1 | <?php |
||
31 | trait JoinTrait |
||
32 | { |
||
33 | /** |
||
34 | * {@inheritDoc} |
||
35 | */ |
||
36 | public function join($secondTable, $onClause = '', $firstTable = '') |
||
40 | |||
41 | /** |
||
42 | * {@inheritDoc} |
||
43 | */ |
||
44 | public function leftJoin($secondTable, $onClause = '', $firstTable = '') |
||
48 | |||
49 | /** |
||
50 | * {@inheritDoc} |
||
51 | */ |
||
52 | public function rightJoin($secondTable, $onClause = '', $firstTable = '') |
||
56 | |||
57 | /** |
||
58 | * {@inheritDoc} |
||
59 | */ |
||
60 | public function joinRaw(/*# string */ $joinType, /*# string */ $rawString) |
||
64 | |||
65 | /** |
||
66 | * The real join |
||
67 | * |
||
68 | * @param string $joinType |
||
69 | * @param string|string[]|SelectStatementInterface $secondTable |
||
70 | * @param string|string[]|ExpressionInterface $onClause |
||
71 | * @param string $firstTable |
||
72 | * @param bool $rawMode |
||
73 | * @return $this |
||
74 | * @access protected |
||
75 | */ |
||
76 | protected function realJoin( |
||
100 | |||
101 | /** |
||
102 | * Fix join table |
||
103 | * |
||
104 | * @param string|string[]|SelectStatementInterface $table |
||
105 | * @return array [table, alias] |
||
106 | * @access protected |
||
107 | */ |
||
108 | protected function fixJoinTable($table) |
||
118 | |||
119 | /** |
||
120 | * Fix 'ON' clause |
||
121 | * |
||
122 | * @param mixed $onClause |
||
123 | * @return array|ExpressionInterface |
||
124 | * @access protected |
||
125 | */ |
||
126 | protected function fixOnClause($onClause) |
||
136 | |||
137 | /** |
||
138 | * Build join |
||
139 | * |
||
140 | * @param string $prefix |
||
141 | * @param array $settings |
||
142 | * @return string |
||
143 | * @access protected |
||
144 | */ |
||
145 | protected function buildJoin( |
||
164 | |||
165 | /** |
||
166 | * Build TABLE part |
||
167 | * |
||
168 | * @param array $cls |
||
169 | * @param array $settings |
||
170 | * @return string |
||
171 | * @access protected |
||
172 | */ |
||
173 | protected function buildJoinTable(array $cls, array $settings)/*# : string */ |
||
179 | |||
180 | /** |
||
181 | * Build ON part |
||
182 | * |
||
183 | * @param array $cls |
||
184 | * @param array $settings |
||
185 | * @return string |
||
186 | * @access protected |
||
187 | */ |
||
188 | protected function buildJoinOn(array $cls, array $settings)/*# : string */ |
||
205 | |||
206 | /** |
||
207 | * Get first table alias |
||
208 | * |
||
209 | * @param array $cls |
||
210 | * @return string |
||
211 | * @access protected |
||
212 | */ |
||
213 | protected function getFirstTableAlias(array $cls)/*# : string */ |
||
225 | |||
226 | /** |
||
227 | * Get second table alias |
||
228 | * |
||
229 | * @param array $cls |
||
230 | * @return string |
||
231 | * @access protected |
||
232 | */ |
||
233 | protected function getSecondTableAlias(array $cls)/*# : string */ |
||
241 | |||
242 | abstract protected function isRaw($str, /*# bool */ $rawMode)/*# : bool */; |
||
257 | } |
||
258 |
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: