N°8834 - Add compatibility with PHP 8.4 (#819)

* N°8834 - Add compatibility with PHP 8.4

* Rollback of scssphp/scssphp version upgrade due to compilation error
This commit is contained in:
Lenaick
2026-02-26 10:36:32 +01:00
committed by GitHub
parent d4821b7edc
commit fc967c06ce
961 changed files with 12298 additions and 7130 deletions

View File

@@ -37,7 +37,7 @@ class ArrayNodeDefinition extends NodeDefinition implements ParentNodeDefinition
protected $nodeBuilder;
protected $normalizeKeys = true;
public function __construct(?string $name, NodeParentInterface $parent = null)
public function __construct(?string $name, ?NodeParentInterface $parent = null)
{
parent::__construct($name, $parent);
@@ -126,7 +126,7 @@ class ArrayNodeDefinition extends NodeDefinition implements ParentNodeDefinition
*
* @return $this
*/
public function addDefaultChildrenIfNoneSet(int|string|array $children = null): static
public function addDefaultChildrenIfNoneSet(int|string|array|null $children = null): static
{
$this->addDefaultChildren = $children;
@@ -169,7 +169,7 @@ class ArrayNodeDefinition extends NodeDefinition implements ParentNodeDefinition
*
* @return $this
*/
public function fixXmlConfig(string $singular, string $plural = null): static
public function fixXmlConfig(string $singular, ?string $plural = null): static
{
$this->normalization()->remap($singular, $plural);
@@ -331,7 +331,7 @@ class ArrayNodeDefinition extends NodeDefinition implements ParentNodeDefinition
public function append(NodeDefinition $node): static
{
$this->children[$node->name] = $node->setParent($this);
$this->children[$node->name ?? ''] = $node->setParent($this);
return $this;
}
@@ -374,7 +374,7 @@ class ArrayNodeDefinition extends NodeDefinition implements ParentNodeDefinition
if ($this->default) {
if (!\is_array($this->defaultValue)) {
throw new \InvalidArgumentException(sprintf('%s: the default value of an array node has to be an array.', $node->getPath()));
throw new \InvalidArgumentException(\sprintf('%s: the default value of an array node has to be an array.', $node->getPath()));
}
$node->setDefaultValue($this->defaultValue);
@@ -434,23 +434,23 @@ class ArrayNodeDefinition extends NodeDefinition implements ParentNodeDefinition
$path = $node->getPath();
if (null !== $this->key) {
throw new InvalidDefinitionException(sprintf('->useAttributeAsKey() is not applicable to concrete nodes at path "%s".', $path));
throw new InvalidDefinitionException(\sprintf('->useAttributeAsKey() is not applicable to concrete nodes at path "%s".', $path));
}
if (false === $this->allowEmptyValue) {
throw new InvalidDefinitionException(sprintf('->cannotBeEmpty() is not applicable to concrete nodes at path "%s".', $path));
throw new InvalidDefinitionException(\sprintf('->cannotBeEmpty() is not applicable to concrete nodes at path "%s".', $path));
}
if (true === $this->atLeastOne) {
throw new InvalidDefinitionException(sprintf('->requiresAtLeastOneElement() is not applicable to concrete nodes at path "%s".', $path));
throw new InvalidDefinitionException(\sprintf('->requiresAtLeastOneElement() is not applicable to concrete nodes at path "%s".', $path));
}
if ($this->default) {
throw new InvalidDefinitionException(sprintf('->defaultValue() is not applicable to concrete nodes at path "%s".', $path));
throw new InvalidDefinitionException(\sprintf('->defaultValue() is not applicable to concrete nodes at path "%s".', $path));
}
if (false !== $this->addDefaultChildren) {
throw new InvalidDefinitionException(sprintf('->addDefaultChildrenIfNoneSet() is not applicable to concrete nodes at path "%s".', $path));
throw new InvalidDefinitionException(\sprintf('->addDefaultChildrenIfNoneSet() is not applicable to concrete nodes at path "%s".', $path));
}
}
@@ -466,20 +466,20 @@ class ArrayNodeDefinition extends NodeDefinition implements ParentNodeDefinition
$path = $node->getPath();
if ($this->addDefaults) {
throw new InvalidDefinitionException(sprintf('->addDefaultsIfNotSet() is not applicable to prototype nodes at path "%s".', $path));
throw new InvalidDefinitionException(\sprintf('->addDefaultsIfNotSet() is not applicable to prototype nodes at path "%s".', $path));
}
if (false !== $this->addDefaultChildren) {
if ($this->default) {
throw new InvalidDefinitionException(sprintf('A default value and default children might not be used together at path "%s".', $path));
throw new InvalidDefinitionException(\sprintf('A default value and default children might not be used together at path "%s".', $path));
}
if (null !== $this->key && (null === $this->addDefaultChildren || \is_int($this->addDefaultChildren) && $this->addDefaultChildren > 0)) {
throw new InvalidDefinitionException(sprintf('->addDefaultChildrenIfNoneSet() should set default children names as ->useAttributeAsKey() is used at path "%s".', $path));
throw new InvalidDefinitionException(\sprintf('->addDefaultChildrenIfNoneSet() should set default children names as ->useAttributeAsKey() is used at path "%s".', $path));
}
if (null === $this->key && (\is_string($this->addDefaultChildren) || \is_array($this->addDefaultChildren))) {
throw new InvalidDefinitionException(sprintf('->addDefaultChildrenIfNoneSet() might not set default children names as ->useAttributeAsKey() is not used at path "%s".', $path));
throw new InvalidDefinitionException(\sprintf('->addDefaultChildrenIfNoneSet() might not set default children names as ->useAttributeAsKey() is not used at path "%s".', $path));
}
}
}
@@ -504,7 +504,7 @@ class ArrayNodeDefinition extends NodeDefinition implements ParentNodeDefinition
: substr($nodePath, 0, $pathSeparatorPos);
if (null === $node = ($this->children[$firstPathSegment] ?? null)) {
throw new \RuntimeException(sprintf('Node with name "%s" does not exist in the current node "%s".', $firstPathSegment, $this->name));
throw new \RuntimeException(\sprintf('Node with name "%s" does not exist in the current node "%s".', $firstPathSegment, $this->name));
}
if (false === $pathSeparatorPos) {

View File

@@ -21,7 +21,7 @@ use Symfony\Component\Config\Definition\Exception\InvalidDefinitionException;
*/
class BooleanNodeDefinition extends ScalarNodeDefinition
{
public function __construct(?string $name, NodeParentInterface $parent = null)
public function __construct(?string $name, ?NodeParentInterface $parent = null)
{
parent::__construct($name, $parent);

View File

@@ -42,7 +42,7 @@ class ExprBuilder
*
* @return $this
*/
public function always(\Closure $then = null): static
public function always(?\Closure $then = null): static
{
$this->ifPart = static fn () => true;
$this->allowedTypes = self::TYPE_ANY;
@@ -61,7 +61,7 @@ class ExprBuilder
*
* @return $this
*/
public function ifTrue(\Closure $closure = null): static
public function ifTrue(?\Closure $closure = null): static
{
$this->ifPart = $closure ?? static fn ($v) => true === $v;
$this->allowedTypes = self::TYPE_ANY;
@@ -196,7 +196,7 @@ class ExprBuilder
*/
public function thenInvalid(string $message): static
{
$this->thenPart = static fn ($v) => throw new \InvalidArgumentException(sprintf($message, json_encode($v)));
$this->thenPart = static fn ($v) => throw new \InvalidArgumentException(\sprintf($message, json_encode($v)));
return $this;
}

View File

@@ -39,7 +39,7 @@ class NodeBuilder implements NodeParentInterface
*
* @return $this
*/
public function setParent(ParentNodeDefinitionInterface $parent = null): static
public function setParent(?ParentNodeDefinitionInterface $parent = null): static
{
if (1 > \func_num_args()) {
trigger_deprecation('symfony/form', '6.2', 'Calling "%s()" without any arguments is deprecated, pass null explicitly instead.', __METHOD__);
@@ -190,13 +190,13 @@ class NodeBuilder implements NodeParentInterface
$type = strtolower($type);
if (!isset($this->nodeMapping[$type])) {
throw new \RuntimeException(sprintf('The node type "%s" is not registered.', $type));
throw new \RuntimeException(\sprintf('The node type "%s" is not registered.', $type));
}
$class = $this->nodeMapping[$type];
if (!class_exists($class)) {
throw new \RuntimeException(sprintf('The node class "%s" does not exist.', $class));
throw new \RuntimeException(\sprintf('The node class "%s" does not exist.', $class));
}
return $class;

View File

@@ -38,7 +38,7 @@ abstract class NodeDefinition implements NodeParentInterface
protected $parent;
protected $attributes = [];
public function __construct(?string $name, NodeParentInterface $parent = null)
public function __construct(?string $name, ?NodeParentInterface $parent = null)
{
$this->parent = $parent;
$this->name = $name;

View File

@@ -36,7 +36,7 @@ class NormalizationBuilder
*
* @return $this
*/
public function remap(string $key, string $plural = null): static
public function remap(string $key, ?string $plural = null): static
{
$this->remappings[] = [$key, null === $plural ? $key.'s' : $plural];
@@ -48,7 +48,7 @@ class NormalizationBuilder
*
* @return ExprBuilder|$this
*/
public function before(\Closure $closure = null): ExprBuilder|static
public function before(?\Closure $closure = null): ExprBuilder|static
{
if (null !== $closure) {
$this->before[] = $closure;

View File

@@ -33,7 +33,7 @@ abstract class NumericNodeDefinition extends ScalarNodeDefinition
public function max(int|float $max): static
{
if (isset($this->min) && $this->min > $max) {
throw new \InvalidArgumentException(sprintf('You cannot define a max(%s) as you already have a min(%s).', $max, $this->min));
throw new \InvalidArgumentException(\sprintf('You cannot define a max(%s) as you already have a min(%s).', $max, $this->min));
}
$this->max = $max;
@@ -50,7 +50,7 @@ abstract class NumericNodeDefinition extends ScalarNodeDefinition
public function min(int|float $min): static
{
if (isset($this->max) && $this->max < $min) {
throw new \InvalidArgumentException(sprintf('You cannot define a min(%s) as you already have a max(%s).', $min, $this->max));
throw new \InvalidArgumentException(\sprintf('You cannot define a min(%s) as you already have a max(%s).', $min, $this->max));
}
$this->min = $min;

View File

@@ -30,7 +30,7 @@ class TreeBuilder implements NodeParentInterface
*/
protected $root;
public function __construct(string $name, string $type = 'array', NodeBuilder $builder = null)
public function __construct(string $name, string $type = 'array', ?NodeBuilder $builder = null)
{
$builder ??= new NodeBuilder();
$this->root = $builder->node($name, $type)->setParent($this);

View File

@@ -31,7 +31,7 @@ class ValidationBuilder
*
* @return ExprBuilder|$this
*/
public function rule(\Closure $closure = null): ExprBuilder|static
public function rule(?\Closure $closure = null): ExprBuilder|static
{
if (null !== $closure) {
$this->rules[] = $closure;