55The PropertyInfo Component
66==========================
77
8- The PropertyInfo component provides the functionality to get information
9- about class properties using metadata of popular sources .
8+ The PropertyInfo component allows you to get information
9+ about class properties by using different sources of metadata .
1010
1111While the :doc: `PropertyAccess component </components/property_access >`
1212allows you to read and write values to/from objects and arrays, the PropertyInfo
13- component works solely with class definitions to provide information such
14- as data type and visibility about properties within that class.
15-
16- Similar to PropertyAccess, the PropertyInfo component combines both class
17- properties (such as ``$property ``) and properties defined via accessor and
18- mutator methods such as ``getProperty() ``, ``isProperty() ``, ``setProperty() ``,
19- ``addProperty() ``, ``removeProperty() ``, etc.
13+ component works solely with class definitions to provide information about the
14+ data type and visibility - including via getter or setter methods - of the properties
15+ within that class.
2016
2117.. versionadded :: 2.8
2218 The PropertyInfo component was introduced in Symfony 2.8.
@@ -42,22 +38,40 @@ Additional dependencies may be required for some of the
4238Usage
4339-----
4440
45- The entry point of this component is a new instance of the
46- :class: `Symfony\\ Component\\ PropertyInfo\\ PropertyInfoExtractor `
47- class, providing sets of information extractors.
41+ To use this component, create a new
42+ :class: `Symfony\\ Component\\ PropertyInfo\\ PropertyInfoExtractor ` instance and
43+ provide it with a set of information extractors.
4844
4945.. code-block :: php
5046
5147 use Symfony\Component\PropertyInfo\PropertyInfoExtractor;
48+ use Symfony\Component\PropertyInfo\Extractor\PhpDocExtractor;
49+ use Symfony\Component\PropertyInfo\Extractor\ReflectionExtractor;
50+
51+ // a full list of extractors is shown further below
52+ $phpDocExtractor = new PhpDocExtractor();
53+ $reflectionExtractor = new ReflectionExtractor();
54+
55+ // array of PropertyListExtractorInterface
56+ $listExtractors = array($reflectionExtractor);
57+
58+ // array of PropertyTypeExtractorInterface
59+ $typeExtractors = array($phpDocExtractor, $reflectionExtractor);
60+
61+ // array of PropertyDescriptionExtractorInterface
62+ $descriptionExtractors = array($phpDocExtractor);
63+
64+ // array of PropertyAccessExtractorInterface
65+ $accessExtractors = array($reflectionExtractor);
5266
5367 $propertyInfo = new PropertyInfoExtractor(
54- $arrayOfListExtractors ,
55- $arrayOfTypeExtractors ,
56- $arrayOfDescriptionExtractors ,
57- $arrayOfAccessExtractors
68+ $listExtractors ,
69+ $typeExtractors ,
70+ $descriptionExtractors ,
71+ $accessExtractors
5872 );
5973
60- The order of extractor instances within an array matters, as the first non-null
74+ The order of extractor instances within an array matters: the first non-null
6175result will be returned. That is why you must provide each category of extractors
6276as a separate array, even if an extractor provides information for more than
6377one category.
@@ -101,7 +115,14 @@ Extractable Information
101115-----------------------
102116
103117The :class: `Symfony\\ Component\\ PropertyInfo\\ PropertyInfoExtractor `
104- class exposes public methods to extract four types of information: list,
118+ class exposes public methods to extract four types of information:
119+
120+ * :ref: `*List* of properties <property-info-list >`: `getProperties() `
121+ * :ref: `Property *type* <property-info-type >`: `getTypes() `
122+ * :ref: `Property *description* <property-info-description >`: `getShortDescription() ` and `getLongDescription() `
123+ * :ref: `Property *access* details <property-info-access >`: `isReadable() ` and `isWritable() `
124+
125+ list,
105126type, description and access information. The first type of information is
106127about the class, while the remaining three are about the individual properties.
107128
@@ -117,6 +138,8 @@ about the class, while the remaining three are about the individual properties.
117138 Since the PropertyInfo component requires PHP 5.5 or greater, you can
118139 also make use of the `class constant `_.
119140
141+ .. _property-info-list :
142+
120143List Information
121144~~~~~~~~~~~~~~~~
122145
@@ -137,6 +160,8 @@ containing each property name as a string.
137160 }
138161 */
139162
163+ .. _property-info-type :
164+
140165Type Information
141166~~~~~~~~~~~~~~~~
142167
@@ -164,6 +189,8 @@ for a property.
164189 }
165190 */
166191
192+ .. _property-info-description :
193+
167194Description Information
168195~~~~~~~~~~~~~~~~~~~~~~~
169196
@@ -189,6 +216,8 @@ strings.
189216 It can span multiple lines.
190217 */
191218
219+ .. _property-info-access :
220+
192221Access Information
193222~~~~~~~~~~~~~~~~~~
194223
0 commit comments