Merge branch '4.3' into 4.4
* 4.3: Fix failures on PHP 7.4
This commit is contained in:
commit
febff9b1fd
@ -305,7 +305,7 @@ class PhpArrayAdapter implements AdapterInterface, CacheInterface, PruneableInte
|
|||||||
public static function throwOnRequiredClass($class)
|
public static function throwOnRequiredClass($class)
|
||||||
{
|
{
|
||||||
$e = new \ReflectionException("Class $class does not exist");
|
$e = new \ReflectionException("Class $class does not exist");
|
||||||
$trace = $e->getTrace();
|
$trace = debug_backtrace();
|
||||||
$autoloadFrame = [
|
$autoloadFrame = [
|
||||||
'function' => 'spl_autoload_call',
|
'function' => 'spl_autoload_call',
|
||||||
'args' => [$class],
|
'args' => [$class],
|
||||||
|
@ -72,7 +72,7 @@ class ClassExistenceResource implements SelfCheckingResourceInterface
|
|||||||
spl_autoload_register(__CLASS__.'::throwOnRequiredClass');
|
spl_autoload_register(__CLASS__.'::throwOnRequiredClass');
|
||||||
}
|
}
|
||||||
$autoloadedClass = self::$autoloadedClass;
|
$autoloadedClass = self::$autoloadedClass;
|
||||||
self::$autoloadedClass = $this->resource;
|
self::$autoloadedClass = ltrim($this->resource, '\\');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$exists = class_exists($this->resource) || interface_exists($this->resource, false) || trait_exists($this->resource, false);
|
$exists = class_exists($this->resource) || interface_exists($this->resource, false) || trait_exists($this->resource, false);
|
||||||
@ -153,7 +153,7 @@ class ClassExistenceResource implements SelfCheckingResourceInterface
|
|||||||
throw $e;
|
throw $e;
|
||||||
}
|
}
|
||||||
|
|
||||||
$trace = $e->getTrace();
|
$trace = debug_backtrace();
|
||||||
$autoloadFrame = [
|
$autoloadFrame = [
|
||||||
'function' => 'spl_autoload_call',
|
'function' => 'spl_autoload_call',
|
||||||
'args' => [$class],
|
'args' => [$class],
|
||||||
|
@ -188,13 +188,14 @@ class PropertyAccessor implements PropertyAccessorInterface
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($trace[$i]['file']) && __FILE__ === $trace[$i]['file'] && \array_key_exists(0, $trace[$i]['args'])) {
|
if (isset($trace[$i]['file']) && __FILE__ === $trace[$i]['file']) {
|
||||||
$pos = strpos($message, $delim = 'must be of the type ') ?: (strpos($message, $delim = 'must be an instance of ') ?: strpos($message, $delim = 'must implement interface '));
|
$pos = strpos($message, $delim = 'must be of the type ') ?: (strpos($message, $delim = 'must be an instance of ') ?: strpos($message, $delim = 'must implement interface '));
|
||||||
$pos += \strlen($delim);
|
$pos += \strlen($delim);
|
||||||
$type = $trace[$i]['args'][0];
|
$j = strpos($message, ',', $pos);
|
||||||
$type = \is_object($type) ? \get_class($type) : \gettype($type);
|
$type = substr($message, 2 + $j, strpos($message, ' given', $j) - $j - 2);
|
||||||
|
$message = substr($message, $pos, $j - $pos);
|
||||||
|
|
||||||
throw new InvalidArgumentException(sprintf('Expected argument of type "%s", "%s" given at property path "%s".', substr($message, $pos, strpos($message, ',', $pos) - $pos), $type, $propertyPath));
|
throw new InvalidArgumentException(sprintf('Expected argument of type "%s", "%s" given at property path "%s".', $message, 'NULL' === $type ? 'null' : $type, $propertyPath));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -546,7 +546,7 @@ class PropertyAccessorTest extends TestCase
|
|||||||
public function testThrowTypeErrorWithNullArgument()
|
public function testThrowTypeErrorWithNullArgument()
|
||||||
{
|
{
|
||||||
$this->expectException('Symfony\Component\PropertyAccess\Exception\InvalidArgumentException');
|
$this->expectException('Symfony\Component\PropertyAccess\Exception\InvalidArgumentException');
|
||||||
$this->expectExceptionMessage('Expected argument of type "DateTime", "NULL" given');
|
$this->expectExceptionMessage('Expected argument of type "DateTime", "null" given');
|
||||||
$object = new TypeHinted();
|
$object = new TypeHinted();
|
||||||
|
|
||||||
$this->propertyAccessor->setValue($object, 'date', null);
|
$this->propertyAccessor->setValue($object, 'date', null);
|
||||||
|
Reference in New Issue
Block a user