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
+1 -5
View File
@@ -63,12 +63,8 @@ class Psr6Cache implements CacheInterface
/**
* Replaces backslashes by dots in a class name.
*
* @param string $class
*
* @return string
*/
private function escapeClassName($class)
private function escapeClassName(string $class): string
{
return str_replace('\\', '.', $class);
}
+11 -16
View File
@@ -47,7 +47,7 @@ class ClassMetadata extends GenericMetadata implements ClassMetadataInterface
public $defaultGroup;
/**
* @var MemberMetadata[]
* @var MemberMetadata[][]
*
* @internal This property is public in order to reduce the size of the
* class' serialized representation. Do not access it. Use
@@ -109,12 +109,7 @@ class ClassMetadata extends GenericMetadata implements ClassMetadataInterface
*/
private $reflClass;
/**
* Constructs a metadata for the given class.
*
* @param string $class
*/
public function __construct($class)
public function __construct(string $class)
{
$this->name = $class;
// class name without namespace
@@ -179,17 +174,17 @@ class ClassMetadata extends GenericMetadata implements ClassMetadataInterface
*/
public function addConstraint(Constraint $constraint)
{
if (!in_array(Constraint::CLASS_CONSTRAINT, (array) $constraint->getTargets())) {
if (!\in_array(Constraint::CLASS_CONSTRAINT, (array) $constraint->getTargets())) {
throw new ConstraintDefinitionException(sprintf(
'The constraint "%s" cannot be put on classes.',
get_class($constraint)
\get_class($constraint)
));
}
if ($constraint instanceof Valid) {
throw new ConstraintDefinitionException(sprintf(
'The constraint "%s" cannot be put on classes.',
get_class($constraint)
\get_class($constraint)
));
}
@@ -335,7 +330,7 @@ class ClassMetadata extends GenericMetadata implements ClassMetadataInterface
/**
* Merges the constraints of the given metadata into this object.
*/
public function mergeConstraints(ClassMetadata $source)
public function mergeConstraints(self $source)
{
if ($source->isGroupSequenceProvider()) {
$this->setGroupSequenceProvider(true);
@@ -350,7 +345,7 @@ class ClassMetadata extends GenericMetadata implements ClassMetadataInterface
$member = clone $member;
foreach ($member->getConstraints() as $constraint) {
if (in_array($constraint::DEFAULT_GROUP, $constraint->groups, true)) {
if (\in_array($constraint::DEFAULT_GROUP, $constraint->groups, true)) {
$member->constraintsByGroup[$this->getDefaultGroup()][] = $constraint;
}
@@ -415,15 +410,15 @@ class ClassMetadata extends GenericMetadata implements ClassMetadataInterface
throw new GroupDefinitionException('Defining a static group sequence is not allowed with a group sequence provider');
}
if (is_array($groupSequence)) {
if (\is_array($groupSequence)) {
$groupSequence = new GroupSequence($groupSequence);
}
if (in_array(Constraint::DEFAULT_GROUP, $groupSequence->groups, true)) {
if (\in_array(Constraint::DEFAULT_GROUP, $groupSequence->groups, true)) {
throw new GroupDefinitionException(sprintf('The group "%s" is not allowed in group sequences', Constraint::DEFAULT_GROUP));
}
if (!in_array($this->getDefaultGroup(), $groupSequence->groups, true)) {
if (!\in_array($this->getDefaultGroup(), $groupSequence->groups, true)) {
throw new GroupDefinitionException(sprintf('The group "%s" is missing in the group sequence', $this->getDefaultGroup()));
}
@@ -437,7 +432,7 @@ class ClassMetadata extends GenericMetadata implements ClassMetadataInterface
*/
public function hasGroupSequence()
{
return $this->groupSequence && count($this->groupSequence->groups) > 0;
return $this->groupSequence && \count($this->groupSequence->groups) > 0;
}
/**
@@ -78,16 +78,20 @@ class LazyLoadingMetadataFactory implements MetadataFactoryInterface
*/
public function getMetadataFor($value)
{
if (!is_object($value) && !is_string($value)) {
throw new NoSuchMetadataException(sprintf('Cannot create metadata for non-objects. Got: %s', gettype($value)));
if (!\is_object($value) && !\is_string($value)) {
throw new NoSuchMetadataException(sprintf('Cannot create metadata for non-objects. Got: %s', \gettype($value)));
}
$class = ltrim(is_object($value) ? get_class($value) : $value, '\\');
$class = ltrim(\is_object($value) ? \get_class($value) : $value, '\\');
if (isset($this->loadedClasses[$class])) {
return $this->loadedClasses[$class];
}
if (!class_exists($class) && !interface_exists($class, false)) {
throw new NoSuchMetadataException(sprintf('The class or interface "%s" does not exist.', $class));
}
if (null !== $this->cache && false !== ($metadata = $this->cache->read($class))) {
// Include constraints from the parent class
$this->mergeConstraints($metadata);
@@ -95,10 +99,6 @@ class LazyLoadingMetadataFactory implements MetadataFactoryInterface
return $this->loadedClasses[$class] = $metadata;
}
if (!class_exists($class) && !interface_exists($class)) {
throw new NoSuchMetadataException(sprintf('The class or interface "%s" does not exist.', $class));
}
$metadata = new ClassMetadata($class);
if (null !== $this->loader) {
@@ -154,16 +154,12 @@ class LazyLoadingMetadataFactory implements MetadataFactoryInterface
*/
public function hasMetadataFor($value)
{
if (!is_object($value) && !is_string($value)) {
if (!\is_object($value) && !\is_string($value)) {
return false;
}
$class = ltrim(is_object($value) ? get_class($value) : $value, '\\');
$class = ltrim(\is_object($value) ? \get_class($value) : $value, '\\');
if (class_exists($class) || interface_exists($class)) {
return true;
}
return false;
return class_exists($class) || interface_exists($class, false);
}
}
+3 -3
View File
@@ -125,11 +125,11 @@ class GenericMetadata implements MetadataInterface
throw new ConstraintDefinitionException(sprintf(
'The constraint "%s" can only be put on classes. Please use '.
'"Symfony\Component\Validator\Constraints\Valid" instead.',
get_class($constraint)
\get_class($constraint)
));
}
if ($constraint instanceof Valid) {
if ($constraint instanceof Valid && null === $constraint->groups) {
$this->cascadingStrategy = CascadingStrategy::CASCADE;
if ($constraint->traverse) {
@@ -181,7 +181,7 @@ class GenericMetadata implements MetadataInterface
*/
public function hasConstraints()
{
return count($this->constraints) > 0;
return \count($this->constraints) > 0;
}
/**
+1 -1
View File
@@ -39,7 +39,7 @@ class GetterMetadata extends MemberMetadata
*
* @throws ValidatorException
*/
public function __construct($class, $property, $method = null)
public function __construct(string $class, string $property, string $method = null)
{
if (null === $method) {
$getMethod = 'get'.ucfirst($property);
+1 -1
View File
@@ -32,7 +32,7 @@ abstract class FileLoader extends AbstractLoader
*
* @throws MappingException If the file does not exist or is not readable
*/
public function __construct($file)
public function __construct(string $file)
{
if (!is_file($file)) {
throw new MappingException(sprintf('The mapping file "%s" does not exist', $file));
+1 -1
View File
@@ -36,7 +36,7 @@ class LoaderChain implements LoaderInterface
{
foreach ($loaders as $loader) {
if (!$loader instanceof LoaderInterface) {
throw new MappingException(sprintf('Class %s is expected to implement LoaderInterface', get_class($loader)));
throw new MappingException(sprintf('Class %s is expected to implement LoaderInterface', \get_class($loader)));
}
}
@@ -28,7 +28,7 @@ class StaticMethodLoader implements LoaderInterface
*
* @param string $methodName The name of the static method to call
*/
public function __construct($methodName = 'loadValidatorMetadata')
public function __construct(string $methodName = 'loadValidatorMetadata')
{
$this->methodName = $methodName;
}
+14 -14
View File
@@ -75,17 +75,17 @@ class XmlFileLoader extends FileLoader
$constraints = array();
foreach ($nodes as $node) {
if (count($node) > 0) {
if (count($node->value) > 0) {
if (\count($node) > 0) {
if (\count($node->value) > 0) {
$options = $this->parseValues($node->value);
} elseif (count($node->constraint) > 0) {
} elseif (\count($node->constraint) > 0) {
$options = $this->parseConstraints($node->constraint);
} elseif (count($node->option) > 0) {
} elseif (\count($node->option) > 0) {
$options = $this->parseOptions($node->option);
} else {
$options = array();
}
} elseif (strlen((string) $node) > 0) {
} elseif (\strlen((string) $node) > 0) {
$options = XmlUtils::phpize(trim($node));
} else {
$options = null;
@@ -109,10 +109,10 @@ class XmlFileLoader extends FileLoader
$values = array();
foreach ($nodes as $node) {
if (count($node) > 0) {
if (count($node->value) > 0) {
if (\count($node) > 0) {
if (\count($node->value) > 0) {
$value = $this->parseValues($node->value);
} elseif (count($node->constraint) > 0) {
} elseif (\count($node->constraint) > 0) {
$value = $this->parseConstraints($node->constraint);
} else {
$value = array();
@@ -143,17 +143,17 @@ class XmlFileLoader extends FileLoader
$options = array();
foreach ($nodes as $node) {
if (count($node) > 0) {
if (count($node->value) > 0) {
if (\count($node) > 0) {
if (\count($node->value) > 0) {
$value = $this->parseValues($node->value);
} elseif (count($node->constraint) > 0) {
} elseif (\count($node->constraint) > 0) {
$value = $this->parseConstraints($node->constraint);
} else {
$value = array();
}
} else {
$value = XmlUtils::phpize($node);
if (is_string($value)) {
if (\is_string($value)) {
$value = trim($value);
}
}
@@ -203,12 +203,12 @@ class XmlFileLoader extends FileLoader
private function loadClassMetadataFromXml(ClassMetadata $metadata, \SimpleXMLElement $classDescription)
{
if (count($classDescription->{'group-sequence-provider'}) > 0) {
if (\count($classDescription->{'group-sequence-provider'}) > 0) {
$metadata->setGroupSequenceProvider(true);
}
foreach ($classDescription->{'group-sequence'} as $groupSequence) {
if (count($groupSequence->value) > 0) {
if (\count($groupSequence->value) > 0) {
$metadata->setGroupSequence($this->parseValues($groupSequence[0]->value));
}
}
+8 -16
View File
@@ -83,16 +83,16 @@ class YamlFileLoader extends FileLoader
$values = array();
foreach ($nodes as $name => $childNodes) {
if (is_numeric($name) && is_array($childNodes) && 1 === count($childNodes)) {
if (is_numeric($name) && \is_array($childNodes) && 1 === \count($childNodes)) {
$options = current($childNodes);
if (is_array($options)) {
if (\is_array($options)) {
$options = $this->parseNodes($options);
}
$values[] = $this->newConstraint(key($childNodes), $options);
} else {
if (is_array($childNodes)) {
if (\is_array($childNodes)) {
$childNodes = $this->parseNodes($childNodes);
}
@@ -115,18 +115,10 @@ class YamlFileLoader extends FileLoader
*/
private function parseFile($path)
{
$prevErrorHandler = set_error_handler(function ($level, $message, $script, $line) use ($path, &$prevErrorHandler) {
$message = E_USER_DEPRECATED === $level ? preg_replace('/ on line \d+/', ' in "'.$path.'"$0', $message) : $message;
return $prevErrorHandler ? $prevErrorHandler($level, $message, $script, $line) : false;
});
try {
$classes = $this->yamlParser->parse(file_get_contents($path), Yaml::PARSE_KEYS_AS_STRINGS);
$classes = $this->yamlParser->parseFile($path, Yaml::PARSE_CONSTANT);
} catch (ParseException $e) {
throw new \InvalidArgumentException(sprintf('The file "%s" does not contain valid YAML.', $path), 0, $e);
} finally {
restore_error_handler();
}
// empty file
@@ -135,7 +127,7 @@ class YamlFileLoader extends FileLoader
}
// not an array
if (!is_array($classes)) {
if (!\is_array($classes)) {
throw new \InvalidArgumentException(sprintf('The file "%s" must contain a YAML array.', $this->file));
}
@@ -171,13 +163,13 @@ class YamlFileLoader extends FileLoader
$metadata->setGroupSequence($classDescription['group_sequence']);
}
if (isset($classDescription['constraints']) && is_array($classDescription['constraints'])) {
if (isset($classDescription['constraints']) && \is_array($classDescription['constraints'])) {
foreach ($this->parseNodes($classDescription['constraints']) as $constraint) {
$metadata->addConstraint($constraint);
}
}
if (isset($classDescription['properties']) && is_array($classDescription['properties'])) {
if (isset($classDescription['properties']) && \is_array($classDescription['properties'])) {
foreach ($classDescription['properties'] as $property => $constraints) {
if (null !== $constraints) {
foreach ($this->parseNodes($constraints) as $constraint) {
@@ -187,7 +179,7 @@ class YamlFileLoader extends FileLoader
}
}
if (isset($classDescription['getters']) && is_array($classDescription['getters'])) {
if (isset($classDescription['getters']) && \is_array($classDescription['getters'])) {
foreach ($classDescription['getters'] as $getter => $constraints) {
if (null !== $constraints) {
foreach ($this->parseNodes($constraints) as $constraint) {
+4 -4
View File
@@ -59,7 +59,7 @@ abstract class MemberMetadata extends GenericMetadata implements PropertyMetadat
* @param string $name The name of the member
* @param string $property The property the member belongs to
*/
public function __construct($class, $name, $property)
public function __construct(string $class, string $name, string $property)
{
$this->class = $class;
$this->name = $name;
@@ -71,10 +71,10 @@ abstract class MemberMetadata extends GenericMetadata implements PropertyMetadat
*/
public function addConstraint(Constraint $constraint)
{
if (!in_array(Constraint::PROPERTY_CONSTRAINT, (array) $constraint->getTargets())) {
if (!\in_array(Constraint::PROPERTY_CONSTRAINT, (array) $constraint->getTargets())) {
throw new ConstraintDefinitionException(sprintf(
'The constraint %s cannot be put on properties or getters',
get_class($constraint)
\get_class($constraint)
));
}
@@ -166,7 +166,7 @@ abstract class MemberMetadata extends GenericMetadata implements PropertyMetadat
*/
public function getReflectionMember($objectOrClassName)
{
$className = is_string($objectOrClassName) ? $objectOrClassName : get_class($objectOrClassName);
$className = \is_string($objectOrClassName) ? $objectOrClassName : \get_class($objectOrClassName);
if (!isset($this->reflMember[$className])) {
$this->reflMember[$className] = $this->newReflectionMember($objectOrClassName);
}
+2 -2
View File
@@ -34,7 +34,7 @@ class PropertyMetadata extends MemberMetadata
*
* @throws ValidatorException
*/
public function __construct($class, $name)
public function __construct(string $class, string $name)
{
if (!property_exists($class, $name)) {
throw new ValidatorException(sprintf('Property "%s" does not exist in class "%s"', $name, $class));
@@ -56,7 +56,7 @@ class PropertyMetadata extends MemberMetadata
*/
protected function newReflectionMember($objectOrClassName)
{
$originalClass = is_string($objectOrClassName) ? $objectOrClassName : get_class($objectOrClassName);
$originalClass = \is_string($objectOrClassName) ? $objectOrClassName : \get_class($objectOrClassName);
while (!property_exists($objectOrClassName, $this->getName())) {
$objectOrClassName = get_parent_class($objectOrClassName);