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
@@ -35,14 +35,13 @@ namespace Symfony\Component\Serializer\Normalizer;
class GetSetMethodNormalizer extends AbstractObjectNormalizer
{
private static $setterAccessibleCache = [];
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));
}
/**
@@ -50,17 +49,21 @@ class GetSetMethodNormalizer 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);
}
/**
* Checks if the given class has any get{Property} method.
*
* @param string $class
*
* @return bool
* {@inheritdoc}
*/
private function supports($class)
public function hasCacheableSupportsMethod(): bool
{
return __CLASS__ === static::class;
}
/**
* Checks if the given class has any getter method.
*/
private function supports(string $class): bool
{
$class = new \ReflectionClass($class);
$methods = $class->getMethods(\ReflectionMethod::IS_PUBLIC);
@@ -74,20 +77,18 @@ class GetSetMethodNormalizer extends AbstractObjectNormalizer
}
/**
* Checks if a method's name is get.* or is.*, and can be called without parameters.
*
* @return bool whether the method is a getter or boolean getter
* Checks if a method's name matches /^(get|is|has).+$/ and can be called non-statically without parameters.
*/
private function isGetMethod(\ReflectionMethod $method)
private function isGetMethod(\ReflectionMethod $method): bool
{
$methodLength = \strlen($method->name);
return
!$method->isStatic() &&
(
((0 === strpos($method->name, 'get') && 3 < $methodLength) ||
(0 === strpos($method->name, 'is') && 2 < $methodLength) ||
(0 === strpos($method->name, 'has') && 3 < $methodLength)) &&
((str_starts_with($method->name, 'get') && 3 < $methodLength) ||
(str_starts_with($method->name, 'is') && 2 < $methodLength) ||
(str_starts_with($method->name, 'has') && 3 < $methodLength)) &&
0 === $method->getNumberOfRequiredParameters()
)
;
@@ -107,7 +108,7 @@ class GetSetMethodNormalizer extends AbstractObjectNormalizer
continue;
}
$attributeName = lcfirst(substr($method->name, 0 === strpos($method->name, 'is') ? 2 : 3));
$attributeName = lcfirst(substr($method->name, str_starts_with($method->name, 'is') ? 2 : 3));
if ($this->isAllowedAttribute($object, $attributeName, $format, $context)) {
$attributes[] = $attributeName;