1
1
The TypeInfo Component
2
2
======================
3
3
4
- The TypeInfo component extracts PHP types information. It aims to:
4
+ The TypeInfo component extracts type information from PHP elements like properties,
5
+ arguments and return types.
5
6
6
- - Have a powerful Type definition that can handle union, intersections, and generics (and could be even more extended)
7
+ This component provides:
7
8
8
- - Being able to get types from anything, such as properties, method arguments, return types, and raw strings (and can also be extended).
9
+ * A powerful ``Type `` definition that can handle unions, intersections, and generics
10
+ (and can be extended to support more types in the future);
11
+ * A way to get types from PHP elements such as properties, method arguments,
12
+ return types, and raw strings.
9
13
10
14
.. caution ::
11
15
12
- This component is :doc: `experimental </contributing/code/experimental >` and could be changed at any time
13
- without prior notice.
16
+ This component is :doc: `experimental </contributing/code/experimental >` and
17
+ could be changed at any time without prior notice.
14
18
15
19
Installation
16
20
------------
@@ -24,11 +28,11 @@ Installation
24
28
Usage
25
29
-----
26
30
27
- This component will gives you a :class: `Symfony\\ Component\\ TypeInfo\\ Type ` object that represents
28
- the PHP type of whatever you builded or asked to resolve.
31
+ This component gives you a :class: `Symfony\\ Component\\ TypeInfo\\ Type ` object that
32
+ represents the PHP type of anything you built or asked to resolve.
29
33
30
34
There are two ways to use this component. First one is to create a type manually thanks
31
- to :class: `Symfony\\ Component\\ TypeInfo\\ Type ` static methods as following::
35
+ to the :class: `Symfony\\ Component\\ TypeInfo\\ Type ` static methods as following::
32
36
33
37
use Symfony\Component\TypeInfo\Type;
34
38
@@ -41,8 +45,8 @@ to :class:`Symfony\\Component\\TypeInfo\\Type` static methods as following::
41
45
// Many others are available and can be
42
46
// found in Symfony\Component\TypeInfo\TypeFactoryTrait
43
47
44
-
45
- Second way to use TypeInfo is to resolve a type based on reflection or a simple string::
48
+ The second way of using the component is to use `` TypeInfo `` to resolve a type
49
+ based on reflection or a simple string::
46
50
47
51
use Symfony\Component\TypeInfo\Type;
48
52
use Symfony\Component\TypeInfo\TypeResolver\TypeResolver;
@@ -62,9 +66,9 @@ Second way to use TypeInfo is to resolve a type based on reflection or a simple
62
66
$type->getCollectionKeyType(); // returns an "int" Type instance
63
67
$type->getCollectionValueType()->isNullable(); // returns true
64
68
65
- Each of this rows will return you a Type instance that will corresponds to whatever static method you used to build it.
66
- We also can resolve a type from a string like we can see in this example with the ` 'bool' ` parameter it is mostly
67
- designed that way so we can give TypeInfo a string from whatever was extracted from existing phpDoc within PropertyInfo.
69
+ Each of this calls will return you a `` Type `` instance that corresponds to the
70
+ static method used. You can also resolve types from a string (as shown in the
71
+ `` bool `` parameter of the previous example)
68
72
69
73
.. note ::
70
74
0 commit comments