Skip to content

Navigation Menu

Sign in
Appearance settings

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 a9d3291

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

21 files changed

+222
-0
lines changed

‎UPGRADE-7.3.md

Copy file name to clipboardExpand all lines: UPGRADE-7.3.md
+12Lines 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

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Doctrine/CHANGELOG.md
+5Lines 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

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Doctrine/PropertyInfo/DoctrineExtractor.php
+5Lines 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

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/DoctrineExtractorTest.php
+25Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
use Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures\DoctrineWithEmbedded;
3131
use Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures\EnumInt;
3232
use Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures\EnumString;
33+
use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait;
3334
use Symfony\Component\PropertyInfo\Type as LegacyType;
3435
use Symfony\Component\TypeInfo\Type;
3536

@@ -38,6 +39,8 @@
3839
*/
3940
class DoctrineExtractorTest extends TestCase
4041
{
42+
use ExpectDeprecationTrait;
43+
4144
private function createExtractor(): DoctrineExtractor
4245
{
4346
$config = ORMSetup::createConfiguration(true);
@@ -108,15 +111,24 @@ public function testTestGetPropertiesWithEmbedded()
108111
}
109112

110113
/**
114+
* @group legacy
115+
*
111116
* @dataProvider legacyTypesProvider
112117
*/
113118
public function testExtractLegacy(string $property, ?array $type = null)
114119
{
120+
$this->expectDeprecation(sprintf('Since symfony/property-info 7.3: The "%s::getTypes()" method is deprecated, use "%s::getType()" instead.', DoctrineExtractor::class, DoctrineExtractor::class));
121+
115122
$this->assertEquals($type, $this->createExtractor()->getTypes(DoctrineDummy::class, $property, []));
116123
}
117124

125+
/**
126+
* @group legacy
127+
*/
118128
public function testExtractWithEmbeddedLegacy()
119129
{
130+
$this->expectDeprecation(sprintf('Since symfony/property-info 7.3: The "%s::getTypes()" method is deprecated, use "%s::getType()" instead.', DoctrineExtractor::class, DoctrineExtractor::class));
131+
120132
$expectedTypes = [new LegacyType(
121133
LegacyType::BUILTIN_TYPE_OBJECT,
122134
false,
@@ -132,15 +144,23 @@ public function testExtractWithEmbeddedLegacy()
132144
$this->assertEquals($expectedTypes, $actualTypes);
133145
}
134146

147+
/**
148+
* @group legacy
149+
*/
135150
public function testExtractEnumLegacy()
136151
{
152+
$this->expectDeprecation(sprintf('Since symfony/property-info 7.3: The "%s::getTypes()" method is deprecated, use "%s::getType()" instead.', DoctrineExtractor::class, DoctrineExtractor::class));
153+
137154
$this->assertEquals([new LegacyType(LegacyType::BUILTIN_TYPE_OBJECT, false, EnumString::class)], $this->createExtractor()->getTypes(DoctrineEnum::class, 'enumString', []));
138155
$this->assertEquals([new LegacyType(LegacyType::BUILTIN_TYPE_OBJECT, false, EnumInt::class)], $this->createExtractor()->getTypes(DoctrineEnum::class, 'enumInt', []));
139156
$this->assertNull($this->createExtractor()->getTypes(DoctrineEnum::class, 'enumStringArray', []));
140157
$this->assertEquals([new LegacyType(LegacyType::BUILTIN_TYPE_ARRAY, false, null, true, new LegacyType(LegacyType::BUILTIN_TYPE_INT), new LegacyType(LegacyType::BUILTIN_TYPE_OBJECT, false, EnumInt::class))], $this->createExtractor()->getTypes(DoctrineEnum::class, 'enumIntArray', []));
141158
$this->assertNull($this->createExtractor()->getTypes(DoctrineEnum::class, 'enumCustom', []));
142159
}
143160

161+
/**
162+
* @group legacy
163+
*/
144164
public static function legacyTypesProvider(): array
145165
{
146166
// DBAL 4 has a special fallback strategy for BINGINT (int -> string)
@@ -240,8 +260,13 @@ public function testGetPropertiesCatchException()
240260
$this->assertNull($this->createExtractor()->getProperties('Not\Exist'));
241261
}
242262

263+
/**
264+
* @group legacy
265+
*/
243266
public function testGetTypesCatchExceptionLegacy()
244267
{
268+
$this->expectDeprecation(sprintf('Since symfony/property-info 7.3: The "%s::getTypes()" method is deprecated, use "%s::getType()" instead.', DoctrineExtractor::class, DoctrineExtractor::class));
269+
245270
$this->assertNull($this->createExtractor()->getTypes('Not\Exist', 'baz'));
246271
}
247272

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/PropertyInfo/CHANGELOG.md
+3Lines 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

Copy file name to clipboardExpand all lines: src/Symfony/Component/PropertyInfo/Extractor/ConstructorArgumentTypeExtractorInterface.php
+2Lines 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

Copy file name to clipboardExpand all lines: src/Symfony/Component/PropertyInfo/Extractor/ConstructorExtractor.php
+5Lines 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

Copy file name to clipboardExpand all lines: src/Symfony/Component/PropertyInfo/Extractor/PhpDocExtractor.php
+10Lines 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

Copy file name to clipboardExpand all lines: src/Symfony/Component/PropertyInfo/Extractor/PhpStanExtractor.php
+9Lines 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

Copy file name to clipboardExpand all lines: src/Symfony/Component/PropertyInfo/Extractor/ReflectionExtractor.php
+9Lines 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) {

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/PropertyInfo/PropertyInfoCacheExtractor.php
+5Lines changed: 5 additions & 0 deletions
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
+5Lines changed: 5 additions & 0 deletions
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
+2Lines changed: 2 additions & 0 deletions
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/ConstructorExtractorTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/PropertyInfo/Tests/Extractor/ConstructorExtractorTest.php
+7Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Component\PropertyInfo\Tests\Extractor;
1313

1414
use PHPUnit\Framework\TestCase;
15+
use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait;
1516
use Symfony\Component\PropertyInfo\Extractor\ConstructorExtractor;
1617
use Symfony\Component\PropertyInfo\Tests\Fixtures\DummyExtractor;
1718
use Symfony\Component\PropertyInfo\Type as LegacyType;
@@ -22,6 +23,8 @@
2223
*/
2324
class ConstructorExtractorTest extends TestCase
2425
{
26+
use ExpectDeprecationTrait;
27+
2528
private ConstructorExtractor $extractor;
2629

2730
protected function setUp(): void
@@ -50,6 +53,8 @@ public function testGetTypeIfNoExtractors()
5053
*/
5154
public function testGetTypes()
5255
{
56+
$this->expectDeprecation(sprintf('Since symfony/property-info 7.3: The "%s::getTypes()" method is deprecated, use "%s::getType()" instead.', ConstructorExtractor::class, ConstructorExtractor::class));
57+
5358
$this->assertEquals([new LegacyType(LegacyType::BUILTIN_TYPE_STRING)], $this->extractor->getTypes('Foo', 'bar', []));
5459
}
5560

@@ -58,6 +63,8 @@ public function testGetTypes()
5863
*/
5964
public function testGetTypesIfNoExtractors()
6065
{
66+
$this->expectDeprecation(sprintf('Since symfony/property-info 7.3: The "%s::getTypes()" method is deprecated, use "%s::getType()" instead.', ConstructorExtractor::class, ConstructorExtractor::class));
67+
6168
$extractor = new ConstructorExtractor([]);
6269
$this->assertNull($extractor->getTypes('Foo', 'bar', []));
6370
}

0 commit comments

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