1 | <?php |
||
18 | class Type implements TypeInterface |
||
19 | { |
||
20 | use Serializable; |
||
21 | |||
22 | /** |
||
23 | * @var Type[] |
||
24 | */ |
||
25 | private static $instances = []; |
||
26 | |||
27 | /** |
||
28 | * @var array[]|string[][] |
||
29 | */ |
||
30 | private static $inheritance = []; |
||
31 | |||
32 | /** |
||
33 | * @var string |
||
34 | */ |
||
35 | protected $name; |
||
36 | |||
37 | /** |
||
38 | * BaseType constructor. |
||
39 | * @param string $name |
||
40 | */ |
||
41 | private function __construct(string $name) |
||
51 | |||
52 | /** |
||
53 | * @var |
||
54 | */ |
||
55 | private function bootInheritance(): void |
||
59 | |||
60 | /** |
||
61 | * @param string $type |
||
62 | * @return Type |
||
63 | */ |
||
64 | public static function of(string $type): Type |
||
68 | |||
69 | /** |
||
70 | * @return bool |
||
71 | */ |
||
72 | public function isDependent(): bool |
||
76 | |||
77 | /** |
||
78 | * @param TypeInterface $type |
||
79 | * @return bool |
||
80 | */ |
||
81 | public function instanceOf(TypeInterface $type): bool |
||
85 | |||
86 | /** |
||
87 | * @return string |
||
88 | */ |
||
89 | public function __toString(): string |
||
93 | |||
94 | /** |
||
95 | * @return string |
||
96 | */ |
||
97 | public function getName(): string |
||
101 | } |
||
102 |
PHP Analyzer performs a side-effects analysis of your code. A side-effect is basically anything that might be visible after the scope of the method is left.
Let’s take a look at an example:
If we look at the
getEmail()
method, we can see that it has no side-effect. Whether you call this method or not, no future calls to other methods are affected by this. As such code as the following is useless:On the hand, if we look at the
setEmail()
, this method _has_ side-effects. In the following case, we could not remove the method call: