@@ -117,7 +117,7 @@ The :class:`Symfony\\Component\\PropertyInfo\\PropertyInfoExtractor`
117
117
class exposes public methods to extract several types of information:
118
118
119
119
* :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 `
121
121
(including typed properties)
122
122
* :ref: `Property description <property-info-description >`: :method: `Symfony\\ Component\\ PropertyInfo\\ PropertyDescriptionExtractorInterface::getShortDescription ` and :method: `Symfony\\ Component\\ PropertyInfo\\ PropertyDescriptionExtractorInterface::getLongDescription `
123
123
* :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
164
164
provide :ref: `extensive data type information <components-property-info-type >`
165
165
for a property::
166
166
167
- $types = $propertyInfo->getTypes ($class, $property);
167
+ $types = $propertyInfo->getType ($class, $property);
168
168
/*
169
169
Example Result
170
170
--------------
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
181
178
}
182
179
*/
183
180
184
181
See :ref: `components-property-info-type ` for info about the ``Type `` class.
185
182
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
+
186
189
Documentation Block
187
190
~~~~~~~~~~~~~~~~~~~
188
191
@@ -281,18 +284,17 @@ Type Objects
281
284
282
285
Compared to the other extractors, type information extractors provide much
283
286
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 `
285
288
objects for each type that the property supports.
286
289
287
290
For example, if a property supports both ``integer `` and ``string `` (via
288
291
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.
292
294
293
295
.. note ::
294
296
295
- Most extractors will return only one :class: `Symfony\\ Component\\ PropertyInfo \\ Type `
297
+ Most extractors will return only one :class: `Symfony\\ Component\\ TypeInfo \\ Type `
296
298
instance. The :class: `Symfony\\ Component\\ PropertyInfo\\ Extractor\\ PhpDocExtractor `
297
299
is currently the only extractor that returns multiple instances in the array.
298
300
@@ -303,32 +305,32 @@ Each object will provide 6 attributes, available in the 6 methods:
303
305
``Type::getBuiltInType() ``
304
306
~~~~~~~~~~~~~~~~~~~~~~~~~~
305
307
306
- The :method: `Type::getBuiltinType() <Symfony\\ Component\\ PropertyInfo \\ Type::getBuiltinType> `
308
+ The :method: `Type::getBuiltinType() <Symfony\\ Component\\ TypeInfo \\ Type::getBuiltinType> `
307
309
method returns the built-in PHP data type, which can be one of these
308
310
string values: ``array ``, ``bool ``, ``callable ``, ``float ``, ``int ``,
309
311
``iterable ``, ``null ``, ``object ``, ``resource `` or ``string ``.
310
312
311
- Constants inside the :class: `Symfony\\ Component\\ PropertyInfo \\ Type `
313
+ Constants inside the :class: `Symfony\\ Component\\ TypeInfo \\ Type `
312
314
class, in the form ``Type::BUILTIN_TYPE_* ``, are provided for convenience.
313
315
314
316
``Type::isNullable() ``
315
317
~~~~~~~~~~~~~~~~~~~~~~
316
318
317
- The :method: `Type::isNullable() <Symfony\\ Component\\ PropertyInfo \\ Type::isNullable> `
319
+ The :method: `Type::isNullable() <Symfony\\ Component\\ TypeInfo \\ Type::isNullable> `
318
320
method will return a boolean value indicating whether the property parameter
319
321
can be set to ``null ``.
320
322
321
323
``Type::getClassName() ``
322
324
~~~~~~~~~~~~~~~~~~~~~~~~
323
325
324
326
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> `
326
328
method will return the fully-qualified class or interface name accepted.
327
329
328
330
``Type::isCollection() ``
329
331
~~~~~~~~~~~~~~~~~~~~~~~~
330
332
331
- The :method: `Type::isCollection() <Symfony\\ Component\\ PropertyInfo \\ Type::isCollection> `
333
+ The :method: `Type::isCollection() <Symfony\\ Component\\ TypeInfo \\ Type::isCollection> `
332
334
method will return a boolean value indicating if the property parameter is
333
335
a collection - a non-scalar value capable of containing other values. Currently
334
336
this returns ``true `` if:
@@ -346,8 +348,8 @@ this returns ``true`` if:
346
348
347
349
If the property is a collection, additional type objects may be returned
348
350
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> `
351
353
methods.
352
354
353
355
.. note ::
@@ -390,7 +392,7 @@ return and scalar types::
390
392
$reflectionExtractor->getProperties($class);
391
393
392
394
// Type information.
393
- $reflectionExtractor->getTypes ($class, $property);
395
+ $reflectionExtractor->getType ($class, $property);
394
396
395
397
// Access information.
396
398
$reflectionExtractor->isReadable($class, $property);
@@ -429,7 +431,7 @@ library is present::
429
431
$phpDocExtractor = new PhpDocExtractor();
430
432
431
433
// Type information.
432
- $phpDocExtractor->getTypes ($class, $property);
434
+ $phpDocExtractor->getType ($class, $property);
433
435
// Description information.
434
436
$phpDocExtractor->getShortDescription($class, $property);
435
437
$phpDocExtractor->getLongDescription($class, $property);
@@ -471,7 +473,7 @@ information from annotations of properties and methods, such as ``@var``,
471
473
$phpStanExtractor = new PhpStanExtractor();
472
474
473
475
// Type information.
474
- $phpStanExtractor->getTypesFromConstructor (Foo::class, 'bar');
476
+ $phpStanExtractor->getTypeFromConstructor (Foo::class, 'bar');
475
477
// Description information.
476
478
$phpStanExtractor->getShortDescription($class, 'bar');
477
479
$phpStanExtractor->getLongDescription($class, 'bar');
@@ -482,6 +484,12 @@ information from annotations of properties and methods, such as ``@var``,
482
484
and :method: `Symfony\\ Component\\ PropertyInfo\\ Extractor\\ PhpStanExtractor::getLongDescription `
483
485
methods were introduced in Symfony 7.3.
484
486
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
+
485
493
SerializerExtractor
486
494
~~~~~~~~~~~~~~~~~~~
487
495
@@ -536,7 +544,7 @@ with the ``property_info`` service in the Symfony Framework::
536
544
// List information.
537
545
$doctrineExtractor->getProperties($class);
538
546
// Type information.
539
- $doctrineExtractor->getTypes ($class, $property);
547
+ $doctrineExtractor->getType ($class, $property);
540
548
541
549
.. _components-property-information-constructor-extractor :
542
550
@@ -563,7 +571,7 @@ on the constructor arguments::
563
571
use Symfony\Component\PropertyInfo\Extractor\ConstructorExtractor;
564
572
565
573
$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'
567
575
568
576
.. _`components-property-information-extractors-creation` :
569
577
0 commit comments