These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace Basis; |
||
4 | |||
5 | use Exception; |
||
6 | |||
7 | abstract class Job |
||
8 | { |
||
9 | use Toolkit; |
||
10 | |||
11 | 1 | protected function require($name) |
|
12 | { |
||
13 | 1 | if (!$this->$name) { |
|
14 | throw new Exception("$name is not defined"); |
||
15 | } |
||
16 | 1 | } |
|
17 | |||
18 | 1 | protected function confirm($message) |
|
19 | { |
||
20 | 1 | $hash = md5($message); |
|
21 | 1 | if (!property_exists($this, '_confirmations') || !is_array($this->_confirmations) || !in_array($hash, $this->_confirmations)) { |
|
0 ignored issues
–
show
|
|||
22 | 1 | throw new Exception(json_encode([ |
|
23 | 1 | 'type' => 'confirm', |
|
24 | 1 | 'message' => $message, |
|
25 | 1 | 'hash' => $hash |
|
26 | ])); |
||
27 | } |
||
28 | 1 | } |
|
29 | } |
||
30 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: