THRIFT-5754: Fix PHP 8.1 deprecates passing null to non-nullable internal function parameters
diff --git a/lib/php/lib/Protocol/TJSONProtocol.php b/lib/php/lib/Protocol/TJSONProtocol.php
index 9144884..e1412cc 100644
--- a/lib/php/lib/Protocol/TJSONProtocol.php
+++ b/lib/php/lib/Protocol/TJSONProtocol.php
@@ -108,7 +108,7 @@
{
$result = TType::STOP;
- if (strlen($name) > 1) {
+ if (strlen((string) $name) > 1) {
switch (substr($name, 0, 1)) {
case 'd':
$result = TType::DOUBLE;
diff --git a/lib/php/lib/StringFunc/Core.php b/lib/php/lib/StringFunc/Core.php
index 39a75b3..376e437 100644
--- a/lib/php/lib/StringFunc/Core.php
+++ b/lib/php/lib/StringFunc/Core.php
@@ -27,14 +27,14 @@
{
// specifying a null $length would return an empty string
if ($length === null) {
- return substr($str, $start);
+ return substr((string) $str, $start);
}
- return substr($str, $start, $length);
+ return substr((string) $str, $start, $length);
}
public function strlen($str)
{
- return strlen($str);
+ return strlen((string) $str);
}
}
diff --git a/lib/php/lib/StringFunc/Mbstring.php b/lib/php/lib/StringFunc/Mbstring.php
index 968ff18..ac48309 100644
--- a/lib/php/lib/StringFunc/Mbstring.php
+++ b/lib/php/lib/StringFunc/Mbstring.php
@@ -36,11 +36,11 @@
$length = $this->strlen($str) - $start;
}
- return mb_substr($str, $start, $length, '8bit');
+ return mb_substr((string) $str, $start, $length, '8bit');
}
public function strlen($str)
{
- return mb_strlen($str, '8bit');
+ return mb_strlen((string) $str, '8bit');
}
}
diff --git a/lib/php/lib/TMultiplexedProcessor.php b/lib/php/lib/TMultiplexedProcessor.php
index a64a968..d276cae 100644
--- a/lib/php/lib/TMultiplexedProcessor.php
+++ b/lib/php/lib/TMultiplexedProcessor.php
@@ -97,7 +97,7 @@
}
// Extract the service name and the new Message name.
- if (strpos($fname, TMultiplexedProtocol::SEPARATOR) === false) {
+ if (strpos((string) $fname, TMultiplexedProtocol::SEPARATOR) === false) {
throw new TException("Service name not found in message name: {$fname}. Did you " .
"forget to use a TMultiplexProtocol in your client?");
}
diff --git a/lib/php/src/TStringUtils.php b/lib/php/src/TStringUtils.php
index 894baf8..544211b 100644
--- a/lib/php/src/TStringUtils.php
+++ b/lib/php/src/TStringUtils.php
@@ -12,15 +12,15 @@
{
// specifying a null $length would return an empty string
if ($length === null) {
- return substr($str, $start);
+ return substr((string) $str, $start);
}
- return substr($str, $start, $length);
+ return substr((string) $str, $start, $length);
}
public function strlen($str)
{
- return strlen($str);
+ return strlen((string) $str);
}
}
@@ -39,12 +39,12 @@
$length = $this->strlen($str) - $start;
}
- return mb_substr($str, $start, $length, '8bit');
+ return mb_substr((string) $str, $start, $length, '8bit');
}
public function strlen($str)
{
- return mb_strlen($str, '8bit');
+ return mb_strlen((string) $str, '8bit');
}
}