Skip to content

Commit 8fbfbae

Browse files
committed
PropertyInfo deprecate Type in favor of TypeInfo
1 parent 0d01dbc commit 8fbfbae

File tree

1 file changed

+37
-29
lines changed

1 file changed

+37
-29
lines changed

components/property_info.rst

Lines changed: 37 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ The :class:`Symfony\\Component\\PropertyInfo\\PropertyInfoExtractor`
117117
class exposes public methods to extract several types of information:
118118

119119
* :ref:`List of properties <property-info-list>`: :method:`Symfony\\Component\\PropertyInfo\\PropertyListExtractorInterface::getProperties`
120-
* :ref:`Property type <property-info-type>`: :method:`Symfony\\Component\\PropertyInfo\\PropertyTypeExtractorInterface::getTypes`
120+
* :ref:`Property type <property-info-type>`: :method:`Symfony\\Component\\PropertyInfo\\PropertyTypeExtractorInterface::getType`
121121
(including typed properties)
122122
* :ref:`Property description <property-info-description>`: :method:`Symfony\\Component\\PropertyInfo\\PropertyDescriptionExtractorInterface::getShortDescription` and :method:`Symfony\\Component\\PropertyInfo\\PropertyDescriptionExtractorInterface::getLongDescription`
123123
* :ref:`Property access details <property-info-access>`: :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
164164
provide :ref:`extensive data type information <components-property-info-type>`
165165
for a property::
166166

167-
$types = $propertyInfo->getTypes($class, $property);
167+
$types = $propertyInfo->getType($class, $property);
168168
/*
169169
Example Result
170170
--------------
171-
array(1) {
172-
[0] =>
173-
class Symfony\Component\PropertyInfo\Type (6) {
174-
private $builtinType => string(6) "string"
175-
private $nullable => bool(false)
176-
private $class => NULL
177-
private $collection => bool(false)
178-
private $collectionKeyType => NULL
179-
private $collectionValueType => NULL
180-
}
171+
class Symfony\Component\PropertyInfo\Type (6) {
172+
private $builtinType => string(6) "string"
173+
private $nullable => bool(false)
174+
private $class => NULL
175+
private $collection => bool(false)
176+
private $collectionKeyType => NULL
177+
private $collectionValueType => NULL
181178
}
182179
*/
183180

184181
See :ref:`components-property-info-type` for info about the ``Type`` class.
185182

183+
.. deprecated:: 7.3
184+
185+
The :method:`Symfony\\Component\\PropertyInfo\\PropertyInfoExtractor::getTypes` is
186+
deprecated since Symfony 7.3. Use the method :method:`Symfony\\Component\\PropertyInfo\\PropertyInfoExtractor::getType`
187+
instead.
188+
186189
Documentation Block
187190
~~~~~~~~~~~~~~~~~~~
188191

@@ -281,18 +284,17 @@ Type Objects
281284

282285
Compared to the other extractors, type information extractors provide much
283286
more information than can be represented as simple scalar values. Because
284-
of this, type extractors return an array of :class:`Symfony\\Component\\PropertyInfo\\Type`
287+
of this, type extractors return an array of :class:`Symfony\\Component\\TypeInfo\\Type`
285288
objects for each type that the property supports.
286289

287290
For example, if a property supports both ``integer`` and ``string`` (via
288291
the ``@return int|string`` annotation),
289-
:method:`PropertyInfoExtractor::getTypes() <Symfony\\Component\\PropertyInfo\\PropertyInfoExtractor::getTypes>`
290-
will return an array containing **two** instances of the :class:`Symfony\\Component\\PropertyInfo\\Type`
291-
class.
292+
:method:`PropertyInfoExtractor::getType() <Symfony\\Component\\PropertyInfo\\PropertyInfoExtractor::getType>`
293+
will return an instance of the :class:`Symfony\\Component\\TypeInfo\\Type` class.
292294

293295
.. note::
294296

295-
Most extractors will return only one :class:`Symfony\\Component\\PropertyInfo\\Type`
297+
Most extractors will return only one :class:`Symfony\\Component\\TypeInfo\\Type`
296298
instance. The :class:`Symfony\\Component\\PropertyInfo\\Extractor\\PhpDocExtractor`
297299
is currently the only extractor that returns multiple instances in the array.
298300

@@ -303,32 +305,32 @@ Each object will provide 6 attributes, available in the 6 methods:
303305
``Type::getBuiltInType()``
304306
~~~~~~~~~~~~~~~~~~~~~~~~~~
305307

306-
The :method:`Type::getBuiltinType() <Symfony\\Component\\PropertyInfo\\Type::getBuiltinType>`
308+
The :method:`Type::getBuiltinType() <Symfony\\Component\\TypeInfo\\Type::getBuiltinType>`
307309
method returns the built-in PHP data type, which can be one of these
308310
string values: ``array``, ``bool``, ``callable``, ``float``, ``int``,
309311
``iterable``, ``null``, ``object``, ``resource`` or ``string``.
310312

311-
Constants inside the :class:`Symfony\\Component\\PropertyInfo\\Type`
313+
Constants inside the :class:`Symfony\\Component\\TypeInfo\\Type`
312314
class, in the form ``Type::BUILTIN_TYPE_*``, are provided for convenience.
313315

