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 f819aed

Browse filesBrowse files
committed
[PropertyInfo] Deprecate Type
1 parent 146c128 commit f819aed
Copy full SHA for f819aed

21 files changed

+218
-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
@@ -44,6 +44,11 @@ DependencyInjection
4444

4545
* Deprecate `ContainerBuilder::getAutoconfiguredAttributes()` in favor of the `getAttributeAutoconfigurators()` method.
4646

47+
DoctrineBridge
48+
--------------
49+
50+
* Deprecate the `DoctrineExtractor::getTypes()` method, use `DoctrineExtractor::getType()` instead
51+
4752
FrameworkBundle
4853
---------------
4954

@@ -76,6 +81,13 @@ OptionsResolver
7681
});
7782
```
7883

84+
PropertyInfo
85+
-------
86+
87+
* Deprecate the `Type` class, use `Symfony\Component\TypeInfo\Type` class from `symfony/type-info` instead
88+
* Deprecate the `PropertyTypeExtractorInterface::getTypes()` method, use `PropertyTypeExtractorInterface::getType()` instead
89+
* Deprecate the `ConstructorArgumentTypeExtractorInterface::getTypesFromConstructor()` method, use `ConstructorArgumentTypeExtractorInterface::getTypeFromConstructor()` instead
90+
7991
Security
8092
--------
8193

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

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Doctrine/CHANGELOG.md
+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ CHANGELOG
55
---
66

77
* Reset the manager registry using native lazy objects when applicable
8+
* Deprecate the `DoctrineExtractor::getTypes()` method, use `DoctrineExtractor::getType()` instead
89

910
7.2
1011
---

‎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
+25
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('Since symfony/property-info 7.3: The "Symfony\Bridge\Doctrine\PropertyInfo\DoctrineExtractor::getTypes()" method is deprecated, use "Symfony\Bridge\Doctrine\PropertyInfo\DoctrineExtractor::getType()" instead.');
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('Since symfony/property-info 7.3: The "Symfony\Bridge\Doctrine\PropertyInfo\DoctrineExtractor::getTypes()" method is deprecated, use "Symfony\Bridge\Doctrine\PropertyInfo\DoctrineExtractor::getType()" instead.');
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('Since symfony/property-info 7.3: The "Symfony\Bridge\Doctrine\PropertyInfo\DoctrineExtractor::getTypes()" method is deprecated, use "Symfony\Bridge\Doctrine\PropertyInfo\DoctrineExtractor::getType()" instead.');
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('Since symfony/property-info 7.3: The "Symfony\Bridge\Doctrine\PropertyInfo\DoctrineExtractor::getTypes()" method is deprecated, use "Symfony\Bridge\Doctrine\PropertyInfo\DoctrineExtractor::getType()" instead.');
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
+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 from `symfony/type-info` 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
@@ -95,8 +95,13 @@ public function __construct(?array $mutatorPrefixes = null, ?array $accessorPref
9595
$this->typeContextFactory = new TypeContextFactory($this->stringTypeResolver);
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
/** @var PhpDocNode|null $docNode */
101106
[$docNode, $source, $prefix, $declaringClass] = $this->getDocBlock($class, $property);
102107
if (null === $docNode) {
@@ -168,10 +173,14 @@ public function getTypes(string $class, string $property, array $context = []):
168173
}
169174

170175
/**
176+
* @deprecated since Symfony 7.3, use "getTypeFromConstructor" instead
177+
*
171178
* @return LegacyType[]|null
172179
*/
173180
public function getTypesFromConstructor(string $class, string $property): ?array
174181
{
182+
trigger_deprecation('symfony/property-info', '7.3', 'The "%s()" method is deprecated, use "%s::getTypeFromConstructor()" instead.', __METHOD__, self::class);
183+
175184
if (null === $tagDocNode = $this->getDocBlockFromConstructor($class, $property)) {
176185
return null;
177186
}

‎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/ConstructorExtractorTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/PropertyInfo/Tests/Extractor/ConstructorExtractorTest.php
+7
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('Since symfony/property-info 7.3: The "Symfony\Component\PropertyInfo\Extractor\ConstructorExtractor::getTypes()" method is deprecated, use "Symfony\Component\PropertyInfo\Extractor\ConstructorExtractor::getType()" instead.');
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('Since symfony/property-info 7.3: The "Symfony\Component\PropertyInfo\Extractor\ConstructorExtractor::getTypes()" method is deprecated, use "Symfony\Component\PropertyInfo\Extractor\ConstructorExtractor::getType()" instead.');
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.