Skip to content

Commit a88ba01

Browse files
Merge branch '7.4' into 8.0
* 7.4: [GHA] Enable igbinary on windows fix BC layer for Expression constraint from options array [Validator] Add missing Polish plural form for filename length validator [ExpressionLanguage] Fix dumping of null safe operator [TypeInfo] Reuse `CollectionType::mergeCollectionValueTypes` for `ConstFetchNode`
2 parents 81ce818 + 26e54ed commit a88ba01

File tree

10 files changed

+35
-34
lines changed

10 files changed

+35
-34
lines changed

.github/workflows/windows.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ jobs:
4848
cd ext
4949
iwr -outf php_apcu.zip https://github.com/symfony/binary-utils/releases/download/v0.1/php_apcu-5.1.24-8.4-ts-vs17-x86.zip
5050
7z x php_apcu.zip -y >nul
51+
iwr -outf php_igbinary.zip https://github.com/symfony/binary-utils/releases/download/v0.1/php_igbinary-3.2.16-8.4-ts-vs17-x86.zip
52+
7z x php_igbinary.zip -y >nul
5153
iwr -outf php_redis.zip https://github.com/symfony/binary-utils/releases/download/v0.1/php_redis-6.2.0-8.4-ts-vs17-x86.zip
5254
7z x php_redis.zip -y >nul
5355
cd ..
@@ -66,7 +68,7 @@ jobs:
6668
"opcache.enable_cli=1" >> php.ini-max
6769
"extension=php_openssl.dll" >> php.ini-max
6870
"extension=php_apcu.dll" >> php.ini-max
69-
#"extension=php_igbinary.dll" >> php.ini-max
71+
"extension=php_igbinary.dll" >> php.ini-max
7072
"extension=php_redis.dll" >> php.ini-max
7173
"apc.enable_cli=1" >> php.ini-max
7274
"extension=php_intl.dll" >> php.ini-max

src/Symfony/Component/ExpressionLanguage/Node/GetAttrNode.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,12 +141,13 @@ private function isShortCircuited(): bool
141141

