From 8fbfbae74f5adb622f005d02e9eb23e393975274 Mon Sep 17 00:00:00 2001 From: MrYamous Date: Tue, 25 Mar 2025 04:41:22 +0100 Subject: [PATCH 1/3] PropertyInfo deprecate Type in favor of TypeInfo --- components/property_info.rst | 66 ++++++++++++++++++++---------------- 1 file changed, 37 insertions(+), 29 deletions(-) diff --git a/components/property_info.rst b/components/property_info.rst index 39019657ced..ffcbf0d44c4 100644 --- a/components/property_info.rst +++ b/components/property_info.rst @@ -117,7 +117,7 @@ The :class:`Symfony\\Component\\PropertyInfo\\PropertyInfoExtractor` class exposes public methods to extract several types of information: * :ref:`List of properties `: :method:`Symfony\\Component\\PropertyInfo\\PropertyListExtractorInterface::getProperties` -* :ref:`Property type `: :method:`Symfony\\Component\\PropertyInfo\\PropertyTypeExtractorInterface::getTypes` +* :ref:`Property type `: :method:`Symfony\\Component\\PropertyInfo\\PropertyTypeExtractorInterface::getType` (including typed properties) * :ref:`Property description `: :method:`Symfony\\Component\\PropertyInfo\\PropertyDescriptionExtractorInterface::getShortDescription` and :method:`Symfony\\Component\\PropertyInfo\\PropertyDescriptionExtractorInterface::getLongDescription` * :ref:`Property access details `: :method:`Symfony\\Component\\PropertyInfo\\PropertyAccessExtractorInterface::isReadable` and :method:`Symfony\\Component\\PropertyInfo\\PropertyAccessExtractorInterface::isWritable` @@ -164,25 +164,28 @@ Extractors that implement :class:`Symfony\\Component\\PropertyInfo\\PropertyType provide :ref:`extensive data type information ` for a property:: - $types = $propertyInfo->getTypes($class, $property); + $types = $propertyInfo->getType($class, $property); /* Example Result -------------- - array(1) { - [0] => - class Symfony\Component\PropertyInfo\Type (6) { - private $builtinType => string(6) "string" - private $nullable => bool(false) - private $class => NULL - private $collection => bool(false) - private $collectionKeyType => NULL - private $collectionValueType => NULL - } + class Symfony\Component\PropertyInfo\Type (6) { + private $builtinType => string(6) "string" + private $nullable => bool(false) + private $class => NULL + private $collection => bool(false) + private $collectionKeyType => NULL + private $collectionValueType => NULL } */ See :ref:`components-property-info-type` for info about the ``Type`` class. +.. deprecated:: 7.3 + + The :method:`Symfony\\Component\\PropertyInfo\\PropertyInfoExtractor::getTypes` is + deprecated since Symfony 7.3. Use the method :method:`Symfony\\Component\\PropertyInfo\\PropertyInfoExtractor::getType` + instead. + Documentation Block ~~~~~~~~~~~~~~~~~~~ @@ -281,18 +284,17 @@ Type Objects Compared to the other extractors, type information extractors provide much more information than can be represented as simple scalar values. Because -of this, type extractors return an array of :class:`Symfony\\Component\\PropertyInfo\\Type` +of this, type extractors return an array of :class:`Symfony\\Component\\TypeInfo\\Type` objects for each type that the property supports. For example, if a property supports both ``integer`` and ``string`` (via the ``@return int|string`` annotation), -:method:`PropertyInfoExtractor::getTypes() ` -will return an array containing **two** instances of the :class:`Symfony\\Component\\PropertyInfo\\Type` -class. +:method:`PropertyInfoExtractor::getType() ` +will return an instance of the :class:`Symfony\\Component\\TypeInfo\\Type` class. .. note:: - Most extractors will return only one :class:`Symfony\\Component\\PropertyInfo\\Type` + Most extractors will return only one :class:`Symfony\\Component\\TypeInfo\\Type` instance. The :class:`Symfony\\Component\\PropertyInfo\\Extractor\\PhpDocExtractor` is currently the only extractor that returns multiple instances in the array. @@ -303,18 +305,18 @@ Each object will provide 6 attributes, available in the 6 methods: ``Type::getBuiltInType()`` ~~~~~~~~~~~~~~~~~~~~~~~~~~ -The :method:`Type::getBuiltinType() ` +The :method:`Type::getBuiltinType() ` method returns the built-in PHP data type, which can be one of these string values: ``array``, ``bool``, ``callable``, ``float``, ``int``, ``iterable``, ``null``, ``object``, ``resource`` or ``string``. -Constants inside the :class:`Symfony\\Component\\PropertyInfo\\Type` +Constants inside the :class:`Symfony\\Component\\TypeInfo\\Type` class, in the form ``Type::BUILTIN_TYPE_*``, are provided for convenience. ``Type::isNullable()`` ~~~~~~~~~~~~~~~~~~~~~~ -The :method:`Type::isNullable() ` +The :method:`Type::isNullable() ` method will return a boolean value indicating whether the property parameter can be set to ``null``. @@ -322,13 +324,13 @@ can be set to ``null``. ~~~~~~~~~~~~~~~~~~~~~~~~ If the :ref:`built-in PHP data type ` -is ``object``, the :method:`Type::getClassName() ` +is ``object``, the :method:`Type::getClassName() ` method will return the fully-qualified class or interface name accepted. ``Type::isCollection()`` ~~~~~~~~~~~~~~~~~~~~~~~~ -The :method:`Type::isCollection() ` +The :method:`Type::isCollection() ` method will return a boolean value indicating if the property parameter is a collection - a non-scalar value capable of containing other values. Currently this returns ``true`` if: @@ -346,8 +348,8 @@ this returns ``true`` if: If the property is a collection, additional type objects may be returned for both the key and value types of the collection (if the information is -available), via the :method:`Type::getCollectionKeyTypes() ` -and :method:`Type::getCollectionValueTypes() ` +available), via the :method:`Type::getCollectionKeyTypes() ` +and :method:`Type::getCollectionValueTypes() ` methods. .. note:: @@ -390,7 +392,7 @@ return and scalar types:: $reflectionExtractor->getProperties($class); // Type information. - $reflectionExtractor->getTypes($class, $property); + $reflectionExtractor->getType($class, $property); // Access information. $reflectionExtractor->isReadable($class, $property); @@ -429,7 +431,7 @@ library is present:: $phpDocExtractor = new PhpDocExtractor(); // Type information. - $phpDocExtractor->getTypes($class, $property); + $phpDocExtractor->getType($class, $property); // Description information. $phpDocExtractor->getShortDescription($class, $property); $phpDocExtractor->getLongDescription($class, $property); @@ -471,7 +473,7 @@ information from annotations of properties and methods, such as ``@var``, $phpStanExtractor = new PhpStanExtractor(); // Type information. - $phpStanExtractor->getTypesFromConstructor(Foo::class, 'bar'); + $phpStanExtractor->getTypeFromConstructor(Foo::class, 'bar'); // Description information. $phpStanExtractor->getShortDescription($class, 'bar'); $phpStanExtractor->getLongDescription($class, 'bar'); @@ -482,6 +484,12 @@ information from annotations of properties and methods, such as ``@var``, and :method:`Symfony\\Component\\PropertyInfo\\Extractor\\PhpStanExtractor::getLongDescription` methods were introduced in Symfony 7.3. +.. deprecated:: 7.3 + + The :method:`Symfony\\Component\\PropertyInfo\\ConstructorArgumentTypeExtractorInterface::getTypesFromConstructor` is + deprecated since Symfony 7.3. Use the method :method:`Symfony\\Component\\PropertyInfo\\ConstructorArgumentTypeExtractorInterface::getTypeFromConstructor` + instead. + SerializerExtractor ~~~~~~~~~~~~~~~~~~~ @@ -536,7 +544,7 @@ with the ``property_info`` service in the Symfony Framework:: // List information. $doctrineExtractor->getProperties($class); // Type information. - $doctrineExtractor->getTypes($class, $property); + $doctrineExtractor->getType($class, $property); .. _components-property-information-constructor-extractor: @@ -563,7 +571,7 @@ on the constructor arguments:: use Symfony\Component\PropertyInfo\Extractor\ConstructorExtractor; $constructorExtractor = new ConstructorExtractor([new ReflectionExtractor()]); - $constructorExtractor->getTypes(Foo::class, 'bar')[0]->getBuiltinType(); // returns 'string' + $constructorExtractor->getType(Foo::class, 'bar')[0]->getBuiltinType(); // returns 'string' .. _`components-property-information-extractors-creation`: From 91f5c90c19dabceee9abc0aeb656218a26de89c0 Mon Sep 17 00:00:00 2001 From: Matthieu Lempereur Date: Tue, 25 Mar 2025 13:33:58 +0100 Subject: [PATCH 2/3] Apply suggestions from code review Co-authored-by: Oskar Stark Co-authored-by: Mathias Arlaud --- components/property_info.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/components/property_info.rst b/components/property_info.rst index ffcbf0d44c4..067e3a813d4 100644 --- a/components/property_info.rst +++ b/components/property_info.rst @@ -182,8 +182,8 @@ See :ref:`components-property-info-type` for info about the ``Type`` class. .. deprecated:: 7.3 - The :method:`Symfony\\Component\\PropertyInfo\\PropertyInfoExtractor::getTypes` is - deprecated since Symfony 7.3. Use the method :method:`Symfony\\Component\\PropertyInfo\\PropertyInfoExtractor::getType` + The :method:`Symfony\\Component\\PropertyInfo\\PropertyInfoExtractor::getTypes` method is + deprecated since Symfony 7.3. Use the :method:`Symfony\\Component\\PropertyInfo\\PropertyInfoExtractor::getType` method instead. Documentation Block @@ -571,7 +571,7 @@ on the constructor arguments:: use Symfony\Component\PropertyInfo\Extractor\ConstructorExtractor; $constructorExtractor = new ConstructorExtractor([new ReflectionExtractor()]); - $constructorExtractor->getType(Foo::class, 'bar')[0]->getBuiltinType(); // returns 'string' + (string) $constructorExtractor->getType(Foo::class, 'bar')[0]; // returns 'string' .. _`components-property-information-extractors-creation`: From 834511b02455d902f9560b8e101b9a1ba0a6939e Mon Sep 17 00:00:00 2001 From: MrYamous Date: Tue, 25 Mar 2025 13:35:13 +0100 Subject: [PATCH 3/3] update namespace --- components/property_info.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/property_info.rst b/components/property_info.rst index 067e3a813d4..f6c2d59ea20 100644 --- a/components/property_info.rst +++ b/components/property_info.rst @@ -168,7 +168,7 @@ for a property:: /* Example Result -------------- - class Symfony\Component\PropertyInfo\Type (6) { + class Symfony\Component\TypeInfo\Type (6) { private $builtinType => string(6) "string" private $nullable => bool(false) private $class => NULL 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