Merge branch '4.3' into 4.4

* 4.3:
  Fix failures on PHP 7.4
This commit is contained in:
Nicolas Grekas 2019-12-01 11:50:45 +01:00
commit febff9b1fd
4 changed files with 9 additions and 8 deletions

View File

@ -305,7 +305,7 @@ class PhpArrayAdapter implements AdapterInterface, CacheInterface, PruneableInte
public static function throwOnRequiredClass($class)
{
$e = new \ReflectionException("Class $class does not exist");
$trace = $e->getTrace();
$trace = debug_backtrace();
$autoloadFrame = [
'function' => 'spl_autoload_call',
'args' => [$class],

View File

@ -72,7 +72,7 @@ class ClassExistenceResource implements SelfCheckingResourceInterface
spl_autoload_register(__CLASS__.'::throwOnRequiredClass');
}
$autoloadedClass = self::$autoloadedClass;
self::$autoloadedClass = $this->resource;
self::$autoloadedClass = ltrim($this->resource, '\\');
try {
$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;
}
$trace = $e->getTrace();
$trace = debug_backtrace();
$autoloadFrame = [
'function' => 'spl_autoload_call',
'args' => [$class],

View File

@ -188,13 +188,14 @@ class PropertyAccessor implements PropertyAccessorInterface
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 += \strlen($delim);
$type = $trace[$i]['args'][0];
$type = \is_object($type) ? \get_class($type) : \gettype($type);
$j = strpos($message, ',', $pos);
$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));
}
}

View File

@ -546,7 +546,7 @@ class PropertyAccessorTest extends TestCase
public function testThrowTypeErrorWithNullArgument()
{
$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();
$this->propertyAccessor->setValue($object, 'date', null);