8000 feature #54789 [PropertyInfo] remove deprecations, mark TypeInfo as e… · symfony/symfony@9a86584 · GitHub
[go: up one dir, main page]

Skip to content

Commit 9a86584

Browse files
committed
feature #54789 [PropertyInfo] remove deprecations, mark TypeInfo as experimental (soyuka)
This PR was merged into the 7.1 branch. Discussion ---------- [PropertyInfo] remove deprecations, mark TypeInfo as experimental | Q | A | ------------- | --- | Branch? | 7.1 | Bug fix? | no | New feature? | no | Deprecations? | no | License | MIT Follows #54788 as we can introduce these deprecation back when we feel the component is stable enough. Software like API Platform that heavily relies on the deprecated functionalities will have a really hard time migrating, we don't want to work more then needed and need to know we won't have to do the same work again in the next years. This also suggest that PropertyInfo can work with or without the new TypeInfo component while it's being experimental. Commits ------- 08ac161 [PropertyInfo] remove deprecations, mark TypeInfo as experimental
2 parents 09e3c5c + 08ac161 commit 9a86584

11 files changed

+30
-91
lines changed

UPGRADE-7.1.md

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -81,45 +81,6 @@ Mailer
8181

8282
* Postmark's "406 - Inactive recipient" API error code now results in a `PostmarkDeliveryEvent` instead of throwing a `HttpTransportException`
8383

84-
PropertyInfo
85-
------------
86-
87-
* Deprecate the `Type` class, use `Symfony\Component\TypeInfo\Type` class of `symfony/type-info` component instead
88-
89-
*Before*
90-
```php
91-
use Symfony\Component\PropertyInfo\Type;
92-
93-
// bool
94-
$boolType = new Type(LegacyType::BUILTIN_TYPE_BOOL);
95-
// bool|null
96-
$nullableType = new Type(LegacyType::BUILTIN_TYPE_BOOL, nullable: true);
97-
// array<int, string|null>
98-
$arrayType = new Type(Type::BUILTIN_TYPE_ARRAY, false, null, true, new Type(Type::BUILTIN_TYPE_INT), new Type(Type::BUILTIN_TYPE_STRING, true));
99-
100-
$arrayType->getBuiltinType(); // returns "array"
101-
$arrayType->getCollectionKeyTypes(); // returns an array with an "int" Type instance
102-
$arrayType->getCollectionValueTypes()[0]->isNullable(); // returns true
103-
```
104-
105-
*After*
106-
```php
107-
use Symfony\Component\TypeInfo\Type;
108-
109-
// bool
110-
$boolType = Type::bool();
111-
// bool|null
112-
$nullableType = Type::nullable(Type::bool());
113-
// array<int, string|null>
114-
$arrayType = Type::array(Type::nullable(Type::string()), Type::int());
115-
116-
(string) $arrayType->getBaseType(); // returns "array"
117-
$arrayType->getCollectionKeyType(); // returns an "int" Type instance
118-
$arrayType->getCollectionValueType()->isNullable(); // returns true
119-
```
120-
121-
* Deprecate `PropertyTypeExtractorInterface::getTypes()`, use `PropertyTypeExtractorInterface::getType()` instead
122-
12384
HttpKernel
12485
----------
12586

src/Symfony/Component/PropertyInfo/CHANGELOG.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ CHANGELOG
66

77
* Introduce `PropertyDocBlockExtractorInterface` to extract a property's doc block
88
* Restrict access to `PhpStanExtractor` based on visibility
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
9+
* Add `PropertyTypeExtractorInterface::getType()` as experimental
1110

1211
6.4
1312
---

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

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ public function __construct(
2929
) {
3030
}
3131

