Skip to content

Commit dbb6fdc

Browse files
Merge branch '6.4' into 7.3
* 6.4: [HttpClient] Fix dealing with truncated streams after headers arrived with CurlHttpClient [PropertyInfo] Fix DocBlock resolution for inherited promoted properties [HttpFoundation] Fix PdoSessionHandler charset-collation mismatch with the Doctrine DBAL on MySQL [HttpClient] Fix dealing with multiple levels of AsyncResponse decoration [Messenger] Only send UNLISTEN query if we are actively listening [RateLimiter] Persist state when consuming negative tokens
2 parents 8b2856a + 7d961db commit dbb6fdc

File tree

3 files changed

+95
-6
lines changed

3 files changed

+95
-6
lines changed

Extractor/PhpDocExtractor.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -341,8 +341,8 @@ private function findDocBlock(string $class, string $property): array
341341
$ucFirstProperty = ucfirst($property);
342342

343343
switch (true) {
344-
case $reflectionProperty?->isPromoted() && $docBlock = $this->getDocBlockFromConstructor($class, $property):
345-
$data = [$docBlock, self::MUTATOR, null, $reflectionProperty->getDeclaringClass()->getName()];
344+
case $reflectionProperty?->isPromoted() && $docBlock = $this->getDocBlockFromConstructor($reflectionProperty->class, $property):
345+
$data = [$docBlock, self::MUTATOR, null, $reflectionProperty->class];
346346
break;
347347

348348
case [$docBlock, $declaringClass] = $this->getDocBlockFromProperty($class, $property):

Tests/Extractor/PhpDocExtractorTest.php

Lines changed: 57 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,13 @@
2323
use Symfony\Component\PropertyInfo\Tests\Fixtures\DummyCollection;
2424
use Symfony\Component\PropertyInfo\Tests\Fixtures\Extractor\ChildOfParentUsingTrait;
2525
use Symfony\Component\PropertyInfo\Tests\Fixtures\Extractor\ChildOfParentWithPromotedSelfDocBlock;
26+
use Symfony\Component\PropertyInfo\Tests\Fixtures\Extractor\ChildWithConstructorOverride;
27+
use Symfony\Component\PropertyInfo\Tests\Fixtures\Extractor\ChildWithoutConstructorOverride;
2628
use Symfony\Component\PropertyInfo\Tests\Fixtures\Extractor\ChildWithSelfDocBlock;
2729
use Symfony\Component\PropertyInfo\Tests\Fixtures\Extractor\ClassUsingNestedTrait;
2830
use Symfony\Component\PropertyInfo\Tests\Fixtures\Extractor\ClassUsingTraitWithSelfDocBlock;
2931
use Symfony\Component\PropertyInfo\Tests\Fixtures\Extractor\ParentUsingTraitWithSelfDocBlock;
32+
use Symfony\Component\PropertyInfo\Tests\Fixtures\Extractor\ParentWithPromotedPropertyDocBlock;
3033
use Symfony\Component\PropertyInfo\Tests\Fixtures\Extractor\ParentWithPromotedSelfDocBlock;
3134
use Symfony\Component\PropertyInfo\Tests\Fixtures\Extractor\ParentWithSelfDocBlock;
3235
use Symfony\Component\PropertyInfo\Tests\Fixtures\InvalidDummy;
@@ -880,6 +883,16 @@ public function testPropertiesParentType(string $class, string $property, ?Type
880883
$this->assertEquals($type, $this->extractor->getType($class, $property));
881884
}
882885

886+
/**
887+
* @return iterable<array{0: class-string, 1: string, 2: ?Type}>
888+
*/
889+
public static function propertiesParentTypeProvider(): iterable
890+
{
891+
yield [ParentDummy::class, 'parentAnnotationNoParent', Type::object('parent')];
892+
yield [Dummy::class, 'parentAnnotation', Type::object(ParentDummy::class)];
893+
}
894+
895+
883896
/**
884897
* @param class-string $class
885898
* @param class-string $expectedResolvedClass
@@ -914,12 +927,52 @@ public static function selfDocBlockResolutionProvider(): iterable
914927
}
915928

916929
/**
917-
* @return iterable<array{0: class-string, 1: string, 2: ?Type}>
930+
* @dataProvider inheritedPromotedPropertyWithConstructorOverrideProviderLegacy
931+
*
932+
* @group legacy
918933
*/
919-
public static function propertiesParentTypeProvider(): iterable
934+
public function testInheritedPromotedPropertyWithConstructorOverrideLegacy(string $class, string $property, ?array $expectedTypes)
920935
{
921-
yield [ParentDummy::class, 'parentAnnotationNoParent', Type::object('parent')];
922-
yield [Dummy::class, 'parentAnnotation', Type::object(ParentDummy::class)];
936+
$this->assertEquals($expectedTypes, $this->extractor->getTypes($class, $property));
937+
}
938+
939+
/**
940+
* @return iterable<string, array{0: class-string, 1: string, 2: ?array}>
941+
*/
942+
public static function inheritedPromotedPropertyWithConstructorOverrideProviderLegacy(): iterable
943+
{
944+
$expectedItemsType = [new LegacyType(
945+
LegacyType::BUILTIN_TYPE_ARRAY,
946+
false,
947+
null,
948+
true,
949+
new LegacyType(LegacyType::BUILTIN_TYPE_STRING),
950+
new LegacyType(LegacyType::BUILTIN_TYPE_INT)
951+
)];
952+
953+
yield 'parent promoted property' => [ParentWithPromotedPropertyDocBlock::class, 'items', $expectedItemsType,];
954+
yield 'child without constructor override' => [ChildWithoutConstructorOverride::class, 'items', $expectedItemsType];
955+
yield 'child with constructor override' => [ChildWithConstructorOverride::class, 'items', $expectedItemsType];
956+
}
957+
958+
/**
959+
* @dataProvider inheritedPromotedPropertyWithConstructorOverrideProvider
960+
*/
961+
public function testInheritedPromotedPropertyWithConstructorOverride(string $class, string $property, ?Type $expectedType)
962+
{
963+
$this->assertEquals($expectedType, $this->extractor->getType($class, $property));
964+
}
965+
966+
/**
967+
* @return iterable<string, array{0: class-string, 1: string, 2: ?Type}>
968+
*/
969+
public static function inheritedPromotedPropertyWithConstructorOverrideProvider(): iterable
970+
{
971+
$expectedItemsType = Type::dict(Type::int(), Type::string());
972+
973+
yield 'parent promoted property' => [ParentWithPromotedPropertyDocBlock::class, 'items', $expectedItemsType];
974+
yield 'child without constructor override' => [ChildWithoutConstructorOverride::class, 'items', $expectedItemsType];
975+
yield 'child with constructor override' => [ChildWithConstructorOverride::class, 'items', $expectedItemsType];
923976
}
924977

925978
public function testUnknownPseudoType()
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\PropertyInfo\Tests\Fixtures\Extractor;
13+
14+
class ParentWithPromotedPropertyDocBlock
15+
{
16+
/**
17+
* @param array<string, int> $items
18+
*/
19+
public function __construct(
20+
public $items = [],
21+
) {
22+
}
23+
}
24+
25+
class ChildWithoutConstructorOverride extends ParentWithPromotedPropertyDocBlock
26+
{
27+
}
28+
29+
class ChildWithConstructorOverride extends ParentWithPromotedPropertyDocBlock
30+
{
31+
public function __construct(
32+
public $extraProp = null,
33+
) {
34+
parent::__construct();
35+
}
36+
}

0 commit comments

Comments
 (0)