1 | <?php |
||
14 | class CropFace extends CropEntropy |
||
15 | { |
||
16 | const CLASSIFIER_FACE = '/classifier/haarcascade_frontalface_default.xml'; |
||
17 | const CLASSIFIER_PROFILE = '/classifier/haarcascade_profileface.xml'; |
||
18 | |||
19 | /** |
||
20 | * imagePath original image path |
||
21 | * |
||
22 | * @var mixed |
||
23 | * @access protected |
||
24 | */ |
||
25 | protected $imagePath; |
||
26 | |||
27 | /** |
||
28 | * safeZoneList |
||
29 | * |
||
30 | * @var array |
||
31 | * @access protected |
||
32 | */ |
||
33 | protected $safeZoneList; |
||
34 | |||
35 | /** |
||
36 | * max execution time (in seconds) |
||
37 | * |
||
38 | * @var int |
||
39 | * @access protected |
||
40 | */ |
||
41 | protected $maxExecutionTime; |
||
42 | |||
43 | /** |
||
44 | * |
||
45 | * @param string $imagePath |
||
46 | */ |
||
47 | public function __construct($imagePath) |
||
52 | |||
53 | /** |
||
54 | * setMaxExecutionTime |
||
55 | * |
||
56 | * @param int $maxExecutionTime max execution time (in sec) |
||
57 | * @access public |
||
58 | * @return void |
||
59 | */ |
||
60 | public function setMaxExecutionTime($maxExecutionTime) |
||
64 | |||
65 | /** |
||
66 | * getFaceList get faces positions and sizes |
||
67 | * |
||
68 | * @access protected |
||
69 | * @return array |
||
70 | */ |
||
71 | protected function getFaceList() |
||
94 | |||
95 | /** |
||
96 | * getFaceListFromClassifier |
||
97 | * |
||
98 | * @param string $classifier |
||
99 | * @access protected |
||
100 | * @return array |
||
101 | */ |
||
102 | protected function getFaceListFromClassifier($classifier) |
||
111 | |||
112 | /** |
||
113 | * getSafeZoneList |
||
114 | * |
||
115 | * @access private |
||
116 | * @return array |
||
117 | */ |
||
118 | protected function getSafeZoneList() |
||
156 | } |
||
157 |
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: