1 | <?php |
||
15 | class Reorganizer |
||
16 | { |
||
17 | const CAST = 'executeCast'; |
||
18 | const READ = 'executeRead'; |
||
19 | const WRITE = 'executeWrite'; |
||
20 | const DELETE = 'scheduleUnset'; |
||
21 | const CUSTOM_TRANSFORM = 'executeCustom'; |
||
22 | |||
23 | private $scheduledUnsets = []; |
||
24 | |||
25 | /** |
||
26 | * Execute $tasks on $array and return result |
||
27 | * @param array $array |
||
28 | * @param array[] $tasks |
||
29 | * @return array (patched) |
||
30 | */ |
||
31 | 18 | public function patchArray(&$array, $tasks) |
|
45 | |||
46 | /** |
||
47 | * @param array $array |
||
48 | */ |
||
49 | 18 | private function executeUnsets(&$array) |
|
55 | |||
56 | /** |
||
57 | * @uses executeCast |
||
58 | * @uses executeRead |
||
59 | * @uses executeWrite |
||
60 | * @uses scheduleUnset |
||
61 | * @uses executeCustom |
||
62 | * |
||
63 | * @param array $array |
||
64 | * @param string $taskName |
||
65 | * @param mixed $taskParams |
||
66 | * @param mixed $temporaryValue |
||
67 | */ |
||
68 | 18 | private function runTask(&$array, $taskName, $taskParams, &$temporaryValue) |
|
72 | |||
73 | /** |
||
74 | * @param array $array |
||
75 | * @param mixed $temporaryValue |
||
76 | * @param string $path |
||
77 | */ |
||
78 | 15 | private function executeRead(&$array, &$temporaryValue, $path) |
|
82 | |||
83 | /** |
||
84 | * @param array $array |
||
85 | * @param mixed $temporaryValue |
||
86 | * @param string $path |
||
87 | */ |
||
88 | 15 | private function executeWrite(&$array, $temporaryValue, $path) |
|
92 | |||
93 | /** |
||
94 | * @param array $array |
||
95 | * @param mixed $temporaryValue |
||
96 | * @param string $path |
||
97 | */ |
||
98 | 6 | private function scheduleUnset(&$array, &$temporaryValue, $path) |
|
102 | |||
103 | /** |
||
104 | * @param array $array |
||
105 | * @param mixed $temporaryValue |
||
106 | * @param string $type |
||
107 | */ |
||
108 | 3 | private function executeCast(&$array, &$temporaryValue, $type) |
|
112 | |||
113 | /** |
||
114 | * @param array $array |
||
115 | * @param mixed $temporaryValue |
||
116 | * @param array $customFunction |
||
117 | */ |
||
118 | 3 | private function executeCustom(&$array, &$temporaryValue, $customFunction) |
|
123 | } |
||
124 |
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.
Consider making the comparison explicit by using
empty(..)
or! empty(...)
instead.