1 | <?php |
||
30 | class ShortcodesManager |
||
31 | { |
||
32 | |||
33 | /** |
||
34 | * @var LegacyShortcodesManager $LegacyShortcodesManager |
||
35 | */ |
||
36 | private $LegacyShortcodesManager; |
||
37 | |||
38 | /** |
||
39 | * @var ShortcodeInterface[] $shortcodes |
||
40 | */ |
||
41 | private $shortcodes; |
||
42 | |||
43 | |||
44 | |||
45 | /** |
||
46 | * ShortcodesManager constructor |
||
47 | * |
||
48 | * @param LegacyShortcodesManager $LegacyShortcodesManager |
||
49 | */ |
||
50 | public function __construct(LegacyShortcodesManager $LegacyShortcodesManager) { |
||
51 | $this->LegacyShortcodesManager = $LegacyShortcodesManager; |
||
52 | // assemble a list of installed and active shortcodes |
||
53 | add_action( |
||
54 | 'AHEE__EE_System__register_shortcodes_modules_and_widgets', |
||
55 | array($this, 'registerShortcodes'), |
||
56 | 999 |
||
57 | ); |
||
58 | // call add_shortcode() for all installed shortcodes |
||
59 | add_action('AHEE__EE_System__core_loaded_and_ready', array($this, 'addShortcodes')); |
||
60 | // check content for shortcodes, the old way, and the more efficient new way |
||
61 | add_action('parse_query', array($this->LegacyShortcodesManager, 'initializeShortcodes'), 5); |
||
62 | add_action('get_header', array($this, 'getHeader')); |
||
63 | } |
||
64 | |||
65 | |||
66 | |||
67 | /** |
||
68 | * @return CollectionInterface|ShortcodeInterface[] |
||
69 | * @throws InvalidIdentifierException |
||
70 | * @throws InvalidInterfaceException |
||
71 | * @throws InvalidFilePathException |
||
72 | * @throws InvalidEntityException |
||
73 | * @throws InvalidDataTypeException |
||
74 | * @throws InvalidClassException |
||
75 | */ |
||
76 | public function getShortcodes() |
||
83 | |||
84 | |||
85 | |||
86 | /** |
||
87 | * @return CollectionInterface|ShortcodeInterface[] |
||
88 | * @throws InvalidIdentifierException |
||
89 | * @throws InvalidInterfaceException |
||
90 | * @throws InvalidFilePathException |
||
91 | * @throws InvalidEntityException |
||
92 | * @throws InvalidDataTypeException |
||
93 | * @throws InvalidClassException |
||
94 | */ |
||
95 | protected function loadShortcodesCollection() |
||
116 | |||
117 | |||
118 | |||
119 | /** |
||
120 | * @return void |
||
121 | * @throws InvalidInterfaceException |
||
122 | * @throws InvalidIdentifierException |
||
123 | * @throws InvalidFilePathException |
||
124 | * @throws InvalidEntityException |
||
125 | * @throws InvalidDataTypeException |
||
126 | * @throws InvalidClassException |
||
127 | */ |
||
128 | public function registerShortcodes() |
||
136 | |||
137 | |||
138 | |||
139 | /** |
||
140 | * @return void |
||
141 | */ |
||
142 | public function addShortcodes() |
||
158 | |||
159 | |||
160 | |||
161 | /** |
||
162 | * callback for the WP "get_header" hook point |
||
163 | * checks posts for EE shortcodes, and initializes them, |
||
164 | * then toggles filter switch that loads core default assets |
||
165 | * |
||
166 | * @return void |
||
167 | */ |
||
168 | public function getHeader() |
||
188 | |||
189 | |||
190 | |||
191 | /** |
||
192 | * checks supplied content against list of shortcodes, |
||
193 | * then initializes any found shortcodes, and returns true. |
||
194 | * returns false if no shortcodes found. |
||
195 | * |
||
196 | * @param string $content |
||
197 | * @return bool |
||
198 | */ |
||
199 | public function parseContentForShortcodes($content) |
||
211 | |||
212 | } |
||
213 | // End of file ShortcodesManager.php |
||
214 | // Location: EventEspresso\core\services\shortcodes/ShortcodesManager.php |
Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.
For example, imagine you have a variable
$accountId
that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to theid
property of an instance of theAccount
class. This class holds a proper account, so the id value must no longer be false.Either this assignment is in error or a type check should be added for that assignment.