32+
/**
33+
* @experimental
34+
*/
3235
public function getType(string $class, string $property, array $context = []): ?Type
3336
{
3437
foreach ($this->extractors as $extractor) {
@@ -40,13 +43,8 @@ public function getType(string $class, string $property, array $context = []): ?
4043
return null;
4144
}
4245

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

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

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -118,13 +118,8 @@ public function getLongDescription(string $class, string $property, array $conte
118118
return '' === $contents ? null : $contents;
119119
}
120120

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

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

188178
if (!$docBlock) {
@@ -204,6 +194,9 @@ public function getTypesFromConstructor(string $class, string $property): ?array
204194
return array_merge([], ...$types);
205195
}
206196

197+
/**
198+
* @experimental
199+
*/
207200
public function getType(string $class, string $property, array $context = []): ?Type
208201
{
209202
/** @var $docBlock DocBlock */
@@ -263,6 +256,9 @@ public function getType(string $class, string $property, array $context = []): ?
263256
return Type::list($type);
264257
}
265258

259+
/**
260+
* @experimental
261+
*/
266262
public function getTypeFromConstructor(string $class, string $property): ?Type
267263
{
268264
if (!$docBlock = $this->getDocBlockFromConstructor($class, $property)) {

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

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,8 @@ public function __construct(?array $mutatorPrefixes = null, ?array $accessorPref
8282
$this->typeContextFactory = new TypeContextFactory($this->stringTypeResolver);
8383
}
8484

85-
/**
86-
* @deprecated since Symfony 7.1, use "getType" instead
87-
*/
8885
public function getTypes(string $class, string $property, array $context = []): ?array
8986
{
90-
trigger_deprecation('symfony/property-info', '7.1', 'The "%s()" method is deprecated, use "%s::getType()" instead.', __METHOD__, self::class);
91-
9287
/** @var PhpDocNode|null $docNode */
9388
[$docNode, $source, $prefix, $declaringClass] = $this->getDocBlock($class, $property);
9489
$nameScope = $this->nameScopeFactory->create($class, $declaringClass);
@@ -159,14 +154,10 @@ public function getTypes(string $class, string $property, array $context = []):
159154
}
160155

161156
/**
162-
* @deprecated since Symfony 7.1, use "getTypeFromConstructor" instead
163-
*
164157
* @return LegacyType[]|null
165158
*/
166159
public function getTypesFromConstructor(string $class, string $property): ?array
167160
{
168-
trigger_deprecation('symfony/property-info', '7.1', 'The "%s()" method is deprecated, use "%s::getTypeFromConstructor()" instead.', __METHOD__, self::class);
169-
170161
if (null === $tagDocNode = $this->getDocBlockFromConstructor($class, $property)) {
171162
return null;
172163
}
@@ -183,6 +174,9 @@ public function getTypesFromConstructor(string $class, string $property): ?array
183174
return $types;
184175
}
185176

177+
/**
178+
* @experimental
179+
*/
186180
public function getType(string $class, string $property, array $context = []): ?Type
187181
{
188182
/** @var PhpDocNode|null $docNode */
@@ -229,6 +223,9 @@ public function getType(string $class, string $property, array $context = []): ?
229223
return Type::list($type);
230224
}
231225

226+
/**
227+
* @experimental
228+
*/
232229
public function getTypeFromConstructor(string $class, string $property): ?Type
233230
{
234231
if (!$tagDocNode = $this->getDocBlockFromConstructor($class, $property)) {

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

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -140,13 +140,8 @@ public function getProperties(string $class, array $context = []): ?array
140140
return $properties ? array_values($properties) : null;
141141
}
142142

143-
/**
144-
* @deprecated since Symfony 7.1, use "getType" instead
145-
*/
146143
public function getTypes(string $class, string $property, array $context = []): ?array
147144
{
148-
trigger_deprecation('symfony/property-info', '7.1', 'The "%s()" method is deprecated, use "%s::getType()" instead.', __METHOD__, self::class);
149-
150145
if ($fromMutator = $this->extractFromMutator($class, $property)) {
151146
return $fromMutator;
152147
}
@@ -170,14 +165,10 @@ public function getTypes(string $class, string $property, array $context = []):
170165
}
171166

172167
/**
173-
* @deprecated since Symfony 7.1, use "getTypeFromConstructor" instead
174-
*
175168
* @return LegacyType[]|null
176169
*/
177170
public function getTypesFromConstructor(string $class, string $property): ?array
178171
{
179-
trigger_deprecation('symfony/property-info', '7.1', 'The "%s()" method is deprecated, use "%s::getTypeFromConstructor()" instead.', __METHOD__, self::class);
180-
181172
try {
182173
$reflection = new \ReflectionClass($class);
183174
} catch (\ReflectionException) {
@@ -199,6 +190,9 @@ public function getTypesFromConstructor(string $class, string $property): ?array
199190
return $types;
200191
}
201192

193+
/**
194+
* @experimental
195+
*/
202196
public function getType(string $class, string $property, array $context = []): ?Type
203197
{
204198
[$mutatorReflection, $prefix] = $this->getMutatorMethod($class, $property);
@@ -260,6 +254,9 @@ public function getType(string $class, string $property, array $context = []): ?
260254
return $type;
261255
}
262256

257+
/**
258+
* @experimental
259+
*/
263260
public function getTypeFromConstructor(string $class, string $property): ?Type
264261
{
265262
try {

src/Symfony/Component/PropertyInfo/PropertyInfoCacheExtractor.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ public function getProperties(string $class, array $context = []): ?array
5656
return $this->extract('getProperties', [$class, $context]);
5757
}
5858

59+
/**
60+
* @experimental
61+
*/
5962
public function getType(string $class, string $property, array $context = []): ?Type
6063
{
6164
return $this->extract('getType', [$class, $property, $context]);
@@ -66,8 +69,6 @@ public function getType(string $class, string $property, array $context = []): ?
6669
*/
6770
public function getTypes(string $class, string $property, array $context = []): ?array
6871
{
69-
trigger_deprecation('symfony/property-info', '7.1', 'The "%s()" method is deprecated, use "%s::getType()" instead.', __METHOD__, self::class);
70-
7172
return $this->extract('getTypes', [$class, $property, $context]);
7273
}
7374

src/Symfony/Component/PropertyInfo/PropertyInfoExtractor.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,18 +53,16 @@ public function getLongDescription(string $class, string $property, array $conte
5353
return $this->extract($this->descriptionExtractors, 'getLongDescription', [$class, $property, $context]);
5454
}
5555

56+
/**
57+
* @experimental
58+
*/
5659
public function getType(string $class, string $property, array $context = []): ?Type
5760
{
5861
return $this->extract($this->typeExtractors, 'getType', [$class, $property, $context]);
5962
}
6063

61-
/**
62-
* @deprecated since Symfony 7.1, use "getType" instead
63-
*/
6464
public function getTypes(string $class, string $property, array $context = []): ?array
6565
{
66-
trigger_deprecation('symfony/property-info', '7.1', 'The "%s()" method is deprecated, use "%s::getType()" instead.', __METHOD__, self::class);
67-
6866
return $this->extract($this->typeExtractors, 'getTypes', [$class, $property, $context]);
6967
}
7068

src/Symfony/Component/PropertyInfo/PropertyTypeExtractorInterface.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ interface PropertyTypeExtractorInterface
2626
/**
2727
* Gets types of a property.
2828
*
29-
* @deprecated since Symfony 7.1, use "getType" instead
30-
*
3129
* @return LegacyType[]|null
3230
*/
3331
public function getTypes(string $class, string $property, array $context = []): ?array;

src/Symfony/Component/PropertyInfo/Type.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,11 @@
1111

1212
namespace Symfony\Component\PropertyInfo;
1313

14-
trigger_deprecation('symfony/property-info', '7.1', 'The "%s" class is deprecated. Use "%s" from the "symfony/type-info" component instead.', Type::class, \Symfony\Component\TypeInfo\Type::class);
15-
1614
/**
1715
* Type value object (immutable).
1816
*
1917
* @author Kévin Dunglas <dunglas@gmail.com>
2018
*
21-
* @deprecated since Symfony 7.1, use "Symfony\Component\TypeInfo\Type" from the "symfony/type-info" component instead
22-
*
2319
* @final
2420
*/
2521
class Type

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,10 @@ final class PhpDocTypeHelper
4141
/**
4242
* Creates a {@see LegacyType} from a PHPDoc type.
4343
*
44-
* @deprecated since Symfony 7.1, use "getType" instead
45-
*
4644
* @return LegacyType[]
4745
*/
4846
public function getTypes(DocType $varType): array
4947
{
50-
trigger_deprecation('symfony/property-info', '7.1', 'The "%s()" method is deprecated, use "%s::getType()" instead.', __METHOD__, self::class);
51-
5248
if ($varType instanceof ConstExpression) {
5349
// It's safer to fall back to other extractors here, as resolving const types correctly is not easy at the moment
5450
return [];
@@ -110,6 +106,8 @@ public function getTypes(DocType $varType): array
110106

111107
/**
112108
* Creates a {@see Type} from a PHPDoc type.
109+
*
110+
* @experimental
113111
*/
114112
public function getType(DocType $varType): ?Type
115113
{

0 commit comments

Comments
 (0)
0