You signed in with another tab or window.Reload to refresh your session.You signed out in another tab or window.Reload to refresh your session.You switched accounts on another tab or window.Reload to refresh your session.Dismiss alert
// the type mismatch is not caused by invalid arguments (but e.g. by an incompatible return type hint of the writer method)
259
-
if (0 !==strpos($message,'Argument')) {
258
+
if (!isset($trace[$i]['file']) ||__FILE__ !==$trace[$i]['file']) {
260
259
return;
261
260
}
262
261
263
-
if (isset($trace[$i]['file']) &&__FILE__ ===$trace[$i]['file']) {
262
+
if (\PHP_VERSION_ID <80000) {
263
+
if (0 !==strpos($message,'Argument')) {
264
+
return;
265
+
}
266
+
264
267
$pos =strpos($message,$delim ='must be of the type') ?: (strpos($message,$delim ='must be an instance of') ?:strpos($message,$delim ='must implement interface'));
thrownewInvalidArgumentException(sprintf('Expected argument of type "%s", "%s" given.',$message,'NULL' ===$type ?'null' :$type),0,$previous);
271
274
}
275
+
276
+
if (preg_match('/^\S+::\S+\(\): Argument #\d+ \(\$\S+\) must be of type (\S+), (\S+) given/',$message,$matches)) {
277
+
list(,$expectedType,$actualType) =$matches;
278
+
279
+
thrownewInvalidArgumentException(sprintf('Expected argument of type "%s", "%s" given.',$expectedType,'NULL' ===$actualType ?'null' :$actualType),0,$previous);
280
+
}
272
281
}
273
282
274
283
/**
@@ -471,7 +480,7 @@ private function readProperty($zval, $property)
if (preg_match((sprintf('/^Return value of %s::%s\(\) must be of the type (\w+), null returned$/',preg_quote(\get_class($object)),$access[self::ACCESS_NAME])),$e->getMessage(),$matches)) {
483
+
if (preg_match((sprintf('/^Return value of %s::%s\(\) must be of(?:the)?type (\w+), null returned$/',preg_quote(\get_class($object)),$access[self::ACCESS_NAME])),$e->getMessage(),$matches)) {
475
484
thrownewAccessException(sprintf('The method "%s::%s()" returned "null", but expected type "%3$s". Did you forget to initialize a property or to make the return type nullable using "?%3$s"?',\get_class($object),$access[self::ACCESS_NAME],$matches[1]),0,$e);