Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit efaf7fe

Browse files
committed
[PropertyInfo] Deprecate Type
1 parent 3590ca3 commit efaf7fe

18 files changed

+103
-0
lines changed

UPGRADE-7.3.md

Lines changed: 12 additions & 0 deletions
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

Lines changed: 5 additions & 0 deletions
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

Lines changed: 5 additions & 0 deletions
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

Lines changed: 14 additions & 0 deletions
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

Lines changed: 3 additions & 0 deletions
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

Lines changed: 2 additions & 0 deletions
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

Lines changed: 5 additions & 0 deletions
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

Lines changed: 10 additions & 0 deletions
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

Lines changed: 9 additions & 0 deletions
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

Lines changed: 9 additions & 0 deletions
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) {

0 commit comments

Comments
 (0)