1 | <?php |
||
18 | class ApprovedDatePropertyAnnotator implements PropertyAnnotator { |
||
19 | |||
20 | /** |
||
21 | * Predefined property ID |
||
22 | */ |
||
23 | const PROP_ID = '___APPROVEDDATE'; |
||
24 | |||
25 | /** |
||
26 | * @var AppFactory |
||
27 | */ |
||
28 | private $appFactory; |
||
29 | |||
30 | /** |
||
31 | * @var Integer|null |
||
32 | */ |
||
33 | private $approvedDate; |
||
34 | |||
35 | /** |
||
36 | * @param AppFactory $appFactory |
||
37 | */ |
||
38 | public function __construct( AppFactory $appFactory ) { |
||
41 | |||
42 | /** |
||
43 | * @since 2.0 |
||
44 | * |
||
45 | * @param Integer $approvedDate |
||
46 | */ |
||
47 | public function setApprovedDate( $approvedDate ) { |
||
50 | |||
51 | /** |
||
52 | * {@inheritDoc} |
||
53 | */ |
||
54 | public function isAnnotatorFor( DIProperty $property ) { |
||
57 | |||
58 | /** |
||
59 | * {@inheritDoc} |
||
60 | */ |
||
61 | public function addAnnotation( |
||
88 | } |
||
89 |
If you define a variable conditionally, it can happen that it is not defined for all execution paths.
Let’s take a look at an example:
In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.
Available Fixes
Check for existence of the variable explicitly:
Define a default value for the variable:
Add a value for the missing path: