1 | <?php |
||
20 | final class ServiceMapping implements MappingInterface |
||
21 | { |
||
22 | |||
23 | /** |
||
24 | * The service-id of the service to load for given entitiy-field. |
||
25 | * |
||
26 | * @var string |
||
27 | */ |
||
28 | private $serviceId; |
||
29 | |||
30 | /** |
||
31 | * Set this to true if this field should not be checked for the correct service on persist. |
||
32 | * This check is a safety-net and you should know what you are doing when you are disabling it. |
||
33 | * You have been warned. |
||
34 | * |
||
35 | * @var bool |
||
36 | */ |
||
37 | private $lax = false; |
||
38 | |||
39 | /** |
||
40 | * @var string |
||
41 | */ |
||
42 | private $origin; |
||
43 | |||
44 | /** |
||
45 | * @var ContainerInterface |
||
46 | */ |
||
47 | private $container; |
||
48 | |||
49 | /** |
||
50 | * Global flag to completely disable service-object checks for the current runtime. |
||
51 | * This is needed for test-runs with software like behat, because there services from multiple |
||
52 | * different executions (from different service-containers) can get mixed up. |
||
53 | * |
||
54 | * @var bool |
||
55 | */ |
||
56 | private static $alwaysLax = false; |
||
57 | |||
58 | 1 | public static function setAlwaysLax(bool $alwaysLax): void |
|
62 | |||
63 | 23 | public function __construct( |
|
74 | |||
75 | 5 | public function __sleep(): array |
|
83 | |||
84 | 1 | public function getServiceId(): string |
|
88 | |||
89 | 2 | public function isLax(): bool |
|
93 | |||
94 | 2 | public function describeOrigin(): string |
|
98 | |||
99 | 4 | public function collectDBALColumns(): array |
|
103 | |||
104 | 8 | public function resolveValue( |
|
124 | |||
125 | 1 | public function revertValue( |
|
131 | |||
132 | 5 | public function assertValue( |
|
151 | |||
152 | 2 | public function wakeUpMapping(ContainerInterface $container): void |
|
156 | |||
157 | } |
||
158 |
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVar
assignment in line 1 and the$higher
assignment in line 2 are dead. The first because$myVar
is never used and the second because$higher
is always overwritten for every possible time line.