1 | <?php |
||
19 | abstract class BBCodeModuleAbstract implements BBCodeModuleInterface{ |
||
20 | |||
21 | protected $tag; |
||
22 | protected $attributes; |
||
23 | protected $content; |
||
24 | protected $match; |
||
25 | protected $callback_count; |
||
26 | |||
27 | /** |
||
28 | * An array of tags the module is able to process |
||
29 | * |
||
30 | * @var array |
||
31 | */ |
||
32 | protected $tags = []; |
||
33 | |||
34 | /** |
||
35 | * Holds an array of singletags |
||
36 | * |
||
37 | * @var array |
||
38 | */ |
||
39 | protected $singletags = []; |
||
40 | |||
41 | /** |
||
42 | * Holds an array of noparse tags |
||
43 | * |
||
44 | * @var array |
||
45 | */ |
||
46 | protected $noparse = []; |
||
47 | |||
48 | /** |
||
49 | * @var \chillerlan\BBCode\BBCodeOptions |
||
50 | */ |
||
51 | protected $options; |
||
52 | |||
53 | /** |
||
54 | * @var \Psr\SimpleCache\CacheInterface |
||
55 | */ |
||
56 | protected $cache; |
||
57 | |||
58 | /** |
||
59 | * @var \Psr\Log\LoggerInterface |
||
60 | */ |
||
61 | protected $logger; |
||
62 | |||
63 | public function __construct(ContainerInterface $options, CacheInterface $cache, LoggerInterface $logger){ |
||
68 | |||
69 | /** |
||
70 | * @param $name |
||
71 | * @param $arguments |
||
72 | * |
||
73 | * @return string |
||
74 | */ |
||
75 | public function __call($name, $arguments):string{ |
||
89 | |||
90 | /** |
||
91 | * this is the catch-all method for __call() |
||
92 | * |
||
93 | * @inheritdoc |
||
94 | */ |
||
95 | protected function transform():string{ |
||
98 | |||
99 | /** |
||
100 | * @inheritdoc |
||
101 | */ |
||
102 | public function getTags():array { |
||
105 | |||
106 | /** |
||
107 | * @inheritdoc |
||
108 | */ |
||
109 | public function getSingleTags():array { |
||
112 | |||
113 | /** |
||
114 | * @inheritdoc |
||
115 | */ |
||
116 | public function getNoparse():array { |
||
119 | |||
120 | /** |
||
121 | * @return string |
||
122 | */ |
||
123 | protected function randomID():string { |
||
126 | |||
127 | /** |
||
128 | * Clears all EOL placeholders from self::$content with the base modules EOL token |
||
129 | * |
||
130 | * @param string $eol [optional] custom EOL token |
||
131 | * |
||
132 | * @return $this |
||
133 | */ |
||
134 | protected function clearEOL(string $eol = null){ |
||
140 | |||
141 | /** |
||
142 | * Clears all pseudo closing single tag bbcodes like [/br] |
||
143 | * |
||
144 | * @return $this |
||
145 | */ |
||
146 | protected function clearPseudoClosingTags(){ |
||
151 | /** |
||
152 | * Retrieves an attribute's value by it's name |
||
153 | * |
||
154 | * @param string $name the desired attributes name |
||
155 | * @param mixed $default [optional] a default value in case the attribute isn't set, defaults to false |
||
156 | * |
||
157 | * @return mixed the attribute's value in case it exists, otherwise $default |
||
158 | */ |
||
159 | protected function getAttribute(string $name, $default = false){ |
||
162 | |||
163 | /** |
||
164 | * shorthand for self::getAttribute('__BBTAG__') |
||
165 | * |
||
166 | * @param mixed $default |
||
167 | * |
||
168 | * @return mixed $this->attributes['__BBTAG__'] |
||
169 | */ |
||
170 | protected function bbtag($default = false){ |
||
173 | |||
174 | /** |
||
175 | * shorthand for self::attributeIn('__BBTAG__', $array) |
||
176 | * |
||
177 | * @param array $array |
||
178 | * @param mixed $default |
||
179 | * |
||
180 | * @return mixed |
||
181 | */ |
||
182 | protected function bbtagIn(array $array, $default = false){ |
||
185 | |||
186 | /** |
||
187 | * Replaces the EOL placeholder in the given string with a custom token |
||
188 | * |
||
189 | * @param string $str haystack |
||
190 | * @param string $eol [optional] custom EOL token, default: '' |
||
191 | * @param int $count [optional] replace first $count occurences |
||
192 | * |
||
193 | * @return string |
||
194 | */ |
||
195 | protected function eol(string $str, string $eol = '', int $count = null):string{ |
||
198 | |||
199 | /** |
||
200 | * Retrieves an attribute's value by it's name and checks if it's whitelisted |
||
201 | * |
||
202 | * @param string $name the desired attributes name |
||
203 | * @param array $whitelist an array with whitelisted values |
||
204 | * @param mixed $default [optional] a default value in case the attribute isn't set, defaults to false |
||
205 | * |
||
206 | * @return mixed boolean if no $default is set, otherwise the attribute's value in case it exists and is whitelisted or $default |
||
207 | */ |
||
208 | protected function attributeIn(string $name, array $whitelist, $default = false){ |
||
215 | |||
216 | /** |
||
217 | * Checks if an attribute exists and if it exists as key in a whitelist |
||
218 | |||
219 | * @param string $name the desired attributes name |
||
220 | * @param array $whitelist an array with whitelisted key -> value pairs |
||
221 | * @param mixed $default [optional] a default value in case the attribute isn't set, defaults to false |
||
222 | * |
||
223 | * @return mixed boolean if no $default is set, otherwise the whitelist value to the given key in case it exists or $default |
||
224 | */ |
||
225 | protected function attributeKeyIn(string $name, array $whitelist, $default = false){ |
||
230 | |||
231 | /** |
||
232 | * Checks if the current tag is whitelisted |
||
233 | * |
||
234 | * @param array $whitelist an array with whitelisted tag names |
||
235 | * @param mixed $default [optional] a default value in case the tag isn't whitelisted |
||
236 | * |
||
237 | * @return mixed boolean if no $default is set, otherwise the whitelisted tag or $default |
||
238 | */ |
||
239 | protected function tagIn(array $whitelist, $default = false){ |
||
244 | |||
245 | |||
246 | } |
||
247 |
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 given class or a super-class is assigned to a property that is type hinted more strictly.
Either this assignment is in error or an instanceof check should be added for that assignment.