@@ -42,396 +42,396 @@ discard block |
||
42 | 42 | */ |
43 | 43 | class ClassLoader |
44 | 44 | { |
45 | - // PSR-4 |
|
46 | - private $prefixLengthsPsr4 = array(); |
|
47 | - private $prefixDirsPsr4 = array(); |
|
48 | - private $fallbackDirsPsr4 = array(); |
|
49 | - |
|
50 | - // PSR-0 |
|
51 | - private $prefixesPsr0 = array(); |
|
52 | - private $fallbackDirsPsr0 = array(); |
|
53 | - |
|
54 | - private $useIncludePath = false; |
|
55 | - private $classMap = array(); |
|
56 | - private $classMapAuthoritative = false; |
|
57 | - private $missingClasses = array(); |
|
58 | - private $apcuPrefix; |
|
59 | - |
|
60 | - public function getPrefixes() |
|
61 | - { |
|
62 | - if (!empty($this->prefixesPsr0)) { |
|
63 | - return call_user_func_array('array_merge', $this->prefixesPsr0); |
|
64 | - } |
|
65 | - |
|
66 | - return array(); |
|
67 | - } |
|
68 | - |
|
69 | - public function getPrefixesPsr4() |
|
70 | - { |
|
71 | - return $this->prefixDirsPsr4; |
|
72 | - } |
|
73 | - |
|
74 | - public function getFallbackDirs() |
|
75 | - { |
|
76 | - return $this->fallbackDirsPsr0; |
|
77 | - } |
|
78 | - |
|
79 | - public function getFallbackDirsPsr4() |
|
80 | - { |
|
81 | - return $this->fallbackDirsPsr4; |
|
82 | - } |
|
83 | - |
|
84 | - public function getClassMap() |
|
85 | - { |
|
86 | - return $this->classMap; |
|
87 | - } |
|
88 | - |
|
89 | - /** |
|
90 | - * @param array $classMap Class to filename map |
|
91 | - */ |
|
92 | - public function addClassMap(array $classMap) |
|
93 | - { |
|
94 | - if ($this->classMap) { |
|
95 | - $this->classMap = array_merge($this->classMap, $classMap); |
|
96 | - } else { |
|
97 | - $this->classMap = $classMap; |
|
98 | - } |
|
99 | - } |
|
100 | - |
|
101 | - /** |
|
102 | - * Registers a set of PSR-0 directories for a given prefix, either |
|
103 | - * appending or prepending to the ones previously set for this prefix. |
|
104 | - * |
|
105 | - * @param string $prefix The prefix |
|
106 | - * @param array|string $paths The PSR-0 root directories |
|
107 | - * @param bool $prepend Whether to prepend the directories |
|
108 | - */ |
|
109 | - public function add($prefix, $paths, $prepend = false) |
|
110 | - { |
|
111 | - if (!$prefix) { |
|
112 | - if ($prepend) { |
|
113 | - $this->fallbackDirsPsr0 = array_merge( |
|
114 | - (array) $paths, |
|
115 | - $this->fallbackDirsPsr0 |
|
116 | - ); |
|
117 | - } else { |
|
118 | - $this->fallbackDirsPsr0 = array_merge( |
|
119 | - $this->fallbackDirsPsr0, |
|
120 | - (array) $paths |
|
121 | - ); |
|
122 | - } |
|
123 | - |
|
124 | - return; |
|
125 | - } |
|
126 | - |
|
127 | - $first = $prefix[0]; |
|
128 | - if (!isset($this->prefixesPsr0[$first][$prefix])) { |
|
129 | - $this->prefixesPsr0[$first][$prefix] = (array) $paths; |
|
130 | - |
|
131 | - return; |
|
132 | - } |
|
133 | - if ($prepend) { |
|
134 | - $this->prefixesPsr0[$first][$prefix] = array_merge( |
|
135 | - (array) $paths, |
|
136 | - $this->prefixesPsr0[$first][$prefix] |
|
137 | - ); |
|
138 | - } else { |
|
139 | - $this->prefixesPsr0[$first][$prefix] = array_merge( |
|
140 | - $this->prefixesPsr0[$first][$prefix], |
|
141 | - (array) $paths |
|
142 | - ); |
|
143 | - } |
|
144 | - } |
|
145 | - |
|
146 | - /** |
|
147 | - * Registers a set of PSR-4 directories for a given namespace, either |
|
148 | - * appending or prepending to the ones previously set for this namespace. |
|
149 | - * |
|
150 | - * @param string $prefix The prefix/namespace, with trailing '\\' |
|
151 | - * @param array|string $paths The PSR-4 base directories |
|
152 | - * @param bool $prepend Whether to prepend the directories |
|
153 | - * |
|
154 | - * @throws \InvalidArgumentException |
|
155 | - */ |
|
156 | - public function addPsr4($prefix, $paths, $prepend = false) |
|
157 | - { |
|
158 | - if (!$prefix) { |
|
159 | - // Register directories for the root namespace. |
|
160 | - if ($prepend) { |
|
161 | - $this->fallbackDirsPsr4 = array_merge( |
|
162 | - (array) $paths, |
|
163 | - $this->fallbackDirsPsr4 |
|
164 | - ); |
|
165 | - } else { |
|
166 | - $this->fallbackDirsPsr4 = array_merge( |
|
167 | - $this->fallbackDirsPsr4, |
|
168 | - (array) $paths |
|
169 | - ); |
|
170 | - } |
|
171 | - } elseif (!isset($this->prefixDirsPsr4[$prefix])) { |
|
172 | - // Register directories for a new namespace. |
|
173 | - $length = strlen($prefix); |
|
174 | - if ('\\' !== $prefix[$length - 1]) { |
|
175 | - throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); |
|
176 | - } |
|
177 | - $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; |
|
178 | - $this->prefixDirsPsr4[$prefix] = (array) $paths; |
|
179 | - } elseif ($prepend) { |
|
180 | - // Prepend directories for an already registered namespace. |
|
181 | - $this->prefixDirsPsr4[$prefix] = array_merge( |
|
182 | - (array) $paths, |
|
183 | - $this->prefixDirsPsr4[$prefix] |
|
184 | - ); |
|
185 | - } else { |
|
186 | - // Append directories for an already registered namespace. |
|
187 | - $this->prefixDirsPsr4[$prefix] = array_merge( |
|
188 | - $this->prefixDirsPsr4[$prefix], |
|
189 | - (array) $paths |
|
190 | - ); |
|
191 | - } |
|
192 | - } |
|
193 | - |
|
194 | - /** |
|
195 | - * Registers a set of PSR-0 directories for a given prefix, |
|
196 | - * replacing any others previously set for this prefix. |
|
197 | - * |
|
198 | - * @param string $prefix The prefix |
|
199 | - * @param array|string $paths The PSR-0 base directories |
|
200 | - */ |
|
201 | - public function set($prefix, $paths) |
|
202 | - { |
|
203 | - if (!$prefix) { |
|
204 | - $this->fallbackDirsPsr0 = (array) $paths; |
|
205 | - } else { |
|
206 | - $this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths; |
|
207 | - } |
|
208 | - } |
|
209 | - |
|
210 | - /** |
|
211 | - * Registers a set of PSR-4 directories for a given namespace, |
|
212 | - * replacing any others previously set for this namespace. |
|
213 | - * |
|
214 | - * @param string $prefix The prefix/namespace, with trailing '\\' |
|
215 | - * @param array|string $paths The PSR-4 base directories |
|
216 | - * |
|
217 | - * @throws \InvalidArgumentException |
|
218 | - */ |
|
219 | - public function setPsr4($prefix, $paths) |
|
220 | - { |
|
221 | - if (!$prefix) { |
|
222 | - $this->fallbackDirsPsr4 = (array) $paths; |
|
223 | - } else { |
|
224 | - $length = strlen($prefix); |
|
225 | - if ('\\' !== $prefix[$length - 1]) { |
|
226 | - throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); |
|
227 | - } |
|
228 | - $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; |
|
229 | - $this->prefixDirsPsr4[$prefix] = (array) $paths; |
|
230 | - } |
|
231 | - } |
|
232 | - |
|
233 | - /** |
|
234 | - * Turns on searching the include path for class files. |
|
235 | - * |
|
236 | - * @param bool $useIncludePath |
|
237 | - */ |
|
238 | - public function setUseIncludePath($useIncludePath) |
|
239 | - { |
|
240 | - $this->useIncludePath = $useIncludePath; |
|
241 | - } |
|
242 | - |
|
243 | - /** |
|
244 | - * Can be used to check if the autoloader uses the include path to check |
|
245 | - * for classes. |
|
246 | - * |
|
247 | - * @return bool |
|
248 | - */ |
|
249 | - public function getUseIncludePath() |
|
250 | - { |
|
251 | - return $this->useIncludePath; |
|
252 | - } |
|
253 | - |
|
254 | - /** |
|
255 | - * Turns off searching the prefix and fallback directories for classes |
|
256 | - * that have not been registered with the class map. |
|
257 | - * |
|
258 | - * @param bool $classMapAuthoritative |
|
259 | - */ |
|
260 | - public function setClassMapAuthoritative($classMapAuthoritative) |
|
261 | - { |
|
262 | - $this->classMapAuthoritative = $classMapAuthoritative; |
|
263 | - } |
|
264 | - |
|
265 | - /** |
|
266 | - * Should class lookup fail if not found in the current class map? |
|
267 | - * |
|
268 | - * @return bool |
|
269 | - */ |
|
270 | - public function isClassMapAuthoritative() |
|
271 | - { |
|
272 | - return $this->classMapAuthoritative; |
|
273 | - } |
|
274 | - |
|
275 | - /** |
|
276 | - * APCu prefix to use to cache found/not-found classes, if the extension is enabled. |
|
277 | - * |
|
278 | - * @param string|null $apcuPrefix |
|
279 | - */ |
|
280 | - public function setApcuPrefix($apcuPrefix) |
|
281 | - { |
|
282 | - $this->apcuPrefix = function_exists('apcu_fetch') && ini_get('apc.enabled') ? $apcuPrefix : null; |
|
283 | - } |
|
284 | - |
|
285 | - /** |
|
286 | - * The APCu prefix in use, or null if APCu caching is not enabled. |
|
287 | - * |
|
288 | - * @return string|null |
|
289 | - */ |
|
290 | - public function getApcuPrefix() |
|
291 | - { |
|
292 | - return $this->apcuPrefix; |
|
293 | - } |
|
294 | - |
|
295 | - /** |
|
296 | - * Registers this instance as an autoloader. |
|
297 | - * |
|
298 | - * @param bool $prepend Whether to prepend the autoloader or not |
|
299 | - */ |
|
300 | - public function register($prepend = false) |
|
301 | - { |
|
302 | - spl_autoload_register(array($this, 'loadClass'), true, $prepend); |
|
303 | - } |
|
304 | - |
|
305 | - /** |
|
306 | - * Unregisters this instance as an autoloader. |
|
307 | - */ |
|
308 | - public function unregister() |
|
309 | - { |
|
310 | - spl_autoload_unregister(array($this, 'loadClass')); |
|
311 | - } |
|
312 | - |
|
313 | - /** |
|
314 | - * Loads the given class or interface. |
|
315 | - * |
|
316 | - * @param string $class The name of the class |
|
317 | - * @return bool|null True if loaded, null otherwise |
|
318 | - */ |
|
319 | - public function loadClass($class) |
|
320 | - { |
|
321 | - if ($file = $this->findFile($class)) { |
|
322 | - includeFile($file); |
|
323 | - |
|
324 | - return true; |
|
325 | - } |
|
326 | - } |
|
327 | - |
|
328 | - /** |
|
329 | - * Finds the path to the file where the class is defined. |
|
330 | - * |
|
331 | - * @param string $class The name of the class |
|
332 | - * |
|
333 | - * @return string|false The path if found, false otherwise |
|
334 | - */ |
|
335 | - public function findFile($class) |
|
336 | - { |
|
337 | - // class map lookup |
|
338 | - if (isset($this->classMap[$class])) { |
|
339 | - return $this->classMap[$class]; |
|
340 | - } |
|
341 | - if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) { |
|
342 | - return false; |
|
343 | - } |
|
344 | - if (null !== $this->apcuPrefix) { |
|
345 | - $file = apcu_fetch($this->apcuPrefix.$class, $hit); |
|
346 | - if ($hit) { |
|
347 | - return $file; |
|
348 | - } |
|
349 | - } |
|
350 | - |
|
351 | - $file = $this->findFileWithExtension($class, '.php'); |
|
352 | - |
|
353 | - // Search for Hack files if we are running on HHVM |
|
354 | - if (false === $file && defined('HHVM_VERSION')) { |
|
355 | - $file = $this->findFileWithExtension($class, '.hh'); |
|
356 | - } |
|
357 | - |
|
358 | - if (null !== $this->apcuPrefix) { |
|
359 | - apcu_add($this->apcuPrefix.$class, $file); |
|
360 | - } |
|
361 | - |
|
362 | - if (false === $file) { |
|
363 | - // Remember that this class does not exist. |
|
364 | - $this->missingClasses[$class] = true; |
|
365 | - } |
|
366 | - |
|
367 | - return $file; |
|
368 | - } |
|
369 | - |
|
370 | - private function findFileWithExtension($class, $ext) |
|
371 | - { |
|
372 | - // PSR-4 lookup |
|
373 | - $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext; |
|
374 | - |
|
375 | - $first = $class[0]; |
|
376 | - if (isset($this->prefixLengthsPsr4[$first])) { |
|
377 | - $subPath = $class; |
|
378 | - while (false !== $lastPos = strrpos($subPath, '\\')) { |
|
379 | - $subPath = substr($subPath, 0, $lastPos); |
|
380 | - $search = $subPath . '\\'; |
|
381 | - if (isset($this->prefixDirsPsr4[$search])) { |
|
382 | - $pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1); |
|
383 | - foreach ($this->prefixDirsPsr4[$search] as $dir) { |
|
384 | - if (file_exists($file = $dir . $pathEnd)) { |
|
385 | - return $file; |
|
386 | - } |
|
387 | - } |
|
388 | - } |
|
389 | - } |
|
390 | - } |
|
391 | - |
|
392 | - // PSR-4 fallback dirs |
|
393 | - foreach ($this->fallbackDirsPsr4 as $dir) { |
|
394 | - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) { |
|
395 | - return $file; |
|
396 | - } |
|
397 | - } |
|
398 | - |
|
399 | - // PSR-0 lookup |
|
400 | - if (false !== $pos = strrpos($class, '\\')) { |
|
401 | - // namespaced class name |
|
402 | - $logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1) |
|
403 | - . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR); |
|
404 | - } else { |
|
405 | - // PEAR-like class name |
|
406 | - $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext; |
|
407 | - } |
|
408 | - |
|
409 | - if (isset($this->prefixesPsr0[$first])) { |
|
410 | - foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) { |
|
411 | - if (0 === strpos($class, $prefix)) { |
|
412 | - foreach ($dirs as $dir) { |
|
413 | - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { |
|
414 | - return $file; |
|
415 | - } |
|
416 | - } |
|
417 | - } |
|
418 | - } |
|
419 | - } |
|
420 | - |
|
421 | - // PSR-0 fallback dirs |
|
422 | - foreach ($this->fallbackDirsPsr0 as $dir) { |
|
423 | - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { |
|
424 | - return $file; |
|
425 | - } |
|
426 | - } |
|
427 | - |
|
428 | - // PSR-0 include paths. |
|
429 | - if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) { |
|
430 | - return $file; |
|
431 | - } |
|
432 | - |
|
433 | - return false; |
|
434 | - } |
|
45 | + // PSR-4 |
|
46 | + private $prefixLengthsPsr4 = array(); |
|
47 | + private $prefixDirsPsr4 = array(); |
|
48 | + private $fallbackDirsPsr4 = array(); |
|
49 | + |
|
50 | + // PSR-0 |
|
51 | + private $prefixesPsr0 = array(); |
|
52 | + private $fallbackDirsPsr0 = array(); |
|
53 | + |
|
54 | + private $useIncludePath = false; |
|
55 | + private $classMap = array(); |
|
56 | + private $classMapAuthoritative = false; |
|
57 | + private $missingClasses = array(); |
|
58 | + private $apcuPrefix; |
|
59 | + |
|
60 | + public function getPrefixes() |
|
61 | + { |
|
62 | + if (!empty($this->prefixesPsr0)) { |
|
63 | + return call_user_func_array('array_merge', $this->prefixesPsr0); |
|
64 | + } |
|
65 | + |
|
66 | + return array(); |
|
67 | + } |
|
68 | + |
|
69 | + public function getPrefixesPsr4() |
|
70 | + { |
|
71 | + return $this->prefixDirsPsr4; |
|
72 | + } |
|
73 | + |
|
74 | + public function getFallbackDirs() |
|
75 | + { |
|
76 | + return $this->fallbackDirsPsr0; |
|
77 | + } |
|
78 | + |
|
79 | + public function getFallbackDirsPsr4() |
|
80 | + { |
|
81 | + return $this->fallbackDirsPsr4; |
|
82 | + } |
|
83 | + |
|
84 | + public function getClassMap() |
|
85 | + { |
|
86 | + return $this->classMap; |
|
87 | + } |
|
88 | + |
|
89 | + /** |
|
90 | + * @param array $classMap Class to filename map |
|
91 | + */ |
|
92 | + public function addClassMap(array $classMap) |
|
93 | + { |
|
94 | + if ($this->classMap) { |
|
95 | + $this->classMap = array_merge($this->classMap, $classMap); |
|
96 | + } else { |
|
97 | + $this->classMap = $classMap; |
|
98 | + } |
|
99 | + } |
|
100 | + |
|
101 | + /** |
|
102 | + * Registers a set of PSR-0 directories for a given prefix, either |
|
103 | + * appending or prepending to the ones previously set for this prefix. |
|
104 | + * |
|
105 | + * @param string $prefix The prefix |
|
106 | + * @param array|string $paths The PSR-0 root directories |
|
107 | + * @param bool $prepend Whether to prepend the directories |
|
108 | + */ |
|
109 | + public function add($prefix, $paths, $prepend = false) |
|
110 | + { |
|
111 | + if (!$prefix) { |
|
112 | + if ($prepend) { |
|
113 | + $this->fallbackDirsPsr0 = array_merge( |
|
114 | + (array) $paths, |
|
115 | + $this->fallbackDirsPsr0 |
|
116 | + ); |
|
117 | + } else { |
|
118 | + $this->fallbackDirsPsr0 = array_merge( |
|
119 | + $this->fallbackDirsPsr0, |
|
120 | + (array) $paths |
|
121 | + ); |
|
122 | + } |
|
123 | + |
|
124 | + return; |
|
125 | + } |
|
126 | + |
|
127 | + $first = $prefix[0]; |
|
128 | + if (!isset($this->prefixesPsr0[$first][$prefix])) { |
|
129 | + $this->prefixesPsr0[$first][$prefix] = (array) $paths; |
|
130 | + |
|
131 | + return; |
|
132 | + } |
|
133 | + if ($prepend) { |
|
134 | + $this->prefixesPsr0[$first][$prefix] = array_merge( |
|
135 | + (array) $paths, |
|
136 | + $this->prefixesPsr0[$first][$prefix] |
|
137 | + ); |
|
138 | + } else { |
|
139 | + $this->prefixesPsr0[$first][$prefix] = array_merge( |
|
140 | + $this->prefixesPsr0[$first][$prefix], |
|
141 | + (array) $paths |
|
142 | + ); |
|
143 | + } |
|
144 | + } |
|
145 | + |
|
146 | + /** |
|
147 | + * Registers a set of PSR-4 directories for a given namespace, either |
|
148 | + * appending or prepending to the ones previously set for this namespace. |
|
149 | + * |
|
150 | + * @param string $prefix The prefix/namespace, with trailing '\\' |
|
151 | + * @param array|string $paths The PSR-4 base directories |
|
152 | + * @param bool $prepend Whether to prepend the directories |
|
153 | + * |
|
154 | + * @throws \InvalidArgumentException |
|
155 | + */ |
|
156 | + public function addPsr4($prefix, $paths, $prepend = false) |
|
157 | + { |
|
158 | + if (!$prefix) { |
|
159 | + // Register directories for the root namespace. |
|
160 | + if ($prepend) { |
|
161 | + $this->fallbackDirsPsr4 = array_merge( |
|
162 | + (array) $paths, |
|
163 | + $this->fallbackDirsPsr4 |
|
164 | + ); |
|
165 | + } else { |
|
166 | + $this->fallbackDirsPsr4 = array_merge( |
|
167 | + $this->fallbackDirsPsr4, |
|
168 | + (array) $paths |
|
169 | + ); |
|
170 | + } |
|
171 | + } elseif (!isset($this->prefixDirsPsr4[$prefix])) { |
|
172 | + // Register directories for a new namespace. |
|
173 | + $length = strlen($prefix); |
|
174 | + if ('\\' !== $prefix[$length - 1]) { |
|
175 | + throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); |
|
176 | + } |
|
177 | + $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; |
|
178 | + $this->prefixDirsPsr4[$prefix] = (array) $paths; |
|
179 | + } elseif ($prepend) { |
|
180 | + // Prepend directories for an already registered namespace. |
|
181 | + $this->prefixDirsPsr4[$prefix] = array_merge( |
|
182 | + (array) $paths, |
|
183 | + $this->prefixDirsPsr4[$prefix] |
|
184 | + ); |
|
185 | + } else { |
|
186 | + // Append directories for an already registered namespace. |
|
187 | + $this->prefixDirsPsr4[$prefix] = array_merge( |
|
188 | + $this->prefixDirsPsr4[$prefix], |
|
189 | + (array) $paths |
|
190 | + ); |
|
191 | + } |
|
192 | + } |
|
193 | + |
|
194 | + /** |
|
195 | + * Registers a set of PSR-0 directories for a given prefix, |
|
196 | + * replacing any others previously set for this prefix. |
|
197 | + * |
|
198 | + * @param string $prefix The prefix |
|
199 | + * @param array|string $paths The PSR-0 base directories |
|
200 | + */ |
|
201 | + public function set($prefix, $paths) |
|
202 | + { |
|
203 | + if (!$prefix) { |
|
204 | + $this->fallbackDirsPsr0 = (array) $paths; |
|
205 | + } else { |
|
206 | + $this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths; |
|
207 | + } |
|
208 | + } |
|
209 | + |
|
210 | + /** |
|
211 | + * Registers a set of PSR-4 directories for a given namespace, |
|
212 | + * replacing any others previously set for this namespace. |
|
213 | + * |
|
214 | + * @param string $prefix The prefix/namespace, with trailing '\\' |
|
215 | + * @param array|string $paths The PSR-4 base directories |
|
216 | + * |
|
217 | + * @throws \InvalidArgumentException |
|
218 | + */ |
|
219 | + public function setPsr4($prefix, $paths) |
|
220 | + { |
|
221 | + if (!$prefix) { |
|
222 | + $this->fallbackDirsPsr4 = (array) $paths; |
|
223 | + } else { |
|
224 | + $length = strlen($prefix); |
|
225 | + if ('\\' !== $prefix[$length - 1]) { |
|
226 | + throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); |
|
227 | + } |
|
228 | + $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; |
|
229 | + $this->prefixDirsPsr4[$prefix] = (array) $paths; |
|
230 | + } |
|
231 | + } |
|
232 | + |
|
233 | + /** |
|
234 | + * Turns on searching the include path for class files. |
|
235 | + * |
|
236 | + * @param bool $useIncludePath |
|
237 | + */ |
|
238 | + public function setUseIncludePath($useIncludePath) |
|
239 | + { |
|
240 | + $this->useIncludePath = $useIncludePath; |
|
241 | + } |
|
242 | + |
|
243 | + /** |
|
244 | + * Can be used to check if the autoloader uses the include path to check |
|
245 | + * for classes. |
|
246 | + * |
|
247 | + * @return bool |
|
248 | + */ |
|
249 | + public function getUseIncludePath() |
|
250 | + { |
|
251 | + return $this->useIncludePath; |
|
252 | + } |
|
253 | + |
|
254 | + /** |
|
255 | + * Turns off searching the prefix and fallback directories for classes |
|
256 | + * that have not been registered with the class map. |
|
257 | + * |
|
258 | + * @param bool $classMapAuthoritative |
|
259 | + */ |
|
260 | + public function setClassMapAuthoritative($classMapAuthoritative) |
|
261 | + { |
|
262 | + $this->classMapAuthoritative = $classMapAuthoritative; |
|
263 | + } |
|
264 | + |
|
265 | + /** |
|
266 | + * Should class lookup fail if not found in the current class map? |
|
267 | + * |
|
268 | + * @return bool |
|
269 | + */ |
|
270 | + public function isClassMapAuthoritative() |
|
271 | + { |
|
272 | + return $this->classMapAuthoritative; |
|
273 | + } |
|
274 | + |
|
275 | + /** |
|
276 | + * APCu prefix to use to cache found/not-found classes, if the extension is enabled. |
|
277 | + * |
|
278 | + * @param string|null $apcuPrefix |
|
279 | + */ |
|
280 | + public function setApcuPrefix($apcuPrefix) |
|
281 | + { |
|
282 | + $this->apcuPrefix = function_exists('apcu_fetch') && ini_get('apc.enabled') ? $apcuPrefix : null; |
|
283 | + } |
|
284 | + |
|
285 | + /** |
|
286 | + * The APCu prefix in use, or null if APCu caching is not enabled. |
|
287 | + * |
|
288 | + * @return string|null |
|
289 | + */ |
|
290 | + public function getApcuPrefix() |
|
291 | + { |
|
292 | + return $this->apcuPrefix; |
|
293 | + } |
|
294 | + |
|
295 | + /** |
|
296 | + * Registers this instance as an autoloader. |
|
297 | + * |
|
298 | + * @param bool $prepend Whether to prepend the autoloader or not |
|
299 | + */ |
|
300 | + public function register($prepend = false) |
|
301 | + { |
|
302 | + spl_autoload_register(array($this, 'loadClass'), true, $prepend); |
|
303 | + } |
|
304 | + |
|
305 | + /** |
|
306 | + * Unregisters this instance as an autoloader. |
|
307 | + */ |
|
308 | + public function unregister() |
|
309 | + { |
|
310 | + spl_autoload_unregister(array($this, 'loadClass')); |
|
311 | + } |
|
312 | + |
|
313 | + /** |
|
314 | + * Loads the given class or interface. |
|
315 | + * |
|
316 | + * @param string $class The name of the class |
|
317 | + * @return bool|null True if loaded, null otherwise |
|
318 | + */ |
|
319 | + public function loadClass($class) |
|
320 | + { |
|
321 | + if ($file = $this->findFile($class)) { |
|
322 | + includeFile($file); |
|
323 | + |
|
324 | + return true; |
|
325 | + } |
|
326 | + } |
|
327 | + |
|
328 | + /** |
|
329 | + * Finds the path to the file where the class is defined. |
|
330 | + * |
|
331 | + * @param string $class The name of the class |
|
332 | + * |
|
333 | + * @return string|false The path if found, false otherwise |
|
334 | + */ |
|
335 | + public function findFile($class) |
|
336 | + { |
|
337 | + // class map lookup |
|
338 | + if (isset($this->classMap[$class])) { |
|
339 | + return $this->classMap[$class]; |
|
340 | + } |
|
341 | + if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) { |
|
342 | + return false; |
|
343 | + } |
|
344 | + if (null !== $this->apcuPrefix) { |
|
345 | + $file = apcu_fetch($this->apcuPrefix.$class, $hit); |
|
346 | + if ($hit) { |
|
347 | + return $file; |
|
348 | + } |
|
349 | + } |
|
350 | + |
|
351 | + $file = $this->findFileWithExtension($class, '.php'); |
|
352 | + |
|
353 | + // Search for Hack files if we are running on HHVM |
|
354 | + if (false === $file && defined('HHVM_VERSION')) { |
|
355 | + $file = $this->findFileWithExtension($class, '.hh'); |
|
356 | + } |
|
357 | + |
|
358 | + if (null !== $this->apcuPrefix) { |
|
359 | + apcu_add($this->apcuPrefix.$class, $file); |
|
360 | + } |
|
361 | + |
|
362 | + if (false === $file) { |
|
363 | + // Remember that this class does not exist. |
|
364 | + $this->missingClasses[$class] = true; |
|
365 | + } |
|
366 | + |
|
367 | + return $file; |
|
368 | + } |
|
369 | + |
|
370 | + private function findFileWithExtension($class, $ext) |
|
371 | + { |
|
372 | + // PSR-4 lookup |
|
373 | + $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext; |
|
374 | + |
|
375 | + $first = $class[0]; |
|
376 | + if (isset($this->prefixLengthsPsr4[$first])) { |
|
377 | + $subPath = $class; |
|
378 | + while (false !== $lastPos = strrpos($subPath, '\\')) { |
|
379 | + $subPath = substr($subPath, 0, $lastPos); |
|
380 | + $search = $subPath . '\\'; |
|
381 | + if (isset($this->prefixDirsPsr4[$search])) { |
|
382 | + $pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1); |
|
383 | + foreach ($this->prefixDirsPsr4[$search] as $dir) { |
|
384 | + if (file_exists($file = $dir . $pathEnd)) { |
|
385 | + return $file; |
|
386 | + } |
|
387 | + } |
|
388 | + } |
|
389 | + } |
|
390 | + } |
|
391 | + |
|
392 | + // PSR-4 fallback dirs |
|
393 | + foreach ($this->fallbackDirsPsr4 as $dir) { |
|
394 | + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) { |
|
395 | + return $file; |
|
396 | + } |
|
397 | + } |
|
398 | + |
|
399 | + // PSR-0 lookup |
|
400 | + if (false !== $pos = strrpos($class, '\\')) { |
|
401 | + // namespaced class name |
|
402 | + $logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1) |
|
403 | + . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR); |
|
404 | + } else { |
|
405 | + // PEAR-like class name |
|
406 | + $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext; |
|
407 | + } |
|
408 | + |
|
409 | + if (isset($this->prefixesPsr0[$first])) { |
|
410 | + foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) { |
|
411 | + if (0 === strpos($class, $prefix)) { |
|
412 | + foreach ($dirs as $dir) { |
|
413 | + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { |
|
414 | + return $file; |
|
415 | + } |
|
416 | + } |
|
417 | + } |
|
418 | + } |
|
419 | + } |
|
420 | + |
|
421 | + // PSR-0 fallback dirs |
|
422 | + foreach ($this->fallbackDirsPsr0 as $dir) { |
|
423 | + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { |
|
424 | + return $file; |
|
425 | + } |
|
426 | + } |
|
427 | + |
|
428 | + // PSR-0 include paths. |
|
429 | + if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) { |
|
430 | + return $file; |
|
431 | + } |
|
432 | + |
|
433 | + return false; |
|
434 | + } |
|
435 | 435 | } |
436 | 436 | |
437 | 437 | /** |
@@ -441,5 +441,5 @@ discard block |
||
441 | 441 | */ |
442 | 442 | function includeFile($file) |
443 | 443 | { |
444 | - include $file; |
|
444 | + include $file; |
|
445 | 445 | } |
@@ -342,7 +342,7 @@ discard block |
||
342 | 342 | return false; |
343 | 343 | } |
344 | 344 | if (null !== $this->apcuPrefix) { |
345 | - $file = apcu_fetch($this->apcuPrefix.$class, $hit); |
|
345 | + $file = apcu_fetch($this->apcuPrefix . $class, $hit); |
|
346 | 346 | if ($hit) { |
347 | 347 | return $file; |
348 | 348 | } |
@@ -356,7 +356,7 @@ discard block |
||
356 | 356 | } |
357 | 357 | |
358 | 358 | if (null !== $this->apcuPrefix) { |
359 | - apcu_add($this->apcuPrefix.$class, $file); |
|
359 | + apcu_add($this->apcuPrefix . $class, $file); |
|
360 | 360 | } |
361 | 361 | |
362 | 362 | if (false === $file) { |
@@ -44,7 +44,7 @@ |
||
44 | 44 | ORDER BY m.icon_order', |
45 | 45 | [] |
46 | 46 | )->fetch_callback( |
47 | - function ($row) use (&$icons, &$last_icon, &$trueOrder) { |
|
47 | + function($row) use (&$icons, &$last_icon, &$trueOrder) { |
|
48 | 48 | global $settings, $txt; |
49 | 49 | |
50 | 50 | $icons[$row['id_icon']] = [ |
@@ -614,7 +614,7 @@ |
||
614 | 614 | 'type' => 0, |
615 | 615 | ) |
616 | 616 | )->fetch_callback( |
617 | - function ($row) use (&$attachmentData) { |
|
617 | + function($row) use (&$attachmentData) { |
|
618 | 618 | $attachmentData = $row; |
619 | 619 | $attachmentData['is_image'] = substr($attachmentData['mime_type'], 0, 5) === 'image'; |
620 | 620 | $attachmentData['size'] = byte_format($attachmentData['size']); |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | FROM {db_prefix}messages', |
35 | 35 | array() |
36 | 36 | )->fetch_callback( |
37 | - function ($row) use (&$fulltext_index) { |
|
37 | + function($row) use (&$fulltext_index) { |
|
38 | 38 | if (($row['Column_name'] === 'body' || $row['Column_name'] === 'subject') |
39 | 39 | && (isset($row['Index_type']) && $row['Index_type'] === 'FULLTEXT' |
40 | 40 | || isset($row['Comment']) && $row['Comment'] === 'FULLTEXT')) |
@@ -380,7 +380,7 @@ discard block |
||
380 | 380 | 'starting_id' => $start, |
381 | 381 | ) |
382 | 382 | )->fetch_callback( |
383 | - function ($row) use (&$num_messages) { |
|
383 | + function($row) use (&$num_messages) { |
|
384 | 384 | $num_messages[empty($row['todo']) ? 'done' : 'todo'] = $row['num_messages']; |
385 | 385 | } |
386 | 386 | ); |
@@ -414,7 +414,7 @@ discard block |
||
414 | 414 | 'limit' => $messages_per_batch, |
415 | 415 | ) |
416 | 416 | )->fetch_callback( |
417 | - function ($row) use (&$forced_break, &$number_processed, &$inserts, $stop) { |
|
417 | + function($row) use (&$forced_break, &$number_processed, &$inserts, $stop) { |
|
418 | 418 | // In theory it's possible for one of these to take friggin ages so add more timeout protection. |
419 | 419 | if ($stop < time() || $forced_break) |
420 | 420 | { |
@@ -501,7 +501,7 @@ discard block |
||
501 | 501 | 'minimum_messages' => $max_occurrences, |
502 | 502 | ) |
503 | 503 | )->fetch_callback( |
504 | - function ($row) use (&$stop_words) { |
|
504 | + function($row) use (&$stop_words) { |
|
505 | 505 | $stop_words[] = $row['id_word']; |
506 | 506 | } |
507 | 507 | ); |
@@ -785,7 +785,7 @@ discard block |
||
785 | 785 | 'approved' => 1, |
786 | 786 | ) |
787 | 787 | )->fetch_callback( |
788 | - function ($row) use (&$topic_changes) { |
|
788 | + function($row) use (&$topic_changes) { |
|
789 | 789 | $topic_changes[$row['id_topic']]['id_last_msg'] = $row['id_last_msg']; |
790 | 790 | } |
791 | 791 | ); |
@@ -947,7 +947,7 @@ discard block |
||
947 | 947 | 'approved' => 1, |
948 | 948 | ) |
949 | 949 | )->fetch_callback( |
950 | - function ($row) use (&$lastMsg) { |
|
950 | + function($row) use (&$lastMsg) { |
|
951 | 951 | $lastMsg[$row['id_board']] = $row['id_msg']; |
952 | 952 | } |
953 | 953 | ); |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | LEFT JOIN {db_prefix}topics AS t ON (t.id_topic = m.id_topic) |
108 | 108 | WHERE t.id_topic IS NULL |
109 | 109 | GROUP BY m.id_topic, m.id_board', |
110 | - 'fix_processing' => function ($row) { |
|
110 | + 'fix_processing' => function($row) { |
|
111 | 111 | $db = database(); |
112 | 112 | |
113 | 113 | // Only if we don't have a reasonable idea of where to put it. |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | // Remove all topics that have zero messages in the messages table. |
197 | 197 | 'fix_collect' => array( |
198 | 198 | 'index' => 'id_topic', |
199 | - 'process' => function ($topics) { |
|
199 | + 'process' => function($topics) { |
|
200 | 200 | $db = database(); |
201 | 201 | |
202 | 202 | $db->query('', ' |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | LEFT JOIN {db_prefix}topics AS t ON (t.id_poll = p.id_poll) |
232 | 232 | WHERE p.id_poll BETWEEN {STEP_LOW} AND {STEP_HIGH} |
233 | 233 | AND t.id_poll IS NULL', |
234 | - 'fix_processing' => function ($row) { |
|
234 | + 'fix_processing' => function($row) { |
|
235 | 235 | global $txt; |
236 | 236 | |
237 | 237 | $db = database(); |
@@ -346,7 +346,7 @@ discard block |
||
346 | 346 | WHERE t.id_topic BETWEEN {STEP_LOW} AND {STEP_HIGH} |
347 | 347 | GROUP BY t.id_topic, t.id_first_msg, t.id_last_msg, t.approved, mf.approved |
348 | 348 | ORDER BY t.id_topic', |
349 | - 'fix_processing' => function ($row) { |
|
349 | + 'fix_processing' => function($row) { |
|
350 | 350 | $row['firstmsg_approved'] = (int) $row['firstmsg_approved']; |
351 | 351 | $row['myid_first_msg'] = (int) $row['myid_first_msg']; |
352 | 352 | $row['myid_last_msg'] = (int) $row['myid_last_msg']; |
@@ -369,7 +369,7 @@ discard block |
||
369 | 369 | 'approved' => $row['firstmsg_approved'], |
370 | 370 | )); |
371 | 371 | }, |
372 | - 'message_function' => function ($row) { |
|
372 | + 'message_function' => function($row) { |
|
373 | 373 | global $txt, $context; |
374 | 374 | |
375 | 375 | // A pretend error? |
@@ -414,7 +414,7 @@ discard block |
||
414 | 414 | WHERE t.id_topic BETWEEN {STEP_LOW} AND {STEP_HIGH} |
415 | 415 | GROUP BY t.id_topic, t.num_replies, mf.approved |
416 | 416 | ORDER BY t.id_topic', |
417 | - 'fix_processing' => function ($row) { |
|
417 | + 'fix_processing' => function($row) { |
|
418 | 418 | $row['my_num_replies'] = (int) $row['my_num_replies']; |
419 | 419 | |
420 | 420 | // Not really a problem? |
@@ -428,7 +428,7 @@ discard block |
||
428 | 428 | 'num_replies' => $row['my_num_replies'], |
429 | 429 | )); |
430 | 430 | }, |
431 | - 'message_function' => function ($row) { |
|
431 | + 'message_function' => function($row) { |
|
432 | 432 | global $txt, $context; |
433 | 433 | |
434 | 434 | // Just joking? |
@@ -462,7 +462,7 @@ discard block |
||
462 | 462 | GROUP BY t.id_topic, t.unapproved_posts |
463 | 463 | HAVING unapproved_posts != COUNT(mu.id_msg) |
464 | 464 | ORDER BY t.id_topic', |
465 | - 'fix_processing' => function ($row) { |
|
465 | + 'fix_processing' => function($row) { |
|
466 | 466 | $row['my_unapproved_posts'] = (int) $row['my_unapproved_posts']; |
467 | 467 | |
468 | 468 | setTopicAttribute($row['id_topic'], array( |
@@ -496,7 +496,7 @@ discard block |
||
496 | 496 | WHERE b.id_board IS NULL |
497 | 497 | AND t.id_topic BETWEEN {STEP_LOW} AND {STEP_HIGH} |
498 | 498 | GROUP BY t.id_board', |
499 | - 'fix_processing' => function ($row) { |
|
499 | + 'fix_processing' => function($row) { |
|
500 | 500 | global $txt; |
501 | 501 | |
502 | 502 | $db = database(); |
@@ -547,7 +547,7 @@ discard block |
||
547 | 547 | ORDER BY b.id_cat, b.id_board', |
548 | 548 | 'fix_collect' => array( |
549 | 549 | 'index' => 'id_cat', |
550 | - 'process' => function ($cats) { |
|
550 | + 'process' => function($cats) { |
|
551 | 551 | $db = database(); |
552 | 552 | $salvageCatID = createSalvageCategory(); |
553 | 553 | $db->query('', ' |
@@ -583,7 +583,7 @@ discard block |
||
583 | 583 | // Last step-make sure all non-guest posters still exist. |
584 | 584 | 'fix_collect' => array( |
585 | 585 | 'index' => 'id_msg', |
586 | - 'process' => function ($msgs) { |
|
586 | + 'process' => function($msgs) { |
|
587 | 587 | $db = database(); |
588 | 588 | |
589 | 589 | $db->query('', ' |
@@ -612,7 +612,7 @@ discard block |
||
612 | 612 | ORDER BY b.id_parent, b.id_board', |
613 | 613 | 'fix_collect' => array( |
614 | 614 | 'index' => 'id_parent', |
615 | - 'process' => function ($parents) { |
|
615 | + 'process' => function($parents) { |
|
616 | 616 | $db = database(); |
617 | 617 | $salvageCatID = createSalvageCategory(); |
618 | 618 | $salvageBoardID = createSalvageBoard(); |
@@ -649,7 +649,7 @@ discard block |
||
649 | 649 | AND p.id_poll IS NULL', |
650 | 650 | 'fix_collect' => array( |
651 | 651 | 'index' => 'id_poll', |
652 | - 'process' => function ($polls) { |
|
652 | + 'process' => function($polls) { |
|
653 | 653 | $db = database(); |
654 | 654 | |
655 | 655 | $db->query('', ' |
@@ -683,7 +683,7 @@ discard block |
||
683 | 683 | ORDER BY cal.id_topic', |
684 | 684 | 'fix_collect' => array( |
685 | 685 | 'index' => 'id_topic', |
686 | - 'process' => function ($events) { |
|
686 | + 'process' => function($events) { |
|
687 | 687 | $db = database(); |
688 | 688 | |
689 | 689 | $db->query('', ' |
@@ -714,7 +714,7 @@ discard block |
||
714 | 714 | AND lt.id_member BETWEEN {STEP_LOW} AND {STEP_HIGH}', |
715 | 715 | 'fix_collect' => array( |
716 | 716 | 'index' => 'id_topic', |
717 | - 'process' => function ($topics) { |
|
717 | + 'process' => function($topics) { |
|
718 | 718 | $db = database(); |
719 | 719 | |
720 | 720 | $db->query('', ' |
@@ -743,7 +743,7 @@ discard block |
||
743 | 743 | AND lt.id_member BETWEEN {STEP_LOW} AND {STEP_HIGH}', |
744 | 744 | 'fix_collect' => array( |
745 | 745 | 'index' => 'id_member', |
746 | - 'process' => function ($members) { |
|
746 | + 'process' => function($members) { |
|
747 | 747 | $db = database(); |
748 | 748 | |
749 | 749 | $db->query('', ' |
@@ -772,7 +772,7 @@ discard block |
||
772 | 772 | AND lb.id_member BETWEEN {STEP_LOW} AND {STEP_HIGH}', |
773 | 773 | 'fix_collect' => array( |
774 | 774 | 'index' => 'id_board', |
775 | - 'process' => function ($boards) { |
|
775 | + 'process' => function($boards) { |
|
776 | 776 | $db = database(); |
777 | 777 | |
778 | 778 | $db->query('', ' |
@@ -801,7 +801,7 @@ discard block |
||
801 | 801 | AND lb.id_member BETWEEN {STEP_LOW} AND {STEP_HIGH}', |
802 | 802 | 'fix_collect' => array( |
803 | 803 | 'index' => 'id_member', |
804 | - 'process' => function ($members) { |
|
804 | + 'process' => function($members) { |
|
805 | 805 | $db = database(); |
806 | 806 | |
807 | 807 | $db->query('', ' |
@@ -830,7 +830,7 @@ discard block |
||
830 | 830 | AND lmr.id_member BETWEEN {STEP_LOW} AND {STEP_HIGH}', |
831 | 831 | 'fix_collect' => array( |
832 | 832 | 'index' => 'id_board', |
833 | - 'process' => function ($boards) { |
|
833 | + 'process' => function($boards) { |
|
834 | 834 | $db = database(); |
835 | 835 | |
836 | 836 | $db->query('', ' |
@@ -859,7 +859,7 @@ discard block |
||
859 | 859 | AND lmr.id_member BETWEEN {STEP_LOW} AND {STEP_HIGH}', |
860 | 860 | 'fix_collect' => array( |
861 | 861 | 'index' => 'id_member', |
862 | - 'process' => function ($members) { |
|
862 | + 'process' => function($members) { |
|
863 | 863 | $db = database(); |
864 | 864 | |
865 | 865 | $db->query('', ' |
@@ -890,7 +890,7 @@ discard block |
||
890 | 890 | GROUP BY pmr.id_pm', |
891 | 891 | 'fix_collect' => array( |
892 | 892 | 'index' => 'id_pm', |
893 | - 'process' => function ($pms) { |
|
893 | + 'process' => function($pms) { |
|
894 | 894 | $db = database(); |
895 | 895 | |
896 | 896 | $db->query('', ' |
@@ -920,7 +920,7 @@ discard block |
||
920 | 920 | AND mem.id_member IS NULL', |
921 | 921 | 'fix_collect' => array( |
922 | 922 | 'index' => 'id_member', |
923 | - 'process' => function ($members) { |
|
923 | + 'process' => function($members) { |
|
924 | 924 | $db = database(); |
925 | 925 | |
926 | 926 | $db->query('', ' |
@@ -951,7 +951,7 @@ discard block |
||
951 | 951 | AND mem.id_member IS NULL', |
952 | 952 | 'fix_collect' => array( |
953 | 953 | 'index' => 'id_pm', |
954 | - 'process' => function ($guestMessages) { |
|
954 | + 'process' => function($guestMessages) { |
|
955 | 955 | $db = database(); |
956 | 956 | |
957 | 957 | $db->query('', ' |
@@ -980,7 +980,7 @@ discard block |
||
980 | 980 | AND mem.id_member IS NULL', |
981 | 981 | 'fix_collect' => array( |
982 | 982 | 'index' => 'id_member', |
983 | - 'process' => function ($members) { |
|
983 | + 'process' => function($members) { |
|
984 | 984 | $db = database(); |
985 | 985 | |
986 | 986 | $db->query('', ' |
@@ -1009,7 +1009,7 @@ discard block |
||
1009 | 1009 | LEFT JOIN {db_prefix}log_search_subjects AS lss ON (lss.id_topic = t.id_topic) |
1010 | 1010 | WHERE t.id_topic BETWEEN {STEP_LOW} AND {STEP_HIGH} |
1011 | 1011 | AND lss.id_topic IS NULL', |
1012 | - 'fix_full_processing' => function ($result) { |
|
1012 | + 'fix_full_processing' => function($result) { |
|
1013 | 1013 | |
1014 | 1014 | $db = database(); |
1015 | 1015 | |
@@ -1043,7 +1043,7 @@ discard block |
||
1043 | 1043 | ); |
1044 | 1044 | } |
1045 | 1045 | }, |
1046 | - 'message_function' => function ($row) { |
|
1046 | + 'message_function' => function($row) { |
|
1047 | 1047 | global $txt, $context; |
1048 | 1048 | |
1049 | 1049 | if (count(text2words($row['subject'])) != 0) |
@@ -1072,7 +1072,7 @@ discard block |
||
1072 | 1072 | AND t.id_topic IS NULL', |
1073 | 1073 | 'fix_collect' => array( |
1074 | 1074 | 'index' => 'id_topic', |
1075 | - 'process' => function ($deleteTopics) { |
|
1075 | + 'process' => function($deleteTopics) { |
|
1076 | 1076 | $db = database(); |
1077 | 1077 | |
1078 | 1078 | $db->query('', ' |
@@ -1103,7 +1103,7 @@ discard block |
||
1103 | 1103 | AND mem.id_member IS NULL', |
1104 | 1104 | 'fix_collect' => array( |
1105 | 1105 | 'index' => 'id_member', |
1106 | - 'process' => function ($members) { |
|
1106 | + 'process' => function($members) { |
|
1107 | 1107 | $db = database(); |
1108 | 1108 | |
1109 | 1109 | $db->query('', ' |
@@ -1133,7 +1133,7 @@ discard block |
||
1133 | 1133 | AND p.id_poll IS NULL', |
1134 | 1134 | 'fix_collect' => array( |
1135 | 1135 | 'index' => 'id_poll', |
1136 | - 'process' => function ($polls) { |
|
1136 | + 'process' => function($polls) { |
|
1137 | 1137 | $db = database(); |
1138 | 1138 | |
1139 | 1139 | $db->query('', ' |
@@ -1163,7 +1163,7 @@ discard block |
||
1163 | 1163 | AND lrc.id_report IS NULL', |
1164 | 1164 | 'fix_collect' => array( |
1165 | 1165 | 'index' => 'id_report', |
1166 | - 'process' => function ($reports) { |
|
1166 | + 'process' => function($reports) { |
|
1167 | 1167 | $db = database(); |
1168 | 1168 | |
1169 | 1169 | $db->query('', ' |
@@ -1193,7 +1193,7 @@ discard block |
||
1193 | 1193 | AND lr.id_report IS NULL', |
1194 | 1194 | 'fix_collect' => array( |
1195 | 1195 | 'index' => 'id_report', |
1196 | - 'process' => function ($reports) { |
|
1196 | + 'process' => function($reports) { |
|
1197 | 1197 | $db = database(); |
1198 | 1198 | |
1199 | 1199 | $db->query('', ' |
@@ -1222,7 +1222,7 @@ discard block |
||
1222 | 1222 | AND mem.id_member IS NULL', |
1223 | 1223 | 'fix_collect' => array( |
1224 | 1224 | 'index' => 'id_member', |
1225 | - 'process' => function ($members) { |
|
1225 | + 'process' => function($members) { |
|
1226 | 1226 | $db = database(); |
1227 | 1227 | |
1228 | 1228 | $db->query('', ' |
@@ -1251,7 +1251,7 @@ discard block |
||
1251 | 1251 | AND mg.id_group IS NULL', |
1252 | 1252 | 'fix_collect' => array( |
1253 | 1253 | 'index' => 'id_group', |
1254 | - 'process' => function ($groups) { |
|
1254 | + 'process' => function($groups) { |
|
1255 | 1255 | $db = database(); |
1256 | 1256 | |
1257 | 1257 | $db->query('', ' |
@@ -88,7 +88,7 @@ |
||
88 | 88 | GROUP BY lngfile', |
89 | 89 | array() |
90 | 90 | )->fetch_callback( |
91 | - function ($row) use (&$languages, $language) { |
|
91 | + function($row) use (&$languages, $language) { |
|
92 | 92 | // Default? |
93 | 93 | if (empty($row['lngfile']) || !isset($languages[$row['lngfile']])) |
94 | 94 | { |
@@ -330,7 +330,7 @@ discard block |
||
330 | 330 | 'newbie_group' => 4, |
331 | 331 | ) |
332 | 332 | )->fetch_callback( |
333 | - function ($row) use ($db, $boardLevels, $profile, $level) { |
|
333 | + function($row) use ($db, $boardLevels, $profile, $level) { |
|
334 | 334 | $group = $row['id_group']; |
335 | 335 | |
336 | 336 | $boardInserts = array(); |
@@ -388,7 +388,7 @@ discard block |
||
388 | 388 | ORDER BY id_profile', |
389 | 389 | array() |
390 | 390 | )->fetch_callback( |
391 | - function ($row) use ($txt) { |
|
391 | + function($row) use ($txt) { |
|
392 | 392 | global $context; |
393 | 393 | |
394 | 394 | // Format the label nicely. |
@@ -737,7 +737,7 @@ discard block |
||
737 | 737 | 'hidden_permissions' => !isset($hidden_permissions) ? $hidden_permissions : array(), |
738 | 738 | ) |
739 | 739 | )->fetch_callback( |
740 | - function ($row) use (&$groups) { |
|
740 | + function($row) use (&$groups) { |
|
741 | 741 | if (isset($groups[(int) $row['id_group']]) && (!empty($row['add_deny']) || $row['id_group'] != -1)) |
742 | 742 | { |
743 | 743 | $groups[$row['id_group']]['num_permissions'][empty($row['add_deny']) ? 'denied' : 'allowed'] = $row['num_permissions']; |
@@ -775,7 +775,7 @@ discard block |
||
775 | 775 | 'current_profile' => $profile_id, |
776 | 776 | ) |
777 | 777 | )->fetch_callback( |
778 | - function ($row) use (&$groups) { |
|
778 | + function($row) use (&$groups) { |
|
779 | 779 | if (isset($groups[(int) $row['id_group']]) && (!empty($row['add_deny']) || $row['id_group'] != -1)) |
780 | 780 | { |
781 | 781 | $groups[$row['id_group']]['num_permissions'][empty($row['add_deny']) ? 'denied' : 'allowed'] += $row['num_permissions']; |
@@ -834,7 +834,7 @@ discard block |
||
834 | 834 | 'copy_from' => $copy_from, |
835 | 835 | ) |
836 | 836 | )->fetch_callback( |
837 | - function ($row) use (&$target_perm) { |
|
837 | + function($row) use (&$target_perm) { |
|
838 | 838 | $target_perm[$row['permission']] = $row['add_deny']; |
839 | 839 | } |
840 | 840 | ); |
@@ -907,7 +907,7 @@ discard block |
||
907 | 907 | 'current_profile' => $profile_id, |
908 | 908 | ) |
909 | 909 | )->fetch_callback( |
910 | - function ($row) use (&$target_perm) { |
|
910 | + function($row) use (&$target_perm) { |
|
911 | 911 | $target_perm[$row['permission']] = $row['add_deny']; |
912 | 912 | } |
913 | 913 | ); |
@@ -1070,7 +1070,7 @@ discard block |
||
1070 | 1070 | 'current_group' => $id_group, |
1071 | 1071 | ) |
1072 | 1072 | )->fetch_callback( |
1073 | - function ($row) use (&$permissions) { |
|
1073 | + function($row) use (&$permissions) { |
|
1074 | 1074 | $permissions[empty($row['add_deny']) ? 'denied' : 'allowed'][] = $row['permission']; |
1075 | 1075 | } |
1076 | 1076 | ); |
@@ -1109,7 +1109,7 @@ discard block |
||
1109 | 1109 | 'current_profile' => $permission_type === 'membergroup' ? 1 : $profile_id, |
1110 | 1110 | ) |
1111 | 1111 | )->fetch_callback( |
1112 | - function ($row) use (&$permissions) { |
|
1112 | + function($row) use (&$permissions) { |
|
1113 | 1113 | $permissions[empty($row['add_deny']) ? 'denied' : 'allowed'][] = $row['permission']; |
1114 | 1114 | } |
1115 | 1115 | ); |
@@ -1205,7 +1205,7 @@ discard block |
||
1205 | 1205 | 'min_posts' => -1, |
1206 | 1206 | ) |
1207 | 1207 | )->fetch_callback( |
1208 | - function ($row) { |
|
1208 | + function($row) { |
|
1209 | 1209 | return $row['id_group']; |
1210 | 1210 | } |
1211 | 1211 | ); |
@@ -1272,7 +1272,7 @@ discard block |
||
1272 | 1272 | 'copy_from' => $copy_from, |
1273 | 1273 | ) |
1274 | 1274 | )->fetch_callback( |
1275 | - function ($row) use ($profile_id) { |
|
1275 | + function($row) use ($profile_id) { |
|
1276 | 1276 | return array($profile_id, $row['id_group'], $row['permission'], $row['add_deny']); |
1277 | 1277 | } |
1278 | 1278 | ); |
@@ -1372,7 +1372,7 @@ discard block |
||
1372 | 1372 | GROUP BY id_profile', |
1373 | 1373 | array() |
1374 | 1374 | )->fetch_callback( |
1375 | - function ($row) use (&$profiles) { |
|
1375 | + function($row) use (&$profiles) { |
|
1376 | 1376 | global $txt; |
1377 | 1377 | |
1378 | 1378 | if (isset($profiles[$row['id_profile']])) |
@@ -1459,7 +1459,7 @@ discard block |
||
1459 | 1459 | 'permissions' => $permissions, |
1460 | 1460 | ) |
1461 | 1461 | )->fetch_callback( |
1462 | - function ($row) use (&$groups) { |
|
1462 | + function($row) use (&$groups) { |
|
1463 | 1463 | $groups[$row['id_group']][$row['add_deny'] ? 'add' : 'deny'][] = $row['permission']; |
1464 | 1464 | } |
1465 | 1465 | ); |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | 'empty' => '', |
156 | 156 | ) |
157 | 157 | )->fetch_callback( |
158 | - function ($row) use (&$credits) { |
|
158 | + function($row) use (&$credits) { |
|
159 | 159 | global $txt; |
160 | 160 | |
161 | 161 | $credit_info = Util::unserialize($row['credits']); |
@@ -551,7 +551,7 @@ discard block |
||
551 | 551 | '<a href="https://github.com/googlefonts/noto-emoji">Noto Emoji</a> | © Googlefonts | Licensed under <a href="https://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>', |
552 | 552 | '<a href="https://openmoji.org">OpenMoji</a> | © OpenMoji | Licensed under <a href="https://creativecommons.org/licenses/by-sa/4.0/">Creative Commons Attribution-ShareAlike 4.0</a>', |
553 | 553 | '<a href="http://www.oxygen-icons.org/">Oxygen Icons</a> | These icons are licensed under <a href="https://creativecommons.org/licenses/by-sa/3.0/">CC BY-SA 3.0</a>', |
554 | - '<a href="https://github.com/twitter/twemoji">Twitter Emoji</a> | © Twitter, Inc and other contributors | Licensed under <a href="https://github.com/twitter/twemoji/blob/master/LICENSE/">MIT</a>', ), |
|
554 | + '<a href="https://github.com/twitter/twemoji">Twitter Emoji</a> | © Twitter, Inc and other contributors | Licensed under <a href="https://github.com/twitter/twemoji/blob/master/LICENSE/">MIT</a>',), |
|
555 | 555 | 'fonts' => array( |
556 | 556 | '<a href="http://openfontlibrary.org/en/font/architect-s-daughter">Architect\'s Daughter</a> | © 2010 <a href="http://kimberlygeswein.com/">Kimberly Geswein</a> | This font is licensed under the SIL Open Font License, Version 1.1', |
557 | 557 | '<a href="http://openfontlibrary.org/en/font/klaudia-and-berenika">Berenika</a> | © 2011 wmk69 | This font is licensed under the SIL Open Font License, Version 1.1', |