Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit efaf7fe

Browse filesBrowse files
committed
[PropertyInfo] Deprecate Type
1 parent 3590ca3 commit efaf7fe
Copy full SHA for efaf7fe

18 files changed

+103
-0
lines changed

‎UPGRADE-7.3.md

Copy file name to clipboardExpand all lines: UPGRADE-7.3.md
+12
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,11 @@ Console
8888

8989
* Deprecate methods `Command::getDefaultName()` and `Command::getDefaultDescription()` in favor of the `#[AsCommand]` attribute
9090

91+
DoctrineBridge
92+
--------------
93+
94+
* Deprecate the `DoctrineExtractor::getTypes()` method, use `DoctrineExtractor::getType()` instead
95+
9196
FrameworkBundle
9297
---------------
9398

@@ -115,6 +120,13 @@ OptionsResolver
115120
});
116121
```
117122

123+
PropertyInfo
124+
-------
125+
126+
* Deprecate the `Type` class, use `Symfony\Component\TypeInfo\Type` class of `symfony/type-info` component instead
127+
* Deprecate the `PropertyTypeExtractorInterface::getTypes()` method, use `PropertyTypeExtractorInterface::getType()` instead
128+
* Deprecate the `ConstructorArgumentTypeExtractorInterface::getTypesFromConstructor()` method, use `ConstructorArgumentTypeExtractorInterface::getTypeFromConstructor()` instead
129+
118130
SecurityBundle
119131
--------------
120132

‎src/Symfony/Bridge/Doctrine/CHANGELOG.md

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Doctrine/CHANGELOG.md
+5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
CHANGELOG
22
=========
33

4+
7.3
5+
---
6+
7+
* Deprecate the `DoctrineExtractor::getTypes()` method, use `DoctrineExtractor::getType()` instead
8+
49
7.2
510
---
611

‎src/Symfony/Bridge/Doctrine/PropertyInfo/DoctrineExtractor.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Doctrine/PropertyInfo/DoctrineExtractor.php
+5
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,13 @@ public function getType(string $class, string $property, array $context = []): ?
161161
};
162162
}
163163

164+
/**
165+
* @deprecated since Symfony 7.3, use "getType" instead
166+
*/
164167
public function getTypes(string $class, string $property, array $context = []): ?array
165168
{
169+
trigger_deprecation('symfony/property-info', '7.3', 'The "%s()" method is deprecated, use "%s::getType()" instead.', __METHOD__, self::class);
170+
166171
if (null === $metadata = $this->getMetadata($class)) {
167172
return null;
168173
}

‎src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/DoctrineExtractorTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/DoctrineExtractorTest.php
+14
Original file line numberDiff line numberDiff line change
@@ -108,13 +108,18 @@ public function testTestGetPropertiesWithEmbedded()
108108
}
109109

110110
/**
111+
* @group legacy
112+
*
111113
* @dataProvider legacyTypesProvider
112114
*/
113115
public function testExtractLegacy(string $property, ?array $type = null)
114116
{
115117
$this->assertEquals($type, $this->createExtractor()->getTypes(DoctrineDummy::class, $property, []));
116118
}
117119

120+
/**
121+
* @group legacy
122+
*/
118123
public function testExtractWithEmbeddedLegacy()
119124
{
120125
$expectedTypes = [new LegacyType(
@@ -132,6 +137,9 @@ public function testExtractWithEmbeddedLegacy()
132137
$this->assertEquals($expectedTypes, $actualTypes);
133138
}
134139

140+
/**
141+
* @group legacy
142+
*/
135143
public function testExtractEnumLegacy()
136144
{
137145
$this->assertEquals([new LegacyType(LegacyType::BUILTIN_TYPE_OBJECT, false, EnumString::class)], $this->createExtractor()->getTypes(DoctrineEnum::class, 'enumString', []));
@@ -141,6 +149,9 @@ public function testExtractEnumLegacy()
141149
$this->assertNull($this->createExtractor()->getTypes(DoctrineEnum::class, 'enumCustom', []));
142150
}
143151

152+
/**
153+
* @group legacy
154+
*/
144155
public static function legacyTypesProvider(): array
145156
{
146157
// DBAL 4 has a special fallback strategy for BINGINT (int -> string)
@@ -240,6 +251,9 @@ public function testGetPropertiesCatchException()
240251
$this->assertNull($this->createExtractor()->getProperties('Not\Exist'));
241252
}
242253

254+
/**
255+
* @group legacy
256+
*/
243257
public function testGetTypesCatchExceptionLegacy()
244258
{
245259
$this->assertNull($this->createExtractor()->getTypes('Not\Exist', 'baz'));

‎src/Symfony/Component/PropertyInfo/CHANGELOG.md

Copy file name to clipboardExpand all lines: src/Symfony/Component/PropertyInfo/CHANGELOG.md
+3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ CHANGELOG
66

77
* Add support for `non-positive-int`, `non-negative-int` and `non-zero-int` PHPStan types to `PhpStanExtractor`
88
* Add `PropertyDescriptionExtractorInterface` to `PhpStanExtractor`
9+
* Deprecate the `Type` class, use `Symfony\Component\TypeInfo\Type` class of `symfony/type-info` component instead
10+
* Deprecate the `PropertyTypeExtractorInterface::getTypes()` method, use `PropertyTypeExtractorInterface::getType()` instead
11+
* Deprecate the `ConstructorArgumentTypeExtractorInterface::getTypesFromConstructor()` method, use `ConstructorArgumentTypeExtractorInterface::getTypeFromConstructor()` instead
912

1013
7.1
1114
---

‎src/Symfony/Component/PropertyInfo/Extractor/ConstructorArgumentTypeExtractorInterface.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/PropertyInfo/Extractor/ConstructorArgumentTypeExtractorInterface.php
+2
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ interface ConstructorArgumentTypeExtractorInterface
2424
/**
2525
* Gets types of an argument from constructor.
2626
*
27+
* @deprecated since Symfony 7.3, use "getTypeFromConstructor" instead
28+
*
2729
* @return LegacyType[]|null
2830
*/
2931
public function getTypesFromConstructor(string $class, string $property): ?array;

‎src/Symfony/Component/PropertyInfo/Extractor/ConstructorExtractor.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/PropertyInfo/Extractor/ConstructorExtractor.php
+5
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,13 @@ public function getType(string $class, string $property, array $context = []): ?
4040
return null;
4141
}
4242

43+
/**
44+
* @deprecated since Symfony 7.3, use "getType" instead
45+
*/
4346
public function getTypes(string $class, string $property, array $context = []): ?array
4447
{
48+
trigger_deprecation('symfony/property-info', '7.3', 'The "%s()" method is deprecated, use "%s::getType()" instead.', __METHOD__, self::class);
49+
4550
foreach ($this->extractors as $extractor) {
4651
$value = $extractor->getTypesFromConstructor($class, $property);
4752
if (null !== $value) {

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/PropertyInfo/Extractor/PhpDocExtractor.php
+10
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,13 @@ public function getLongDescription(string $class, string $property, array $conte
118118
return '' === $contents ? null : $contents;
119119
}
120120

121+
/**
122+
* @deprecated since Symfony 7.3, use "getType" instead
123+
*/
121124
public function getTypes(string $class, string $property, array $context = []): ?array
122125
{
126+
trigger_deprecation('symfony/property-info', '7.3', 'The "%s()" method is deprecated, use "%s::getType()" instead.', __METHOD__, self::class);
127+
123128
/** @var DocBlock $docBlock */
124129
[$docBlock, $source, $prefix] = $this->findDocBlock($class, $property);
125130
if (!$docBlock) {
@@ -171,8 +176,13 @@ public function getTypes(string $class, string $property, array $context = []):
171176
return [new LegacyType(LegacyType::BUILTIN_TYPE_ARRAY, false, null, true, new LegacyType(LegacyType::BUILTIN_TYPE_INT), $types[0])];
172177
}
173178

179+
/**
180+
* @deprecated since Symfony 7.3, use "getTypeFromConstructor" instead
181+
*/
174182
public function getTypesFromConstructor(string $class, string $property): ?array
175183
{
184+
trigger_deprecation('symfony/property-info', '7.3', 'The "%s()" method is deprecated, use "%s::getTypeFromConstructor()" instead.', __METHOD__, self::class);
185+
176186
$docBlock = $this->getDocBlockFromConstructor($class, $property);
177187

178188
if (!$docBlock) {

‎src/Symfony/Component/PropertyInfo/Extractor/PhpStanExtractor.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/PropertyInfo/Extractor/PhpStanExtractor.php
+9
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,13 @@ public function __construct(?array $mutatorPrefixes = null, ?array $accessorPref
9393
$this->typeContextFactory = new TypeContextFactory($this->stringTypeResolver);
9494
}
9595

96+
/**
97+
* @deprecated since Symfony 7.3, use "getType" instead
98+
*/
9699
public function getTypes(string $class, string $property, array $context = []): ?array
97100
{
101+
trigger_deprecation('symfony/property-info', '7.3', 'The "%s()" method is deprecated, use "%s::getType()" instead.', __METHOD__, self::class);
102+
98103
/** @var PhpDocNode|null $docNode */
99104
[$docNode, $source, $prefix, $declaringClass] = $this->getDocBlock($class, $property);
100105
if (null === $docNode) {
@@ -166,10 +171,14 @@ public function getTypes(string $class, string $property, array $context = []):
166171
}
167172

168173
/**
174+
* @deprecated since Symfony 7.3, use "getTypeFromConstructor" instead
175+
*
169176
* @return LegacyType[]|null
170177
*/
171178
public function getTypesFromConstructor(string $class, string $property): ?array
172179
{
180+
trigger_deprecation('symfony/property-info', '7.3', 'The "%s()" method is deprecated, use "%s::getTypeFromConstructor()" instead.', __METHOD__, self::class);
181+
173182
if (null === $tagDocNode = $this->getDocBlockFromConstructor($class, $property)) {
174183
return null;
175184
}

‎src/Symfony/Component/PropertyInfo/Extractor/ReflectionExtractor.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/PropertyInfo/Extractor/ReflectionExtractor.php
+9
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,13 @@ public function getProperties(string $class, array $context = []): ?array
155155
return $properties ? array_values($properties) : null;
156156
}
157157

158+
/**
159+
* @deprecated since Symfony 7.3, use "getType" instead
160+
*/
158161
public function getTypes(string $class, string $property, array $context = []): ?array
159162
{
163+
trigger_deprecation('symfony/property-info', '7.3', 'The "%s()" method is deprecated, use "%s::getType()" instead.', __METHOD__, self::class);
164+
160165
if ($fromMutator = $this->extractFromMutator($class, $property)) {
161166
return $fromMutator;
162167
}
@@ -180,10 +185,14 @@ public function getTypes(string $class, string $property, array $context = []):
180185
}
181186

182187
/**
188+
* @deprecated since Symfony 7.3, use "getTypeFromConstructor" instead
189+
*
183190
* @return LegacyType[]|null
184191
*/
185192
public function getTypesFromConstructor(string $class, string $property): ?array
186193
{
194+
trigger_deprecation('symfony/property-info', '7.3', 'The "%s()" method is deprecated, use "%s::getTypeFromConstructor()" instead.', __METHOD__, self::class);
195+
187196
try {
188197
$reflection = new \ReflectionClass($class);
189198
} catch (\ReflectionException) {

‎src/Symfony/Component/PropertyInfo/PropertyInfoCacheExtractor.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/PropertyInfo/PropertyInfoCacheExtractor.php
+5
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,13 @@ public function getType(string $class, string $property, array $context = []): ?
9595
return $this->arrayCache[$key] = $value;
9696
}
9797

98+
/**
99+
* @deprecated since Symfony 7.3, use "getType" instead
100+
*/
98101
public function getTypes(string $class, string $property, array $context = []): ?array
99102
{
103+
trigger_deprecation('symfony/property-info', '7.3', 'The "%s()" method is deprecated, use "%s::getType()" instead.', __METHOD__, self::class);
104+
100105
return $this->extract('getTypes', [$class, $property, $context]);
101106
}
102107

‎src/Symfony/Component/PropertyInfo/PropertyInfoExtractor.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/PropertyInfo/PropertyInfoExtractor.php
+5
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,13 @@ public function getType(string $class, string $property, array $context = []): ?
7575
return null;
7676
}
7777

78+
/**
79+
* @deprecated since Symfony 7.3, use "getType" instead
80+
*/
7881
public function getTypes(string $class, string $property, array $context = []): ?array
7982
{
83+
trigger_deprecation('symfony/property-info', '7.3', 'The "%s()" method is deprecated, use "%s::getType()" instead.', __METHOD__, self::class);
84+
8085
return $this->extract($this->typeExtractors, 'getTypes', [$class, $property, $context]);
8186
}
8287

‎src/Symfony/Component/PropertyInfo/PropertyTypeExtractorInterface.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/PropertyInfo/PropertyTypeExtractorInterface.php
+2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ interface PropertyTypeExtractorInterface
2626
/**
2727
* Gets types of a property.
2828
*
29+
* @deprecated since Symfony 7.3, use "getType" instead
30+
*
2931
* @return LegacyType[]|null
3032
*/
3133
public function getTypes(string $class, string $property, array $context = []): ?array;

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/PropertyInfo/Tests/Extractor/PhpDocExtractorTest.php
+3
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,9 @@ public function testUnknownPseudoTypeLegacy()
447447
$this->assertEquals([new LegacyType(LegacyType::BUILTIN_TYPE_OBJECT, false, 'scalar')], $this->extractor->getTypes(PseudoTypeDummy::class, 'unknownPseudoType'));
448448
}
449449

450+
/**
451+
* @group legacy
452+
*/
450453
public function testGenericInterface()
451454
{
452455
$this->assertNull($this->extractor->getTypes(Dummy::class, 'genericInterface'));

‎src/Symfony/Component/PropertyInfo/Tests/Extractor/PhpStanExtractorTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/PropertyInfo/Tests/Extractor/PhpStanExtractorTest.php
+5
Original file line numberDiff line numberDiff line change
@@ -559,6 +559,8 @@ public static function allowPrivateAccessLegacyProvider(): array
559559
}
560560

561561
/**
562+
* @group legacy
563+
*
562564
* @param list<LegacyType> $expectedTypes
563565
*
564566
* @dataProvider legacyGenericsProvider
@@ -1043,6 +1045,9 @@ public static function allowPrivateAccessProvider(): array
10431045
];
10441046
}
10451047

1048+
/**
1049+
* @group legacy
1050+
*/
10461051
public function testGenericInterface()
10471052
{
10481053
$this->assertEquals(

‎src/Symfony/Component/PropertyInfo/Type.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/PropertyInfo/Type.php
+4
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,15 @@
1111

1212
namespace Symfony\Component\PropertyInfo;
1313

14+
trigger_deprecation('symfony/property-info', '7.3', 'The "%s" class is deprecated. Use "%s" from the "symfony/type-info" component instead.', Type::class, \Symfony\Component\TypeInfo\Type::class);
15+
1416
/**
1517
* Type value object (immutable).
1618
*
1719
* @author Kévin Dunglas <dunglas@gmail.com>
1820
*
21+
* @deprecated since Symfony 7.3, use "Symfony\Component\TypeInfo\Type" from the "symfony/type-info" component instead
22+
*
1923
* @final
2024
*/
2125
class Type

‎src/Symfony/Component/PropertyInfo/Util/PhpDocTypeHelper.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/PropertyInfo/Util/PhpDocTypeHelper.php
+4
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,14 @@ final class PhpDocTypeHelper
4141
/**
4242
* Creates a {@see LegacyType} from a PHPDoc type.
4343
*
44+
* @deprecated since Symfony 7.3, use "getType" instead
45+
*
4446
* @return LegacyType[]
4547
*/
4648
public function getTypes(DocType $varType): array
4749
{
50+
trigger_deprecation('symfony/property-info', '7.3', 'The "%s()" method is deprecated, use "%s::getType()" instead.', __METHOD__, self::class);
51+
4852
if ($varType instanceof ConstExpression) {
4953
// It's safer to fall back to other extractors here, as resolving const types correctly is not easy at the moment
5054
return [];

‎src/Symfony/Component/PropertyInfo/composer.json

Copy file name to clipboardExpand all lines: src/Symfony/Component/PropertyInfo/composer.json
+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
],
2525
"require": {
2626
"php": ">=8.2",
27+
"symfony/deprecation-contracts": "^2.5|^3",
2728
"symfony/string": "^6.4|^7.0",
2829
"symfony/type-info": "~7.1.9|^7.2.2"
2930
},

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.