1 | <?php |
||
11 | abstract class Predefined_Options_Field extends Field { |
||
12 | |||
13 | /** |
||
14 | * Stores the raw, unprocessed field options |
||
15 | * |
||
16 | * @var array(array|callable) |
||
17 | */ |
||
18 | protected $option_collections = array(); |
||
19 | |||
20 | /** |
||
21 | * Check if an array is indexed |
||
22 | * |
||
23 | * @param array $array |
||
24 | * @return boolean |
||
25 | */ |
||
26 | protected function is_indexed_array( $array ) { |
||
29 | |||
30 | /** |
||
31 | * Set the options of this field. |
||
32 | * Accepts either array of data or a callback that returns the data. |
||
33 | * |
||
34 | * @param array|callable $options |
||
35 | * @return Field $this |
||
36 | */ |
||
37 | 9 | public function set_options( $options ) { |
|
46 | |||
47 | /** |
||
48 | * Add new options to this field. |
||
49 | * Accepts either array of data or a callback that returns the data. |
||
50 | * |
||
51 | * @param array|callable $options |
||
52 | * @return Field $this |
||
53 | */ |
||
54 | 13 | public function add_options( $options ) { |
|
63 | |||
64 | /** |
||
65 | * Get a populated array of options executing any callbacks in the process |
||
66 | * |
||
67 | * @return array |
||
68 | */ |
||
69 | protected function load_options() { |
||
90 | |||
91 | /** |
||
92 | * Retrieve the current options. |
||
93 | * |
||
94 | * @return array|callable $options |
||
95 | */ |
||
96 | 13 | public function get_options() { |
|
99 | |||
100 | /** |
||
101 | * Changes the options array structure. This is needed to keep the array items order when it is JSON encoded. |
||
102 | * Will also work with a callable that returns an array. |
||
103 | * |
||
104 | * @param array|callable $options |
||
105 | * @return array |
||
106 | */ |
||
107 | protected function parse_options( $options ) { |
||
123 | } |
||
124 |
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVar
assignment in line 1 and the$higher
assignment in line 2 are dead. The first because$myVar
is never used and the second because$higher
is always overwritten for every possible time line.