Upgrade 1-11.38

This commit is contained in:
xesmyd
2026-03-30 14:10:30 +02:00
parent f2a7e6d1fc
commit ac648ef29d
24665 changed files with 69682 additions and 2205004 deletions
+30 -25
View File
@@ -11,6 +11,8 @@
namespace Symfony\Component\Serializer\Normalizer;
use Symfony\Component\PropertyAccess\Exception\AccessException;
/**
* Converts between objects and arrays by mapping properties.
*
@@ -30,14 +32,12 @@ namespace Symfony\Component\Serializer\Normalizer;
*/
class PropertyNormalizer extends AbstractObjectNormalizer
{
private $cache = [];
/**
* {@inheritdoc}
*/
public function supportsNormalization($data, $format = null)
{
return parent::supportsNormalization($data, $format) && (isset($this->cache[$type = \get_class($data)]) ? $this->cache[$type] : $this->cache[$type] = $this->supports($type));
return parent::supportsNormalization($data, $format) && $this->supports(\get_class($data));
}
/**
@@ -45,17 +45,21 @@ class PropertyNormalizer extends AbstractObjectNormalizer
*/
public function supportsDenormalization($data, $type, $format = null)
{
return parent::supportsDenormalization($data, $type, $format) && (isset($this->cache[$type]) ? $this->cache[$type] : $this->cache[$type] = $this->supports($type));
return parent::supportsDenormalization($data, $type, $format) && $this->supports($type);
}
/**
* {@inheritdoc}
*/
public function hasCacheableSupportsMethod(): bool
{
return __CLASS__ === static::class;
}
/**
* Checks if the given class has any non-static property.
*
* @param string $class
*
* @return bool
*/
private function supports($class)
private function supports(string $class): bool
{
$class = new \ReflectionClass($class);
@@ -99,20 +103,9 @@ class PropertyNormalizer extends AbstractObjectNormalizer
{
$reflectionObject = new \ReflectionObject($object);
$attributes = [];
$checkPropertyInitialization = \PHP_VERSION_ID >= 70400;
do {
foreach ($reflectionObject->getProperties() as $property) {
if ($checkPropertyInitialization) {
if (!$property->isPublic()) {
$property->setAccessible(true);
}
if (!$property->isInitialized($object)) {
continue;
}
}
if (!$this->isAllowedAttribute($reflectionObject->getName(), $property->name, $format, $context)) {
continue;
}
@@ -121,7 +114,7 @@ class PropertyNormalizer extends AbstractObjectNormalizer
}
} while ($reflectionObject = $reflectionObject->getParentClass());
return $attributes;
return array_unique($attributes);
}
/**
@@ -140,6 +133,21 @@ class PropertyNormalizer extends AbstractObjectNormalizer
$reflectionProperty->setAccessible(true);
}
if (\PHP_VERSION_ID >= 70400 && $reflectionProperty->hasType()) {
return $reflectionProperty->getValue($object);
}
if (!method_exists($object, '__get') && !isset($object->$attribute)) {
$propertyValues = (array) $object;
if (($reflectionProperty->isPublic() && !\array_key_exists($reflectionProperty->name, $propertyValues))
|| ($reflectionProperty->isProtected() && !\array_key_exists("\0*\0{$reflectionProperty->name}", $propertyValues))
|| ($reflectionProperty->isPrivate() && !\array_key_exists("\0{$reflectionProperty->class}\0{$reflectionProperty->name}", $propertyValues))
) {
throw new AccessException(sprintf('The property "%s::$%s" is not initialized.', \get_class($object), $reflectionProperty->name));
}
}
return $reflectionProperty->getValue($object);
}
@@ -168,13 +176,10 @@ class PropertyNormalizer extends AbstractObjectNormalizer
/**
* @param string|object $classOrObject
* @param string $attribute
*
* @return \ReflectionProperty
*
* @throws \ReflectionException
*/
private function getReflectionProperty($classOrObject, $attribute)
private function getReflectionProperty($classOrObject, string $attribute): \ReflectionProperty
{
$reflectionClass = new \ReflectionClass($classOrObject);
while (true) {