142142
public function toArray(): array
143143
{
144+
$nullSafe = $this->nodes['attribute'] instanceof ConstantNode && $this->nodes['attribute']->isNullSafe;
144145
switch ($this->attributes['type']) {
145146
case self::PROPERTY_CALL:
146-
return [$this->nodes['node'], '.', $this->nodes['attribute']];
147+
return [$this->nodes['node'], $nullSafe ? '?.' : '.', $this->nodes['attribute']];
147148

148149
case self::METHOD_CALL:
149-
return [$this->nodes['node'], '.', $this->nodes['attribute'], '(', $this->nodes['arguments'], ')'];
150+
return [$this->nodes['node'], $nullSafe ? '?.' : '.', $this->nodes['attribute'], '(', $this->nodes['arguments'], ')'];
150151

151152
case self::ARRAY_CALL:
152153
return [$this->nodes['node'], '[', $this->nodes['attribute'], ']'];

src/Symfony/Component/ExpressionLanguage/Tests/ExpressionLanguageTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -412,9 +412,9 @@ public function testNullSafeCompileFails($expression, $foo)
412412

413413
public static function provideInvalidNullSafe()
414414
{
415-
yield ['foo?.bar.baz', (object) ['bar' => null], 'Unable to get property "baz" of non-object "foo.bar".'];
416-
yield ['foo?.bar["baz"]', (object) ['bar' => null], 'Unable to get an item of non-array "foo.bar".'];
417-
yield ['foo?.bar["baz"].qux.quux', (object) ['bar' => ['baz' => null]], 'Unable to get property "qux" of non-object "foo.bar["baz"]".'];
415+
yield ['foo?.bar.baz', (object) ['bar' => null], 'Unable to get property "baz" of non-object "foo?.bar".'];
416+
yield ['foo?.bar["baz"]', (object) ['bar' => null], 'Unable to get an item of non-array "foo?.bar".'];
417+
yield ['foo?.bar["baz"].qux.quux', (object) ['bar' => ['baz' => null]], 'Unable to get property "qux" of non-object "foo?.bar["baz"]".'];
418418
}
419419

420420
/**

src/Symfony/Component/ExpressionLanguage/Tests/Node/FunctionNodeTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public static function getCompileData(): array
3434
public static function getDumpData(): array
3535
{
3636
return [
37-
['foo("bar")', new FunctionNode('foo', new Node([new ConstantNode('bar')])), ['foo' => static::getCallables()]],
37+
['foo("bar")', new FunctionNode('foo', new Node([new ConstantNode('bar')]))],
3838
];
3939
}
4040

src/Symfony/Component/ExpressionLanguage/Tests/Node/GetAttrNodeTest.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Symfony\Component\ExpressionLanguage\Node\ConstantNode;
1616
use Symfony\Component\ExpressionLanguage\Node\GetAttrNode;
1717
use Symfony\Component\ExpressionLanguage\Node\NameNode;
18+
use Symfony\Component\ExpressionLanguage\Node\ArgumentsNode;
1819

1920
class GetAttrNodeTest extends AbstractNodeTestCase
2021
{
@@ -50,10 +51,12 @@ public static function getDumpData(): array
5051
['foo[0]', new GetAttrNode(new NameNode('foo'), new ConstantNode(0), self::getArrayNode(), GetAttrNode::ARRAY_CALL)],
5152
['foo["b"]', new GetAttrNode(new NameNode('foo'), new ConstantNode('b'), self::getArrayNode(), GetAttrNode::ARRAY_CALL)],
5253

53-
['foo.foo', new GetAttrNode(new NameNode('foo'), new NameNode('foo'), self::getArrayNode(), GetAttrNode::PROPERTY_CALL), ['foo' => new Obj()]],
54+
['foo.foo', new GetAttrNode(new NameNode('foo'), new NameNode('foo'), self::getArrayNode(), GetAttrNode::PROPERTY_CALL)],
5455

55-
['foo.foo({"b": "a", 0: "b"})', new GetAttrNode(new NameNode('foo'), new NameNode('foo'), self::getArrayNode(), GetAttrNode::METHOD_CALL), ['foo' => new Obj()]],
56+
['foo.foo({"b": "a", 0: "b"})', new GetAttrNode(new NameNode('foo'), new NameNode('foo'), self::getArrayNode(), GetAttrNode::METHOD_CALL)],
5657
['foo[index]', new GetAttrNode(new NameNode('foo'), new NameNode('index'), self::getArrayNode(), GetAttrNode::ARRAY_CALL)],
58+
59+
['foo?.foo()', new GetAttrNode(new NameNode('foo'), new ConstantNode('foo', true, true), new ArgumentsNode(), GetAttrNode::METHOD_CALL)],
5760
];
5861
}
5962

src/Symfony/Component/TypeInfo/Tests/TypeResolver/StringTypeResolverTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,12 @@ public static function resolveDataProvider(): iterable
103103
yield [Type::int(), DummyWithConstants::class.'::DUMMY_INT_*'];
104104
yield [Type::int(), DummyWithConstants::class.'::DUMMY_INT_A'];
105105
yield [Type::float(), DummyWithConstants::class.'::DUMMY_FLOAT_*'];
106-
yield [Type::bool(), DummyWithConstants::class.'::DUMMY_TRUE_*'];
107-
yield [Type::bool(), DummyWithConstants::class.'::DUMMY_FALSE_*'];
106+
yield [Type::true(), DummyWithConstants::class.'::DUMMY_TRUE_*'];
107+
yield [Type::false(), DummyWithConstants::class.'::DUMMY_FALSE_*'];
108108
yield [Type::null(), DummyWithConstants::class.'::DUMMY_NULL_*'];
109-
yield [Type::array(), DummyWithConstants::class.'::DUMMY_ARRAY_*'];
109+
yield [Type::array(null, Type::union(Type::int(), Type::string())), DummyWithConstants::class.'::DUMMY_ARRAY_*'];
110110
yield [Type::enum(DummyEnum::class, Type::string()), DummyWithConstants::class.'::DUMMY_ENUM_*'];
111-
yield [Type::union(Type::string(), Type::int(), Type::float(), Type::bool(), Type::null(), Type::array(), Type::enum(DummyEnum::class, Type::string())), DummyWithConstants::class.'::DUMMY_MIX_*'];
111+
yield [Type::union(Type::enum(DummyEnum::class, Type::string()), Type::array(Type::mixed(), Type::union(Type::int(), Type::string())), Type::string(), Type::int(), Type::float(), Type::bool(), Type::null()), DummyWithConstants::class.'::DUMMY_MIX_*'];
112112

113113
// identifiers
114114
yield [Type::bool(), 'bool'];

src/Symfony/Component/TypeInfo/TypeResolver/StringTypeResolver.php

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -149,29 +149,11 @@ private function getTypeFromNode(TypeNode $node, ?TypeContext $typeContext): Typ
149149

150150
foreach ((new \ReflectionClass($className))->getReflectionConstants() as $const) {
151151
if (preg_match('/^'.str_replace('\*', '.*', preg_quote($node->constExpr->name, '/')).'$/', $const->getName())) {
152-
$constValue = $const->getValue();
153-
154-
$types[] = match (true) {
155-
true === $constValue,
156-
false === $constValue => Type::bool(),
157-
null === $constValue => Type::null(),
158-
\is_string($constValue) => Type::string(),
159-
\is_int($constValue) => Type::int(),
160-
\is_float($constValue) => Type::float(),
161-
\is_array($constValue) => Type::array(),
162-
$constValue instanceof \UnitEnum => Type::enum($constValue::class),
163-
default => Type::mixed(),
164-
};
152+
$types[] = Type::fromValue($const->getValue());
165153
}
166154
}
167155

168-
$types = array_unique($types);
169-
170-
if (\count($types) > 2) {
171-
return Type::union(...$types);
172-
}
173-
174-
return $types[0] ?? Type::null();
156+
return CollectionType::mergeCollectionValueTypes($types);
175157
}
176158

177159
return match ($node->constExpr::class) {

src/Symfony/Component/Validator/Constraints/Expression.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ public function __construct(
6464
trigger_deprecation('symfony/validator', '7.3', 'Passing an array of options to configure the "%s" constraint is deprecated, use named arguments instead.', static::class);
6565

6666
$options = array_merge($expression, $options ?? []);
67+
$expression = null;
6768
} else {
6869
if (\is_array($options)) {
6970
trigger_deprecation('symfony/validator', '7.3', 'Passing an array of options to configure the "%s" constraint is deprecated, use named arguments instead.', static::class);

src/Symfony/Component/Validator/Resources/translations/validators.pl.xlf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@
404404
</trans-unit>
405405
<trans-unit id="104">
406406
<source>The filename is too long. It should have {{ filename_max_length }} character or less.|The filename is too long. It should have {{ filename_max_length }} characters or less.</source>
407-
<target>Nazwa pliku jest za długa. Powinna mieć {{ filename_max_length }} znak lub mniej.|Nazwa pliku jest za długa. Powinna mieć {{ filename_max_length }} znaków lub mniej.</target>
407+
<target>Nazwa pliku jest za długa. Powinna mieć {{ filename_max_length }} znak lub mniej.|Nazwa pliku jest za długa. Powinna mieć {{ filename_max_length }} znaki lub mniej.|Nazwa pliku jest za długa. Powinna mieć {{ filename_max_length }} znaków lub mniej.</target>
408408
</trans-unit>
409409
<trans-unit id="105">
410410
<source>The password strength is too low. Please use a stronger password.</source>

src/Symfony/Component/Validator/Tests/Constraints/ExpressionTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,18 @@ public function testAttributes()
4141
self::assertSame('some attached data', $cConstraint->payload);
4242
self::assertFalse($cConstraint->negate);
4343
}
44+
45+
/**
46+
* @group legacy
47+
*/
48+
public function testInitializeWithOptionsArray()
49+
{
50+
$constraint = new Expression([
51+
'expression' => '!this.getParent().get("field2").getData()',
52+
]);
53+
54+
$this->assertSame('!this.getParent().get("field2").getData()', $constraint->expression);
55+
}
4456
}
4557

4658
class ExpressionDummy

0 commit comments

Comments
 (0)