|
25 | 25 | use Symfony\Component\PropertyInfo\Tests\Fixtures\DummyCollection; |
26 | 26 | use Symfony\Component\PropertyInfo\Tests\Fixtures\Extractor\ChildOfParentUsingTrait; |
27 | 27 | use Symfony\Component\PropertyInfo\Tests\Fixtures\Extractor\ChildOfParentWithPromotedSelfDocBlock; |
| 28 | +use Symfony\Component\PropertyInfo\Tests\Fixtures\Extractor\ChildWithConstructorOverride; |
| 29 | +use Symfony\Component\PropertyInfo\Tests\Fixtures\Extractor\ChildWithoutConstructorOverride; |
28 | 30 | use Symfony\Component\PropertyInfo\Tests\Fixtures\Extractor\ChildWithSelfDocBlock; |
29 | 31 | use Symfony\Component\PropertyInfo\Tests\Fixtures\Extractor\ClassUsingNestedTrait; |
30 | 32 | use Symfony\Component\PropertyInfo\Tests\Fixtures\Extractor\ClassUsingTraitWithSelfDocBlock; |
31 | 33 | use Symfony\Component\PropertyInfo\Tests\Fixtures\Extractor\ParentUsingTraitWithSelfDocBlock; |
| 34 | +use Symfony\Component\PropertyInfo\Tests\Fixtures\Extractor\ParentWithPromotedPropertyDocBlock; |
32 | 35 | use Symfony\Component\PropertyInfo\Tests\Fixtures\Extractor\ParentWithPromotedSelfDocBlock; |
33 | 36 | use Symfony\Component\PropertyInfo\Tests\Fixtures\Extractor\ParentWithSelfDocBlock; |
34 | 37 | use Symfony\Component\PropertyInfo\Tests\Fixtures\InvalidDummy; |
@@ -827,6 +830,16 @@ public function testPropertiesParentType(string $class, string $property, ?Type |
827 | 830 | $this->assertEquals($type, $this->extractor->getType($class, $property)); |
828 | 831 | } |
829 | 832 |
|
| 833 | + /** |
| 834 | + * @return iterable<array{0: class-string, 1: string, 2: ?Type}> |
| 835 | + */ |
| 836 | + public static function propertiesParentTypeProvider(): iterable |
| 837 | + { |
| 838 | + yield [ParentDummy::class, 'parentAnnotationNoParent', Type::object('parent')]; |
| 839 | + yield [Dummy::class, 'parentAnnotation', Type::object(ParentDummy::class)]; |
| 840 | + } |
| 841 | + |
| 842 | + |
830 | 843 | /** |
831 | 844 | * @param class-string $class |
832 | 845 | * @param class-string $expectedResolvedClass |
@@ -859,13 +872,49 @@ public static function selfDocBlockResolutionProvider(): iterable |
859 | 872 | yield 'promoted property from child' => [ChildOfParentWithPromotedSelfDocBlock::class, 'promotedSelfProp', ParentWithPromotedSelfDocBlock::class]; |
860 | 873 | } |
861 | 874 |
|
| 875 | + #[IgnoreDeprecations] |
| 876 | + #[Group('legacy')] |
| 877 | + #[DataProvider('inheritedPromotedPropertyWithConstructorOverrideProviderLegacy')] |
| 878 | + public function testInheritedPromotedPropertyWithConstructorOverrideLegacy(string $class, string $property, ?array $expectedTypes) |
| 879 | + { |
| 880 | + $this->assertEquals($expectedTypes, $this->extractor->getTypes($class, $property)); |
| 881 | + } |
| 882 | + |
862 | 883 | /** |
863 | | - * @return iterable<array{0: class-string, 1: string, 2: ?Type}> |
| 884 | + * @return iterable<string, array{0: class-string, 1: string, 2: ?array}> |
864 | 885 | */ |
865 | | - public static function propertiesParentTypeProvider(): iterable |
| 886 | + public static function inheritedPromotedPropertyWithConstructorOverrideProviderLegacy(): iterable |
866 | 887 | { |
867 | | - yield [ParentDummy::class, 'parentAnnotationNoParent', Type::object('parent')]; |
868 | | - yield [Dummy::class, 'parentAnnotation', Type::object(ParentDummy::class)]; |
| 888 | + $expectedItemsType = [new LegacyType( |
| 889 | + LegacyType::BUILTIN_TYPE_ARRAY, |
| 890 | + false, |
| 891 | + null, |
| 892 | + true, |
| 893 | + new LegacyType(LegacyType::BUILTIN_TYPE_STRING), |
| 894 | + new LegacyType(LegacyType::BUILTIN_TYPE_INT) |
| 895 | + )]; |
| 896 | + |
| 897 | + yield 'parent promoted property' => [ParentWithPromotedPropertyDocBlock::class, 'items', $expectedItemsType,]; |
| 898 | + yield 'child without constructor override' => [ChildWithoutConstructorOverride::class, 'items', $expectedItemsType]; |
| 899 | + yield 'child with constructor override' => [ChildWithConstructorOverride::class, 'items', $expectedItemsType]; |
| 900 | + } |
| 901 | + |
| 902 | + #[DataProvider('inheritedPromotedPropertyWithConstructorOverrideProvider')] |
| 903 | + public function testInheritedPromotedPropertyWithConstructorOverride(string $class, string $property, ?Type $expectedType) |
| 904 | + { |
| 905 | + $this->assertEquals($expectedType, $this->extractor->getType($class, $property)); |
| 906 | + } |
| 907 | + |
| 908 | + /** |
| 909 | + * @return iterable<string, array{0: class-string, 1: string, 2: ?Type}> |
| 910 | + */ |
| 911 | + public static function inheritedPromotedPropertyWithConstructorOverrideProvider(): iterable |
| 912 | + { |
| 913 | + $expectedItemsType = Type::dict(Type::int(), Type::string()); |
| 914 | + |
| 915 | + yield 'parent promoted property' => [ParentWithPromotedPropertyDocBlock::class, 'items', $expectedItemsType]; |
| 916 | + yield 'child without constructor override' => [ChildWithoutConstructorOverride::class, 'items', $expectedItemsType]; |
| 917 | + yield 'child with constructor override' => [ChildWithConstructorOverride::class, 'items', $expectedItemsType]; |
869 | 918 | } |
870 | 919 |
|
871 | 920 | public function testUnknownPseudoType() |
|
0 commit comments