From 08ac161f1c12c1b91ab18a8983f791c6d09e1609 Mon Sep 17 00:00:00 2001 From: soyuka Date: Tue, 30 Apr 2024 12:23:38 +0200 Subject: [PATCH] [PropertyInfo] remove deprecations, mark TypeInfo as experimental --- UPGRADE-7.1.md | 39 ------------------- .../Component/PropertyInfo/CHANGELOG.md | 3 +- .../Extractor/ConstructorExtractor.php | 8 ++-- .../Extractor/PhpDocExtractor.php | 16 +++----- .../Extractor/PhpStanExtractor.php | 15 +++---- .../Extractor/ReflectionExtractor.php | 15 +++---- .../PropertyInfoCacheExtractor.php | 5 ++- .../PropertyInfo/PropertyInfoExtractor.php | 8 ++-- .../PropertyTypeExtractorInterface.php | 2 - src/Symfony/Component/PropertyInfo/Type.php | 4 -- .../PropertyInfo/Util/PhpDocTypeHelper.php | 6 +-- 11 files changed, 30 insertions(+), 91 deletions(-) diff --git a/UPGRADE-7.1.md b/UPGRADE-7.1.md index 1c01adfd77219..ea360ede1ed3c 100644 --- a/UPGRADE-7.1.md +++ b/UPGRADE-7.1.md @@ -81,45 +81,6 @@ Mailer * Postmark's "406 - Inactive recipient" API error code now results in a `PostmarkDeliveryEvent` instead of throwing a `HttpTransportException` -PropertyInfo ------------- - - * Deprecate the `Type` class, use `Symfony\Component\TypeInfo\Type` class of `symfony/type-info` component instead - - *Before* - ```php - use Symfony\Component\PropertyInfo\Type; - - // bool - $boolType = new Type(LegacyType::BUILTIN_TYPE_BOOL); - // bool|null - $nullableType = new Type(LegacyType::BUILTIN_TYPE_BOOL, nullable: true); - // array - $arrayType = new Type(Type::BUILTIN_TYPE_ARRAY, false, null, true, new Type(Type::BUILTIN_TYPE_INT), new Type(Type::BUILTIN_TYPE_STRING, true)); - - $arrayType->getBuiltinType(); // returns "array" - $arrayType->getCollectionKeyTypes(); // returns an array with an "int" Type instance - $arrayType->getCollectionValueTypes()[0]->isNullable(); // returns true - ``` - - *After* - ```php - use Symfony\Component\TypeInfo\Type; - - // bool - $boolType = Type::bool(); - // bool|null - $nullableType = Type::nullable(Type::bool()); - // array - $arrayType = Type::array(Type::nullable(Type::string()), Type::int()); - - (string) $arrayType->getBaseType(); // returns "array" - $arrayType->getCollectionKeyType(); // returns an "int" Type instance - $arrayType->getCollectionValueType()->isNullable(); // returns true - ``` - - * Deprecate `PropertyTypeExtractorInterface::getTypes()`, use `PropertyTypeExtractorInterface::getType()` instead - HttpKernel ---------- diff --git a/src/Symfony/Component/PropertyInfo/CHANGELOG.md b/src/Symfony/Component/PropertyInfo/CHANGELOG.md index 1e5642be469ed..490dab43b4754 100644 --- a/src/Symfony/Component/PropertyInfo/CHANGELOG.md +++ b/src/Symfony/Component/PropertyInfo/CHANGELOG.md @@ -6,8 +6,7 @@ CHANGELOG * Introduce `PropertyDocBlockExtractorInterface` to extract a property's doc block * Restrict access to `PhpStanExtractor` based on visibility - * Deprecate the `Type` class, use `Symfony\Component\TypeInfo\Type` class of `symfony/type-info` component instead - * Deprecate the `PropertyTypeExtractorInterface::getTypes()` method, use `PropertyTypeExtractorInterface::getType()` instead + * Add `PropertyTypeExtractorInterface::getType()` as experimental 6.4 --- diff --git a/src/Symfony/Component/PropertyInfo/Extractor/ConstructorExtractor.php b/src/Symfony/Component/PropertyInfo/Extractor/ConstructorExtractor.php index ee2ce36a5149c..ea1772241b0a0 100644 --- a/src/Symfony/Component/PropertyInfo/Extractor/ConstructorExtractor.php +++ b/src/Symfony/Component/PropertyInfo/Extractor/ConstructorExtractor.php @@ -29,6 +29,9 @@ public function __construct( ) { } + /** + * @experimental + */ public function getType(string $class, string $property, array $context = []): ?Type { foreach ($this->extractors as $extractor) { @@ -40,13 +43,8 @@ public function getType(string $class, string $property, array $context = []): ? return null; } - /** - * @deprecated since Symfony 7.1, use "getType" instead - */ public function getTypes(string $class, string $property, array $context = []): ?array { - trigger_deprecation('symfony/property-info', '7.1', 'The "%s()" method is deprecated, use "%s::getType()" instead.', __METHOD__, self::class); - foreach ($this->extractors as $extractor) { $value = $extractor->getTypesFromConstructor($class, $property); if (null !== $value) { diff --git a/src/Symfony/Component/PropertyInfo/Extractor/PhpDocExtractor.php b/src/Symfony/Component/PropertyInfo/Extractor/PhpDocExtractor.php index 956ed3f81f52d..34ad9f326861b 100644 --- a/src/Symfony/Component/PropertyInfo/Extractor/PhpDocExtractor.php +++ b/src/Symfony/Component/PropertyInfo/Extractor/PhpDocExtractor.php @@ -118,13 +118,8 @@ public function getLongDescription(string $class, string $property, array $conte return '' === $contents ? null : $contents; } - /** - * @deprecated since Symfony 7.1, use "getType" instead - */ public function getTypes(string $class, string $property, array $context = []): ?array { - trigger_deprecation('symfony/property-info', '7.1', 'The "%s()" method is deprecated, use "%s::getType()" instead.', __METHOD__, self::class); - /** @var $docBlock DocBlock */ [$docBlock, $source, $prefix] = $this->findDocBlock($class, $property); if (!$docBlock) { @@ -176,13 +171,8 @@ public function getTypes(string $class, string $property, array $context = []): return [new LegacyType(LegacyType::BUILTIN_TYPE_ARRAY, false, null, true, new LegacyType(LegacyType::BUILTIN_TYPE_INT), $types[0])]; } - /** - * @deprecated since Symfony 7.1, use "getTypeFromConstructor" instead - */ public function getTypesFromConstructor(string $class, string $property): ?array { - trigger_deprecation('symfony/property-info', '7.1', 'The "%s()" method is deprecated, use "%s::getTypeFromConstructor()" instead.', __METHOD__, self::class); - $docBlock = $this->getDocBlockFromConstructor($class, $property); if (!$docBlock) { @@ -204,6 +194,9 @@ public function getTypesFromConstructor(string $class, string $property): ?array return array_merge([], ...$types); } + /** + * @experimental + */ public function getType(string $class, string $property, array $context = []): ?Type { /** @var $docBlock DocBlock */ @@ -263,6 +256,9 @@ public function getType(string $class, string $property, array $context = []): ? return Type::list($type); } + /** + * @experimental + */ public function getTypeFromConstructor(string $class, string $property): ?Type { if (!$docBlock = $this->getDocBlockFromConstructor($class, $property)) { diff --git a/src/Symfony/Component/PropertyInfo/Extractor/PhpStanExtractor.php b/src/Symfony/Component/PropertyInfo/Extractor/PhpStanExtractor.php index 0441c4cff1457..016f40677fd4c 100644 --- a/src/Symfony/Component/PropertyInfo/Extractor/PhpStanExtractor.php +++ b/src/Symfony/Component/PropertyInfo/Extractor/PhpStanExtractor.php @@ -82,13 +82,8 @@ public function __construct(?array $mutatorPrefixes = null, ?array $accessorPref $this->typeContextFactory = new TypeContextFactory($this->stringTypeResolver); } - /** - * @deprecated since Symfony 7.1, use "getType" instead - */ public function getTypes(string $class, string $property, array $context = []): ?array { - trigger_deprecation('symfony/property-info', '7.1', 'The "%s()" method is deprecated, use "%s::getType()" instead.', __METHOD__, self::class); - /** @var PhpDocNode|null $docNode */ [$docNode, $source, $prefix, $declaringClass] = $this->getDocBlock($class, $property); $nameScope = $this->nameScopeFactory->create($class, $declaringClass); @@ -159,14 +154,10 @@ public function getTypes(string $class, string $property, array $context = []): } /** - * @deprecated since Symfony 7.1, use "getTypeFromConstructor" instead - * * @return LegacyType[]|null */ public function getTypesFromConstructor(string $class, string $property): ?array { - trigger_deprecation('symfony/property-info', '7.1', 'The "%s()" method is deprecated, use "%s::getTypeFromConstructor()" instead.', __METHOD__, self::class); - if (null === $tagDocNode = $this->getDocBlockFromConstructor($class, $property)) { return null; } @@ -183,6 +174,9 @@ public function getTypesFromConstructor(string $class, string $property): ?array return $types; } + /** + * @experimental + */ public function getType(string $class, string $property, array $context = []): ?Type { /** @var PhpDocNode|null $docNode */ @@ -229,6 +223,9 @@ public function getType(string $class, string $property, array $context = []): ? return Type::list($type); } + /** + * @experimental + */ public function getTypeFromConstructor(string $class, string $property): ?Type { if (!$tagDocNode = $this->getDocBlockFromConstructor($class, $property)) { diff --git a/src/Symfony/Component/PropertyInfo/Extractor/ReflectionExtractor.php b/src/Symfony/Component/PropertyInfo/Extractor/ReflectionExtractor.php index 7e7087221812e..0e3fda568ea9e 100644 --- a/src/Symfony/Component/PropertyInfo/Extractor/ReflectionExtractor.php +++ b/src/Symfony/Component/PropertyInfo/Extractor/ReflectionExtractor.php @@ -140,13 +140,8 @@ public function getProperties(string $class, array $context = []): ?array return $properties ? array_values($properties) : null; } - /** - * @deprecated since Symfony 7.1, use "getType" instead - */ public function getTypes(string $class, string $property, array $context = []): ?array { - trigger_deprecation('symfony/property-info', '7.1', 'The "%s()" method is deprecated, use "%s::getType()" instead.', __METHOD__, self::class); - if ($fromMutator = $this->extractFromMutator($class, $property)) { return $fromMutator; } @@ -170,14 +165,10 @@ public function getTypes(string $class, string $property, array $context = []): } /** - * @deprecated since Symfony 7.1, use "getTypeFromConstructor" instead - * * @return LegacyType[]|null */ public function getTypesFromConstructor(string $class, string $property): ?array { - trigger_deprecation('symfony/property-info', '7.1', 'The "%s()" method is deprecated, use "%s::getTypeFromConstructor()" instead.', __METHOD__, self::class); - try { $reflection = new \ReflectionClass($class); } catch (\ReflectionException) { @@ -199,6 +190,9 @@ public function getTypesFromConstructor(string $class, string $property): ?array return $types; } + /** + * @experimental + */ public function getType(string $class, string $property, array $context = []): ?Type { [$mutatorReflection, $prefix] = $this->getMutatorMethod($class, $property); @@ -260,6 +254,9 @@ public function getType(string $class, string $property, array $context = []): ? return $type; } + /** + * @experimental + */ public function getTypeFromConstructor(string $class, string $property): ?Type { try { diff --git a/src/Symfony/Component/PropertyInfo/PropertyInfoCacheExtractor.php b/src/Symfony/Component/PropertyInfo/PropertyInfoCacheExtractor.php index 9cf487eb7fad0..83c7fc3fa801e 100644 --- a/src/Symfony/Component/PropertyInfo/PropertyInfoCacheExtractor.php +++ b/src/Symfony/Component/PropertyInfo/PropertyInfoCacheExtractor.php @@ -56,6 +56,9 @@ public function getProperties(string $class, array $context = []): ?array return $this->extract('getProperties', [$class, $context]); } + /** + * @experimental + */ public function getType(string $class, string $property, array $context = []): ?Type { return $this->extract('getType', [$class, $property, $context]); @@ -66,8 +69,6 @@ public function getType(string $class, string $property, array $context = []): ? */ public function getTypes(string $class, string $property, array $context = []): ?array { - trigger_deprecation('symfony/property-info', '7.1', 'The "%s()" method is deprecated, use "%s::getType()" instead.', __METHOD__, self::class); - return $this->extract('getTypes', [$class, $property, $context]); } diff --git a/src/Symfony/Component/PropertyInfo/PropertyInfoExtractor.php b/src/Symfony/Component/PropertyInfo/PropertyInfoExtractor.php index cc24382d0e683..8e8952c7f4e23 100644 --- a/src/Symfony/Component/PropertyInfo/PropertyInfoExtractor.php +++ b/src/Symfony/Component/PropertyInfo/PropertyInfoExtractor.php @@ -53,18 +53,16 @@ public function getLongDescription(string $class, string $property, array $conte return $this->extract($this->descriptionExtractors, 'getLongDescription', [$class, $property, $context]); } + /** + * @experimental + */ public function getType(string $class, string $property, array $context = []): ?Type { return $this->extract($this->typeExtractors, 'getType', [$class, $property, $context]); } - /** - * @deprecated since Symfony 7.1, use "getType" instead - */ public function getTypes(string $class, string $property, array $context = []): ?array { - trigger_deprecation('symfony/property-info', '7.1', 'The "%s()" method is deprecated, use "%s::getType()" instead.', __METHOD__, self::class); - return $this->extract($this->typeExtractors, 'getTypes', [$class, $property, $context]); } diff --git a/src/Symfony/Component/PropertyInfo/PropertyTypeExtractorInterface.php b/src/Symfony/Component/PropertyInfo/PropertyTypeExtractorInterface.php index d5762370bccd1..c986aaf586e22 100644 --- a/src/Symfony/Component/PropertyInfo/PropertyTypeExtractorInterface.php +++ b/src/Symfony/Component/PropertyInfo/PropertyTypeExtractorInterface.php @@ -26,8 +26,6 @@ interface PropertyTypeExtractorInterface /** * Gets types of a property. * - * @deprecated since Symfony 7.1, use "getType" instead - * * @return LegacyType[]|null */ public function getTypes(string $class, string $property, array $context = []): ?array; diff --git a/src/Symfony/Component/PropertyInfo/Type.php b/src/Symfony/Component/PropertyInfo/Type.php index b47e2be411484..1ce71301dfd20 100644 --- a/src/Symfony/Component/PropertyInfo/Type.php +++ b/src/Symfony/Component/PropertyInfo/Type.php @@ -11,15 +11,11 @@ namespace Symfony\Component\PropertyInfo; -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); - /** * Type value object (immutable). * * @author Kévin Dunglas * - * @deprecated since Symfony 7.1, use "Symfony\Component\TypeInfo\Type" from the "symfony/type-info" component instead - * * @final */ class Type diff --git a/src/Symfony/Component/PropertyInfo/Util/PhpDocTypeHelper.php b/src/Symfony/Component/PropertyInfo/Util/PhpDocTypeHelper.php index 6d983453337af..a6cdb7494123c 100644 --- a/src/Symfony/Component/PropertyInfo/Util/PhpDocTypeHelper.php +++ b/src/Symfony/Component/PropertyInfo/Util/PhpDocTypeHelper.php @@ -41,14 +41,10 @@ final class PhpDocTypeHelper /** * Creates a {@see LegacyType} from a PHPDoc type. * - * @deprecated since Symfony 7.1, use "getType" instead - * * @return LegacyType[] */ public function getTypes(DocType $varType): array { - trigger_deprecation('symfony/property-info', '7.1', 'The "%s()" method is deprecated, use "%s::getType()" instead.', __METHOD__, self::class); - if ($varType instanceof ConstExpression) { // It's safer to fall back to other extractors here, as resolving const types correctly is not easy at the moment return []; @@ -110,6 +106,8 @@ public function getTypes(DocType $varType): array /** * Creates a {@see Type} from a PHPDoc type. + * + * @experimental */ public function getType(DocType $varType): ?Type { pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy