8000 bug #48969 [PropertyInfo] Fixes constructor extractor for mixed type … · symfony/symfony@fe23f0f · GitHub
[go: up one dir, main page]

Skip to content

Commit fe23f0f

Browse files
committed
bug #48969 [PropertyInfo] Fixes constructor extractor for mixed type (michael.kubovic)
This PR was squashed before being merged into the 5.4 branch. Discussion ---------- [PropertyInfo] Fixes constructor extractor for mixed type | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | | License | MIT | Doc PR | `ConstructorExtractor` when configured with `PhpDocExtractor` returns an empty array instead of null for properties with `mixed` type. This configuration breaks for example with Messenger. ``` Message: "Could not decode stamp: The type of the "id" attribute for class "Symfony\Component\Messenger\Stamp\TransportMessageIdStamp" must be one of "" ("string" given)." {"exception":"[object] (Symfony\\Component\\Messenger\\Exception\\MessageDecodingFailedException(code: 0): Could not decode stamp: The type of the \"id\" attribute for class \"Symfony\\Component\\Messenger\\Stamp\\TransportMessageIdStamp\" must be one of \"\" (\"string\" given). at /var/www/vendor/symfony/messenger/Transport/Serialization/Serializer.php:123) ``` Commits ------- 4edd347 [PropertyInfo] Fixes constructor extractor for mixed type
2 parents 0096175 + 4edd347 commit fe23f0f

File tree

3 files changed

+4
-2
lines changed

3 files changed

+4
-2
lines changed

src/Symfony/Component/PropertyInfo/Extractor/PhpDocExtractor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ public function getTypesFromConstructor(string $class, string $property): ?array
200200
}
201201
}
202202

203-
if (!isset($types[0])) {
203+
if (!isset($types[0]) || [] === $types[0]) {
204204
return null;
205205
}
206206

src/Symfony/Component/PropertyInfo/Tests/Extractor/PhpDocExtractorTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,7 @@ public function constructorTypesProvider()
443443
['dateObject', [new Type(Type::BUILTIN_TYPE_OBJECT, false, 'DateTimeInterface')]],
444444
['dateTime', null],
445445
['ddd', null],
446+
['mixed', null],
446447
];
447448
}
448449
}

src/Symfony/Component/PropertyInfo/Tests/Fixtures/ConstructorDummy.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,9 @@ class ConstructorDummy
2929
* @param \DateTimeZone $timezone
3030
* @param int $date Timestamp
3131
* @param \DateTimeInterface $dateObject
32+
* @param mixed $mixed
3233
*/
33-
public function __construct(\DateTimeZone $timezone, $date, $dateObject, \DateTime $dateTime)
34+
public function __construct(\DateTimeZone $timezone, $date, $dateObject, \DateTime $dateTime, $mixed)
3435
{
3536
$this->timezone = $timezone->getName();
3637
$this->date = \DateTime::createFromFormat('U', $date);

0 commit comments

Comments
 (0)
0