314316
``Type::isNullable()``
315317
~~~~~~~~~~~~~~~~~~~~~~
316318

317-
The :method:`Type::isNullable() <Symfony\\Component\\PropertyInfo\\Type::isNullable>`
319+
The :method:`Type::isNullable() <Symfony\\Component\\TypeInfo\\Type::isNullable>`
318320
method will return a boolean value indicating whether the property parameter
319321
can be set to ``null``.
320322

321323
``Type::getClassName()``
322324
~~~~~~~~~~~~~~~~~~~~~~~~
323325

324326
If the :ref:`built-in PHP data type <components-property-info-type-builtin>`
325-
is ``object``, the :method:`Type::getClassName() <Symfony\\Component\\PropertyInfo\\Type::getClassName>`
327+
is ``object``, the :method:`Type::getClassName() <Symfony\\Component\\TypeInfo\\Type::getClassName>`
326328
method will return the fully-qualified class or interface name accepted.
327329

328330
``Type::isCollection()``
329331
~~~~~~~~~~~~~~~~~~~~~~~~
330332

331-
The :method:`Type::isCollection() <Symfony\\Component\\PropertyInfo\\Type::isCollection>`
333+
The :method:`Type::isCollection() <Symfony\\Component\\TypeInfo\\Type::isCollection>`
332334
method will return a boolean value indicating if the property parameter is
333335
a collection - a non-scalar value capable of containing other values. Currently
334336
this returns ``true`` if:
@@ -346,8 +348,8 @@ this returns ``true`` if:
346348

347349
If the property is a collection, additional type objects may be returned
348350
for both the key and value types of the collection (if the information is
349-
available), via the :method:`Type::getCollectionKeyTypes() <Symfony\\Component\\PropertyInfo\\Type::getCollectionKeyTypes>`
350-
and :method:`Type::getCollectionValueTypes() <Symfony\\Component\\PropertyInfo\\Type::getCollectionValueTypes>`
351+
available), via the :method:`Type::getCollectionKeyTypes() <Symfony\\Component\\TypeInfo\\Type::getCollectionKeyTypes>`
352+
and :method:`Type::getCollectionValueTypes() <Symfony\\Component\\TypeInfo\\Type::getCollectionValueTypes>`
351353
methods.
352354

353355
.. note::
@@ -390,7 +392,7 @@ return and scalar types::
390392
$reflectionExtractor->getProperties($class);
391393

392394
// Type information.
393-
$reflectionExtractor->getTypes($class, $property);
395+
$reflectionExtractor->getType($class, $property);
394396

395397
// Access information.
396398
$reflectionExtractor->isReadable($class, $property);
@@ -429,7 +431,7 @@ library is present::
429431
$phpDocExtractor = new PhpDocExtractor();
430432

431433
// Type information.
432-
$phpDocExtractor->getTypes($class, $property);
434+
$phpDocExtractor->getType($class, $property);
433435
// Description information.
434436
$phpDocExtractor->getShortDescription($class, $property);
435437
$phpDocExtractor->getLongDescription($class, $property);
@@ -471,7 +473,7 @@ information from annotations of properties and methods, such as ``@var``,
471473
$phpStanExtractor = new PhpStanExtractor();
472474

473475
// Type information.
474-
$phpStanExtractor->getTypesFromConstructor(Foo::class, 'bar');
476+
$phpStanExtractor->getTypeFromConstructor(Foo::class, 'bar');
475477
// Description information.
476478
$phpStanExtractor->getShortDescription($class, 'bar');
477479
$phpStanExtractor->getLongDescription($class, 'bar');
@@ -482,6 +484,12 @@ information from annotations of properties and methods, such as ``@var``,
482484
and :method:`Symfony\\Component\\PropertyInfo\\Extractor\\PhpStanExtractor::getLongDescription`
483485
methods were introduced in Symfony 7.3.
484486

487+
.. deprecated:: 7.3
488+
489+
The :method:`Symfony\\Component\\PropertyInfo\\ConstructorArgumentTypeExtractorInterface::getTypesFromConstructor` is
490+
deprecated since Symfony 7.3. Use the method :method:`Symfony\\Component\\PropertyInfo\\ConstructorArgumentTypeExtractorInterface::getTypeFromConstructor`
491+
instead.
492+
485493
SerializerExtractor
486494
~~~~~~~~~~~~~~~~~~~
487495

@@ -536,7 +544,7 @@ with the ``property_info`` service in the Symfony Framework::
536544
// List information.
537545
$doctrineExtractor->getProperties($class);
538546
// Type information.
539-
$doctrineExtractor->getTypes($class, $property);
547+
$doctrineExtractor->getType($class, $property);
540548

541549
.. _components-property-information-constructor-extractor:
542550

@@ -563,7 +571,7 @@ on the constructor arguments::
563571
use Symfony\Component\PropertyInfo\Extractor\ConstructorExtractor;
564572

565573
$constructorExtractor = new ConstructorExtractor([new ReflectionExtractor()]);
566-
$constructorExtractor->getTypes(Foo::class, 'bar')[0]->getBuiltinType(); // returns 'string'
574+
$constructorExtractor->getType(Foo::class, 'bar')[0]->getBuiltinType(); // returns 'string'
567575

568576
.. _`components-property-information-extractors-creation`:
569577

0 commit comments

Comments
 (0)