@@ -7,6 +7,10 @@ The TypeInfo Component
7
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
9
10
+ .. caution ::
11
+
12
+ This component is :doc: `experimental </contributing/code/experimental >` and could be changed at any time
13
+ without prior notice.
10
14
11
15
Installation
12
16
------------
@@ -20,7 +24,10 @@ Installation
20
24
Usage
21
25
-----
22
26
23
- There is two ways to use this component. First one is to create a manually thanks
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.
29
+
30
+ There are two ways to use this component. First one is to create a type manually thanks
24
31
to :class: `Symfony\\ Component\\ TypeInfo\\ Type ` static methods as following::
25
32
26
33
use Symfony\Component\TypeInfo\Type;
@@ -34,6 +41,7 @@ to :class:`Symfony\\Component\\TypeInfo\\Type` static methods as following::
34
41
// Many others are available and can be
35
42
// found in Symfony\Component\TypeInfo\TypeFactoryTrait
36
43
44
+
37
45
Second way to use TypeInfo is to resolve a type based on reflection or a simple string::
38
46
39
47
use Symfony\Component\TypeInfo\Type;
@@ -54,6 +62,10 @@ Second way to use TypeInfo is to resolve a type based on reflection or a simple
54
62
$type->getCollectionKeyType(); // returns an "int" Type instance
55
63
$type->getCollectionValueType()->isNullable(); // returns true
56
64
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.
68
+
57
69
.. note ::
58
70
59
71
To support raw string resolving, you need to install ``phpstan/phpdoc-parser `` package.
0 commit comments