|
23 | 23 | use Symfony\Component\PropertyInfo\Tests\Fixtures\DummyCollection; |
24 | 24 | use Symfony\Component\PropertyInfo\Tests\Fixtures\Extractor\ChildOfParentUsingTrait; |
25 | 25 | 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; |
26 | 28 | use Symfony\Component\PropertyInfo\Tests\Fixtures\Extractor\ChildWithSelfDocBlock; |
27 | 29 | use Symfony\Component\PropertyInfo\Tests\Fixtures\Extractor\ClassUsingNestedTrait; |
28 | 30 | use Symfony\Component\PropertyInfo\Tests\Fixtures\Extractor\ClassUsingTraitWithSelfDocBlock; |
29 | 31 | use Symfony\Component\PropertyInfo\Tests\Fixtures\Extractor\ParentUsingTraitWithSelfDocBlock; |
| 32 | +use Symfony\Component\PropertyInfo\Tests\Fixtures\Extractor\ParentWithPromotedPropertyDocBlock; |
30 | 33 | use Symfony\Component\PropertyInfo\Tests\Fixtures\Extractor\ParentWithPromotedSelfDocBlock; |
31 | 34 | use Symfony\Component\PropertyInfo\Tests\Fixtures\Extractor\ParentWithSelfDocBlock; |
32 | 35 | use Symfony\Component\PropertyInfo\Tests\Fixtures\InvalidDummy; |
@@ -327,6 +330,16 @@ public function testPropertiesParentType(string $class, string $property, ?Type |
327 | 330 | $this->assertEquals($type, $this->extractor->getType($class, $property)); |
328 | 331 | } |
329 | 332 |
|
| 333 | + /** |
| 334 | + * @return iterable<array{0: class-string, 1: string, 2: ?Type}> |
| 335 | + */ |
| 336 | + public static function propertiesParentTypeProvider(): iterable |
| 337 | + { |
| 338 | + yield [ParentDummy::class, 'parentAnnotationNoParent', Type::object('parent')]; |
| 339 | + yield [Dummy::class, 'parentAnnotation', Type::object(ParentDummy::class)]; |
| 340 | + } |
| 341 | + |
| 342 | + |
330 | 343 | /** |
331 | 344 | * @param class-string $class |
332 | 345 | * @param class-string $expectedResolvedClass |
@@ -359,13 +372,22 @@ public static function selfDocBlockResolutionProvider(): iterable |
359 | 372 | yield 'promoted property from child' => [ChildOfParentWithPromotedSelfDocBlock::class, 'promotedSelfProp', ParentWithPromotedSelfDocBlock::class]; |
360 | 373 | } |
361 | 374 |
|
| 375 | + #[DataProvider('inheritedPromotedPropertyWithConstructorOverrideProvider')] |
| 376 | + public function testInheritedPromotedPropertyWithConstructorOverride(string $class, string $property, ?Type $expectedType) |
| 377 | + { |
| 378 | + $this->assertEquals($expectedType, $this->extractor->getType($class, $property)); |
| 379 | + } |
| 380 | + |
362 | 381 | /** |
363 | | - * @return iterable<array{0: class-string, 1: string, 2: ?Type}> |
| 382 | + * @return iterable<string, array{0: class-string, 1: string, 2: ?Type}> |
364 | 383 | */ |
365 | | - public static function propertiesParentTypeProvider(): iterable |
| 384 | + public static function inheritedPromotedPropertyWithConstructorOverrideProvider(): iterable |
366 | 385 | { |
367 | | - yield [ParentDummy::class, 'parentAnnotationNoParent', Type::object('parent')]; |
368 | | - yield [Dummy::class, 'parentAnnotation', Type::object(ParentDummy::class)]; |
| 386 | + $expectedItemsType = Type::dict(Type::int(), Type::string()); |
| 387 | + |
| 388 | + yield 'parent promoted property' => [ParentWithPromotedPropertyDocBlock::class, 'items', $expectedItemsType]; |
| 389 | + yield 'child without constructor override' => [ChildWithoutConstructorOverride::class, 'items', $expectedItemsType]; |
| 390 | + yield 'child with constructor override' => [ChildWithConstructorOverride::class, 'items', $expectedItemsType]; |
369 | 391 | } |
370 | 392 |
|
371 | 393 | public function testUnknownPseudoType() |
|
0 commit comments