1 | <?php |
||||
2 | |||||
3 | namespace LumenWpApp; |
||||
4 | |||||
5 | use Illuminate\Contracts\Foundation\Application as FoundationApplication; |
||||
6 | use Illuminate\Cache\CacheServiceProvider; |
||||
7 | use Illuminate\Config\Repository as ConfigRepository; |
||||
8 | use Illuminate\Container\Container; |
||||
9 | use Illuminate\Contracts\Cache\Repository as CacheRepository; |
||||
10 | use Illuminate\Contracts\Cache\Factory as CacheFactory; |
||||
11 | use Illuminate\Contracts\Encryption\Encrypter; |
||||
12 | use Illuminate\Contracts\Events\Dispatcher; |
||||
13 | use Illuminate\Contracts\Filesystem\Cloud; |
||||
14 | use Illuminate\Contracts\Hashing\Hasher; |
||||
15 | use Illuminate\Contracts\Translation\Translator; |
||||
16 | use Illuminate\Contracts\Validation\Factory; |
||||
17 | use Illuminate\Encryption\EncryptionServiceProvider; |
||||
18 | use Illuminate\Events\EventServiceProvider; |
||||
19 | use Illuminate\Filesystem\Filesystem; |
||||
20 | use Illuminate\Filesystem\FilesystemServiceProvider; |
||||
21 | use Illuminate\Contracts\Container\Container as ContainerContainer; |
||||
22 | use Illuminate\Contracts\Filesystem\Factory as FilesystemFactory; |
||||
23 | use Illuminate\Contracts\Filesystem\Filesystem as FilesystemFilesystem; |
||||
24 | use Illuminate\Hashing\HashServiceProvider; |
||||
25 | use Illuminate\Log\LogManager; |
||||
26 | use Illuminate\Support\Composer; |
||||
27 | use Illuminate\Support\Facades\Facade; |
||||
28 | use Illuminate\Support\Facades\Cache; |
||||
29 | use Illuminate\Support\Facades\Event; |
||||
30 | use Illuminate\Support\Facades\Log; |
||||
31 | use Illuminate\Support\Facades\Storage; |
||||
32 | use Illuminate\Support\Facades\Validator; |
||||
33 | use Illuminate\Support\ServiceProvider; |
||||
34 | use Illuminate\Support\Str; |
||||
35 | use Illuminate\Translation\TranslationServiceProvider; |
||||
36 | use Illuminate\Validation\ValidationServiceProvider; |
||||
37 | use Psr\Log\LoggerInterface; |
||||
38 | use RuntimeException; |
||||
39 | |||||
40 | class Application extends Container |
||||
41 | { |
||||
42 | /** |
||||
43 | * Indicates if the class aliases have been registered. |
||||
44 | * |
||||
45 | * @var bool |
||||
46 | */ |
||||
47 | protected static $aliasesRegistered = false; |
||||
48 | |||||
49 | /** |
||||
50 | * The base path of the application installation. |
||||
51 | * |
||||
52 | * @var string |
||||
53 | */ |
||||
54 | protected $basePath; |
||||
55 | |||||
56 | /** |
||||
57 | * All of the loaded configuration files. |
||||
58 | * |
||||
59 | * @var array |
||||
60 | */ |
||||
61 | protected $loadedConfigurations = []; |
||||
62 | |||||
63 | /** |
||||
64 | * Indicates if the application has "booted". |
||||
65 | * |
||||
66 | * @var bool |
||||
67 | */ |
||||
68 | protected $booted = false; |
||||
69 | |||||
70 | /** |
||||
71 | * The loaded service providers. |
||||
72 | * |
||||
73 | * @var array |
||||
74 | */ |
||||
75 | protected $loadedProviders = []; |
||||
76 | |||||
77 | /** |
||||
78 | * The service binding methods that have been executed. |
||||
79 | * |
||||
80 | * @var array |
||||
81 | */ |
||||
82 | protected $ranServiceBinders = []; |
||||
83 | |||||
84 | /** |
||||
85 | * The custom storage path defined by the developer. |
||||
86 | * |
||||
87 | * @var string |
||||
88 | */ |
||||
89 | protected $storagePath; |
||||
90 | |||||
91 | /** |
||||
92 | * The application namespace. |
||||
93 | * |
||||
94 | * @var string |
||||
95 | */ |
||||
96 | protected $namespace; |
||||
97 | |||||
98 | /** |
||||
99 | * The Router instance. |
||||
100 | * |
||||
101 | * @var \Laravel\Lumen\Routing\Router |
||||
0 ignored issues
–
show
|
|||||
102 | */ |
||||
103 | public $router; |
||||
104 | |||||
105 | /** |
||||
106 | * Create a new Lumen application instance. |
||||
107 | * |
||||
108 | * @param string|null $basePath |
||||
109 | * @return void |
||||
110 | */ |
||||
111 | public function __construct($basePath = null) |
||||
112 | { |
||||
113 | if (! empty(env('APP_TIMEZONE'))) { |
||||
114 | date_default_timezone_set(env('APP_TIMEZONE', 'UTC')); |
||||
115 | } |
||||
116 | |||||
117 | $this->basePath = $basePath; |
||||
118 | |||||
119 | $this->bootstrapContainer(); |
||||
120 | } |
||||
121 | |||||
122 | /** |
||||
123 | * Bootstrap the application container. |
||||
124 | * |
||||
125 | * @return void |
||||
126 | */ |
||||
127 | protected function bootstrapContainer() |
||||
128 | { |
||||
129 | static::setInstance($this); |
||||
130 | |||||
131 | $this->instance('app', $this); |
||||
132 | $this->instance(self::class, $this); |
||||
133 | |||||
134 | $this->instance('path', $this->path()); |
||||
135 | |||||
136 | $this->instance('env', $this->environment()); |
||||
137 | |||||
138 | $this->registerContainerAliases(); |
||||
139 | } |
||||
140 | |||||
141 | /** |
||||
142 | * Register all of the configured providers. |
||||
143 | * |
||||
144 | * @return $this |
||||
145 | */ |
||||
146 | public function registerConfiguredProviders() |
||||
147 | { |
||||
148 | foreach ($this->config['app.providers'] as $provider) { |
||||
0 ignored issues
–
show
The property
config does not exist on LumenWpApp\Application . Since you implemented __get , consider adding a @property annotation.
![]() |
|||||
149 | $this->register($provider); |
||||
150 | } |
||||
151 | |||||
152 | return $this; |
||||
153 | } |
||||
154 | |||||
155 | /** |
||||
156 | * Get the version number of the application. |
||||
157 | * |
||||
158 | * @return string |
||||
159 | */ |
||||
160 | public function version() |
||||
161 | { |
||||
162 | return 'Lumen (8.0.1) (Laravel Components ^8.0)'; |
||||
163 | } |
||||
164 | |||||
165 | /** |
||||
166 | * Determine if the application is currently down for maintenance. |
||||
167 | * |
||||
168 | * @return bool |
||||
169 | */ |
||||
170 | public function isDownForMaintenance() |
||||
171 | { |
||||
172 | return false; |
||||
173 | } |
||||
174 | |||||
175 | /** |
||||
176 | * Get or check the current application environment. |
||||
177 | * |
||||
178 | * @param mixed |
||||
179 | * @return string |
||||
180 | */ |
||||
181 | public function environment() |
||||
182 | { |
||||
183 | $env = env('WP_ENV', config('app.env', 'production')); |
||||
184 | |||||
185 | if (func_num_args() > 0) { |
||||
186 | $patterns = is_array(func_get_arg(0)) ? func_get_arg(0) : func_get_args(); |
||||
187 | |||||
188 | foreach ($patterns as $pattern) { |
||||
189 | if (Str::is($pattern, $env)) { |
||||
190 | return true; |
||||
191 | } |
||||
192 | } |
||||
193 | |||||
194 | return false; |
||||
195 | } |
||||
196 | |||||
197 | return $env; |
||||
198 | } |
||||
199 | |||||
200 | /** |
||||
201 | * Determine if the given service provider is loaded. |
||||
202 | * |
||||
203 | * @param string $provider |
||||
204 | * @return bool |
||||
205 | */ |
||||
206 | public function providerIsLoaded(string $provider) |
||||
207 | { |
||||
208 | return isset($this->loadedProviders[$provider]); |
||||
209 | } |
||||
210 | |||||
211 | /** |
||||
212 | * Register a service provider with the application. |
||||
213 | * |
||||
214 | * @param \Illuminate\Support\ServiceProvider|string $provider |
||||
215 | * @return void |
||||
216 | */ |
||||
217 | public function register($provider) |
||||
218 | { |
||||
219 | if (! $provider instanceof ServiceProvider) { |
||||
220 | $provider = new $provider($this); |
||||
221 | } |
||||
222 | |||||
223 | if (array_key_exists($providerName = get_class($provider), $this->loadedProviders)) { |
||||
224 | return; |
||||
225 | } |
||||
226 | |||||
227 | $this->loadedProviders[$providerName] = $provider; |
||||
228 | |||||
229 | if (method_exists($provider, 'register')) { |
||||
230 | $provider->register(); |
||||
231 | } |
||||
232 | |||||
233 | if ($this->booted) { |
||||
234 | $this->bootProvider($provider); |
||||
235 | } |
||||
236 | } |
||||
237 | |||||
238 | /** |
||||
239 | * Register a deferred provider and service. |
||||
240 | * |
||||
241 | * @param string $provider |
||||
242 | * @return void |
||||
243 | */ |
||||
244 | public function registerDeferredProvider($provider) |
||||
245 | { |
||||
246 | $this->register($provider); |
||||
247 | } |
||||
248 | |||||
249 | /** |
||||
250 | * Boots the registered providers. |
||||
251 | */ |
||||
252 | public function boot() |
||||
253 | { |
||||
254 | if ($this->booted) { |
||||
255 | return; |
||||
256 | } |
||||
257 | |||||
258 | foreach ($this->loadedProviders as $provider) { |
||||
259 | $this->bootProvider($provider); |
||||
260 | } |
||||
261 | |||||
262 | $this->booted = true; |
||||
263 | } |
||||
264 | |||||
265 | /** |
||||
266 | * Boot the given service provider. |
||||
267 | * |
||||
268 | * @param \Illuminate\Support\ServiceProvider $provider |
||||
269 | * @return mixed |
||||
270 | */ |
||||
271 | protected function bootProvider(ServiceProvider $provider) |
||||
272 | { |
||||
273 | if (method_exists($provider, 'boot')) { |
||||
274 | return $this->call([$provider, 'boot']); |
||||
275 | } |
||||
276 | } |
||||
277 | |||||
278 | /** |
||||
279 | * Resolve the given type from the container. |
||||
280 | * |
||||
281 | * @param string $abstract |
||||
282 | * @param array $parameters |
||||
283 | * @return mixed |
||||
284 | */ |
||||
285 | public function make($abstract, array $parameters = []) |
||||
286 | { |
||||
287 | $abstract = $this->getAlias($abstract); |
||||
288 | |||||
289 | if (! $this->bound($abstract) && |
||||
290 | array_key_exists($abstract, $this->availableBindings) && |
||||
291 | ! array_key_exists($this->availableBindings[$abstract], $this->ranServiceBinders)) { |
||||
292 | $this->{$method = $this->availableBindings[$abstract]}(); |
||||
293 | |||||
294 | $this->ranServiceBinders[$method] = true; |
||||
295 | } |
||||
296 | |||||
297 | return parent::make($abstract, $parameters); |
||||
298 | } |
||||
299 | |||||
300 | /** |
||||
301 | * Register container bindings for the application. |
||||
302 | * |
||||
303 | * @return void |
||||
304 | */ |
||||
305 | protected function registerCacheBindings() |
||||
306 | { |
||||
307 | $this->singleton('cache', function () { |
||||
308 | return $this->loadComponent('cache', CacheServiceProvider::class); |
||||
309 | }); |
||||
310 | $this->singleton('cache.store', function () { |
||||
311 | return $this->loadComponent('cache', CacheServiceProvider::class, 'cache.store'); |
||||
312 | }); |
||||
313 | } |
||||
314 | |||||
315 | /** |
||||
316 | * Register container bindings for the application. |
||||
317 | * |
||||
318 | * @return void |
||||
319 | */ |
||||
320 | protected function registerComposerBindings() |
||||
321 | { |
||||
322 | $this->singleton('composer', function ($app) { |
||||
323 | return new Composer($app->make('files'), $this->basePath()); |
||||
324 | }); |
||||
325 | } |
||||
326 | |||||
327 | /** |
||||
328 | * Register container bindings for the application. |
||||
329 | * |
||||
330 | * @return void |
||||
331 | */ |
||||
332 | protected function registerConfigBindings() |
||||
333 | { |
||||
334 | $this->singleton('config', function () { |
||||
335 | return new ConfigRepository; |
||||
336 | }); |
||||
337 | } |
||||
338 | |||||
339 | /** |
||||
340 | * Register container bindings for the application. |
||||
341 | * |
||||
342 | * @return void |
||||
343 | */ |
||||
344 | protected function registerEncrypterBindings() |
||||
345 | { |
||||
346 | $this->singleton('encrypter', function () { |
||||
347 | return $this->loadComponent('app', EncryptionServiceProvider::class, 'encrypter'); |
||||
348 | }); |
||||
349 | } |
||||
350 | |||||
351 | /** |
||||
352 | * Register container bindings for the application. |
||||
353 | * |
||||
354 | * @return void |
||||
355 | */ |
||||
356 | protected function registerFilesBindings() |
||||
357 | { |
||||
358 | $this->singleton('files', function () { |
||||
359 | return new Filesystem; |
||||
360 | }); |
||||
361 | } |
||||
362 | |||||
363 | /** |
||||
364 | * Register container bindings for the application. |
||||
365 | * |
||||
366 | * @return void |
||||
367 | */ |
||||
368 | protected function registerFilesystemBindings() |
||||
369 | { |
||||
370 | $this->singleton('filesystem', function () { |
||||
371 | return $this->loadComponent('filesystems', FilesystemServiceProvider::class, 'filesystem'); |
||||
372 | }); |
||||
373 | $this->singleton('filesystem.disk', function () { |
||||
374 | return $this->loadComponent('filesystems', FilesystemServiceProvider::class, 'filesystem.disk'); |
||||
375 | }); |
||||
376 | $this->singleton('filesystem.cloud', function () { |
||||
377 | return $this->loadComponent('filesystems', FilesystemServiceProvider::class, 'filesystem.cloud'); |
||||
378 | }); |
||||
379 | } |
||||
380 | |||||
381 | /** |
||||
382 | * Register container bindings for the application. |
||||
383 | * |
||||
384 | * @return void |
||||
385 | */ |
||||
386 | protected function registerHashBindings() |
||||
387 | { |
||||
388 | $this->singleton('hash', function () { |
||||
389 | $this->register(HashServiceProvider::class); |
||||
390 | |||||
391 | return $this->make('hash'); |
||||
392 | }); |
||||
393 | } |
||||
394 | |||||
395 | /** |
||||
396 | * Register container bindings for the application. |
||||
397 | * |
||||
398 | * @return void |
||||
399 | */ |
||||
400 | protected function registerLogBindings() |
||||
401 | { |
||||
402 | $this->singleton(LoggerInterface::class, function () { |
||||
403 | $this->configure('logging'); |
||||
404 | |||||
405 | return new LogManager($this); |
||||
0 ignored issues
–
show
$this of type LumenWpApp\Application is incompatible with the type Illuminate\Contracts\Foundation\Application expected by parameter $app of Illuminate\Log\LogManager::__construct() .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
406 | }); |
||||
407 | } |
||||
408 | |||||
409 | /** |
||||
410 | * Register container bindings for the application. |
||||
411 | * |
||||
412 | * @return void |
||||
413 | */ |
||||
414 | protected function registerEventBindings() |
||||
415 | { |
||||
416 | $this->singleton('events', function () { |
||||
417 | $this->register(EventServiceProvider::class); |
||||
418 | return $this->make('events'); |
||||
419 | }); |
||||
420 | } |
||||
421 | |||||
422 | /** |
||||
423 | * Register container bindings for the application. |
||||
424 | * |
||||
425 | * @return void |
||||
426 | */ |
||||
427 | protected function registerTranslationBindings() |
||||
428 | { |
||||
429 | $this->singleton('translator', function () { |
||||
430 | $this->configure('app'); |
||||
431 | |||||
432 | $this->instance('path.lang', $this->getLanguagePath()); |
||||
433 | |||||
434 | $this->register(TranslationServiceProvider::class); |
||||
435 | |||||
436 | return $this->make('translator'); |
||||
437 | }); |
||||
438 | } |
||||
439 | |||||
440 | /** |
||||
441 | * Get the path to the application's language files. |
||||
442 | * |
||||
443 | * @return string |
||||
444 | */ |
||||
445 | protected function getLanguagePath() |
||||
446 | { |
||||
447 | if (is_dir($langPath = $this->basePath().'/resources/lang')) { |
||||
448 | return $langPath; |
||||
449 | } else { |
||||
450 | return __DIR__.'/../resources/lang'; |
||||
451 | } |
||||
452 | } |
||||
453 | |||||
454 | /** |
||||
455 | * Register container bindings for the application. |
||||
456 | * |
||||
457 | * @return void |
||||
458 | */ |
||||
459 | protected function registerValidatorBindings() |
||||
460 | { |
||||
461 | $this->singleton('validator', function () { |
||||
462 | $this->register(ValidationServiceProvider::class); |
||||
463 | |||||
464 | return $this->make('validator'); |
||||
465 | }); |
||||
466 | } |
||||
467 | |||||
468 | /** |
||||
469 | * Configure and load the given component and provider. |
||||
470 | * |
||||
471 | * @param string $config |
||||
472 | * @param array|string $providers |
||||
473 | * @param string|null $return |
||||
474 | * @return mixed |
||||
475 | */ |
||||
476 | public function loadComponent($config, $providers, $return = null) |
||||
477 | { |
||||
478 | $this->configure($config); |
||||
479 | |||||
480 | foreach ((array) $providers as $provider) { |
||||
481 | $this->register($provider); |
||||
482 | } |
||||
483 | |||||
484 | return $this->make($return ?: $config); |
||||
485 | } |
||||
486 | |||||
487 | /** |
||||
488 | * Load a configuration file into the application. |
||||
489 | * |
||||
490 | * @param string $name |
||||
491 | * @return void |
||||
492 | */ |
||||
493 | public function configure($name) |
||||
494 | { |
||||
495 | if (isset($this->loadedConfigurations[$name])) { |
||||
496 | return; |
||||
497 | } |
||||
498 | |||||
499 | $this->loadedConfigurations[$name] = true; |
||||
500 | |||||
501 | $path = $this->getConfigurationPath($name); |
||||
502 | |||||
503 | if ($path) { |
||||
504 | $this->make('config')->set($name, require $path); |
||||
505 | } |
||||
506 | } |
||||
507 | |||||
508 | /** |
||||
509 | * Get the path to the given configuration file. |
||||
510 | * |
||||
511 | * If no name is provided, then we'll return the path to the config folder. |
||||
512 | * |
||||
513 | * @param string|null $name |
||||
514 | * @return string |
||||
515 | */ |
||||
516 | public function getConfigurationPath($name = null) |
||||
517 | { |
||||
518 | if (! $name) { |
||||
519 | $appConfigDir = $this->basePath('config').'/'; |
||||
520 | |||||
521 | if (file_exists($appConfigDir)) { |
||||
522 | return $appConfigDir; |
||||
523 | } elseif (file_exists($path = __DIR__.'/../config/')) { |
||||
524 | return $path; |
||||
525 | } |
||||
526 | } else { |
||||
527 | $appConfigPath = $this->basePath('config').'/'.$name.'.php'; |
||||
528 | |||||
529 | if (file_exists($appConfigPath)) { |
||||
530 | return $appConfigPath; |
||||
531 | } elseif (file_exists($path = __DIR__.'/../config/'.$name.'.php')) { |
||||
532 | return $path; |
||||
533 | } |
||||
534 | } |
||||
535 | } |
||||
536 | |||||
537 | /** |
||||
538 | * Register the facades for the application. |
||||
539 | * |
||||
540 | * @param bool $aliases |
||||
541 | * @param array $userAliases |
||||
542 | * @return void |
||||
543 | */ |
||||
544 | public function withFacades($aliases = true, $userAliases = []) |
||||
545 | { |
||||
546 | Facade::setFacadeApplication($this); |
||||
0 ignored issues
–
show
$this of type LumenWpApp\Application is incompatible with the type Illuminate\Contracts\Foundation\Application expected by parameter $app of Illuminate\Support\Facad...:setFacadeApplication() .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
547 | |||||
548 | if ($aliases) { |
||||
549 | $this->withAliases($userAliases); |
||||
550 | } |
||||
551 | } |
||||
552 | |||||
553 | /** |
||||
554 | * Register the aliases for the application. |
||||
555 | * |
||||
556 | * @param array $userAliases |
||||
557 | * @return void |
||||
558 | */ |
||||
559 | public function withAliases($userAliases = []) |
||||
560 | { |
||||
561 | $defaults = [ |
||||
562 | Cache::class => 'Cache', |
||||
563 | Event::class => 'Event', |
||||
564 | Log::class => 'Log', |
||||
565 | Storage::class => 'Storage', |
||||
566 | Validator::class => 'Validator', |
||||
567 | ]; |
||||
568 | |||||
569 | if (! static::$aliasesRegistered) { |
||||
570 | static::$aliasesRegistered = true; |
||||
571 | |||||
572 | $merged = array_merge($defaults, $userAliases); |
||||
573 | |||||
574 | foreach ($merged as $original => $alias) { |
||||
575 | class_alias($original, $alias); |
||||
576 | } |
||||
577 | } |
||||
578 | } |
||||
579 | |||||
580 | /** |
||||
581 | * Get the path to the application "app" directory. |
||||
582 | * |
||||
583 | * @return string |
||||
584 | */ |
||||
585 | public function path() |
||||
586 | { |
||||
587 | return $this->basePath.DIRECTORY_SEPARATOR.'app'; |
||||
588 | } |
||||
589 | |||||
590 | /** |
||||
591 | * Get the base path for the application. |
||||
592 | * |
||||
593 | * @param string|null $path |
||||
594 | * @return string |
||||
595 | */ |
||||
596 | public function basePath($path = null) |
||||
597 | { |
||||
598 | if (isset($this->basePath)) { |
||||
599 | return $this->basePath.($path ? '/'.$path : $path); |
||||
600 | } |
||||
601 | |||||
602 | if ($this->runningInConsole()) { |
||||
603 | $this->basePath = getcwd(); |
||||
604 | } else { |
||||
605 | $this->basePath = realpath(getcwd().'/../'); |
||||
606 | } |
||||
607 | |||||
608 | return $this->basePath($path); |
||||
609 | } |
||||
610 | |||||
611 | /** |
||||
612 | * Get the path to the application configuration files. |
||||
613 | * |
||||
614 | * @param string $path |
||||
615 | * @return string |
||||
616 | */ |
||||
617 | public function configPath($path = '') |
||||
618 | { |
||||
619 | return $this->basePath.DIRECTORY_SEPARATOR.'config'.($path ? DIRECTORY_SEPARATOR.$path : $path); |
||||
620 | } |
||||
621 | |||||
622 | /** |
||||
623 | * Get the path to the database directory. |
||||
624 | * |
||||
625 | * @param string $path |
||||
626 | * @return string |
||||
627 | */ |
||||
628 | public function databasePath($path = '') |
||||
629 | { |
||||
630 | return $this->basePath.DIRECTORY_SEPARATOR.'database'.($path ? DIRECTORY_SEPARATOR.$path : $path); |
||||
631 | } |
||||
632 | |||||
633 | /** |
||||
634 | * Get the storage path for the application. |
||||
635 | * |
||||
636 | * @param string|null $path |
||||
637 | * @return string |
||||
638 | */ |
||||
639 | public function storagePath($path = '') |
||||
640 | { |
||||
641 | return ($this->storagePath ?: $this->basePath.DIRECTORY_SEPARATOR.'storage').($path ? DIRECTORY_SEPARATOR.$path : $path); |
||||
642 | } |
||||
643 | |||||
644 | /** |
||||
645 | * Set the storage directory. |
||||
646 | * |
||||
647 | * @param string $path |
||||
648 | * @return $this |
||||
649 | */ |
||||
650 | public function useStoragePath($path) |
||||
651 | { |
||||
652 | $this->storagePath = $path; |
||||
653 | |||||
654 | $this->instance('path.storage', $path); |
||||
655 | |||||
656 | return $this; |
||||
657 | } |
||||
658 | |||||
659 | /** |
||||
660 | * Get the path to the resources directory. |
||||
661 | * |
||||
662 | * @param string|null $path |
||||
663 | * @return string |
||||
664 | */ |
||||
665 | public function resourcePath($path = '') |
||||
666 | { |
||||
667 | return $this->basePath.DIRECTORY_SEPARATOR.'resources'.($path ? DIRECTORY_SEPARATOR.$path : $path); |
||||
668 | } |
||||
669 | /** |
||||
670 | * Determine if the application configuration is cached. |
||||
671 | * |
||||
672 | * @return bool |
||||
673 | */ |
||||
674 | public function configurationIsCached() |
||||
675 | { |
||||
676 | return false; |
||||
677 | } |
||||
678 | |||||
679 | /** |
||||
680 | * Determine if the application is running in the console. |
||||
681 | * |
||||
682 | * @return bool |
||||
683 | */ |
||||
684 | public function runningInConsole() |
||||
685 | { |
||||
686 | return \PHP_SAPI === 'cli' || \PHP_SAPI === 'phpdbg'; |
||||
687 | } |
||||
688 | |||||
689 | /** |
||||
690 | * Determine if we are running unit tests. |
||||
691 | * |
||||
692 | * @return bool |
||||
693 | */ |
||||
694 | public function runningUnitTests() |
||||
695 | { |
||||
696 | return $this->environment() == 'testing'; |
||||
697 | } |
||||
698 | |||||
699 | /** |
||||
700 | * Determine if the application events are cached. |
||||
701 | * |
||||
702 | * @return bool |
||||
703 | */ |
||||
704 | public function eventsAreCached() |
||||
705 | { |
||||
706 | return false; |
||||
707 | } |
||||
708 | |||||
709 | /** |
||||
710 | * Get the application namespace. |
||||
711 | * |
||||
712 | * @return string |
||||
713 | * |
||||
714 | * @throws \RuntimeException |
||||
715 | */ |
||||
716 | public function getNamespace() |
||||
717 | { |
||||
718 | if (! is_null($this->namespace)) { |
||||
0 ignored issues
–
show
|
|||||
719 | return $this->namespace; |
||||
720 | } |
||||
721 | |||||
722 | $composer = json_decode(file_get_contents(base_path('composer.json')), true); |
||||
723 | |||||
724 | foreach ((array) data_get($composer, 'autoload.psr-4') as $namespace => $path) { |
||||
725 | foreach ((array) $path as $pathChoice) { |
||||
726 | if (realpath(app()->path()) == realpath(base_path().'/'.$pathChoice)) { |
||||
727 | return $this->namespace = $namespace; |
||||
728 | } |
||||
729 | } |
||||
730 | } |
||||
731 | |||||
732 | throw new RuntimeException('Unable to detect application namespace.'); |
||||
733 | } |
||||
734 | |||||
735 | /** |
||||
736 | * Flush the container of all bindings and resolved instances. |
||||
737 | * |
||||
738 | * @return void |
||||
739 | */ |
||||
740 | public function flush() |
||||
741 | { |
||||
742 | parent::flush(); |
||||
743 | |||||
744 | $this->loadedProviders = []; |
||||
745 | $this->reboundCallbacks = []; |
||||
746 | $this->resolvingCallbacks = []; |
||||
747 | $this->availableBindings = []; |
||||
748 | $this->ranServiceBinders = []; |
||||
749 | $this->loadedConfigurations = []; |
||||
750 | $this->afterResolvingCallbacks = []; |
||||
751 | |||||
752 | $this->router = null; |
||||
753 | $this->dispatcher = null; |
||||
0 ignored issues
–
show
|
|||||
754 | static::$instance = null; |
||||
755 | } |
||||
756 | |||||
757 | /** |
||||
758 | * Get the current application locale. |
||||
759 | * |
||||
760 | * @return string |
||||
761 | */ |
||||
762 | public function getLocale() |
||||
763 | { |
||||
764 | return $this['config']->get('app.locale'); |
||||
765 | } |
||||
766 | |||||
767 | /** |
||||
768 | * Set the current application locale. |
||||
769 | * |
||||
770 | * @param string $locale |
||||
771 | * @return void |
||||
772 | */ |
||||
773 | public function setLocale($locale) |
||||
774 | { |
||||
775 | $this['config']->set('app.locale', $locale); |
||||
776 | $this['translator']->setLocale($locale); |
||||
777 | } |
||||
778 | |||||
779 | /** |
||||
780 | * Determine if application locale is the given locale. |
||||
781 | * |
||||
782 | * @param string $locale |
||||
783 | * @return bool |
||||
784 | */ |
||||
785 | public function isLocale($locale) |
||||
786 | { |
||||
787 | return $this->getLocale() == $locale; |
||||
788 | } |
||||
789 | |||||
790 | /** |
||||
791 | * Register the core container aliases. |
||||
792 | * |
||||
793 | * @return void |
||||
794 | */ |
||||
795 | protected function registerContainerAliases() |
||||
796 | { |
||||
797 | $this->aliases = [ |
||||
798 | FoundationApplication::class => 'app', |
||||
799 | CacheFactory::class => 'cache', |
||||
800 | CacheRepository::class => 'cache.store', |
||||
801 | ConfigRepository::class => 'config', |
||||
802 | Container::class => 'app', |
||||
803 | ContainerContainer::class => 'app', |
||||
804 | Dispatcher::class => 'events', |
||||
805 | FilesystemFactory::class => 'filesystem', |
||||
806 | FilesystemFilesystem::class => 'filesystem.disk', |
||||
807 | Cloud::class => 'filesystem.cloud', |
||||
808 | Hasher::class => 'hash', |
||||
809 | 'log' => LoggerInterface::class, |
||||
810 | Translator::class => 'translator', |
||||
811 | Factory::class => 'validator', |
||||
812 | ]; |
||||
813 | } |
||||
814 | |||||
815 | /** |
||||
816 | * The available container bindings and their respective load methods. |
||||
817 | * |
||||
818 | * @var array |
||||
819 | */ |
||||
820 | public $availableBindings = [ |
||||
821 | 'composer' => 'registerComposerBindings', |
||||
822 | 'cache' => 'registerCacheBindings', |
||||
823 | 'cache.store' => 'registerCacheBindings', |
||||
824 | CacheFactory::class => 'registerCacheBindings', |
||||
825 | CacheRepository::class => 'registerCacheBindings', |
||||
826 | 'config' => 'registerConfigBindings', |
||||
827 | 'filesystem' => 'registerFilesystemBindings', |
||||
828 | 'filesystem.cloud' => 'registerFilesystemBindings', |
||||
829 | 'filesystem.disk' => 'registerFilesystemBindings', |
||||
830 | Cloud::class => 'registerFilesystemBindings', |
||||
831 | FilesystemFilesystem::class => 'registerFilesystemBindings', |
||||
832 | FilesystemFactory::class => 'registerFilesystemBindings', |
||||
833 | 'files' => 'registerFilesBindings', |
||||
834 | 'events' => 'registerEventBindings', |
||||
835 | Dispatcher::class => 'registerEventBindings', |
||||
836 | 'log' => 'registerLogBindings', |
||||
837 | LoggerInterface::class => 'registerLogBindings', |
||||
838 | 'translator' => 'registerTranslationBindings', |
||||
839 | 'encrypter' => 'registerEncrypterBindings', |
||||
840 | Encrypter::class => 'registerEncrypterBindings', |
||||
841 | 'hash' => 'registerHashBindings', |
||||
842 | Hasher::class => 'registerHashBindings', |
||||
843 | 'validator' => 'registerValidatorBindings', |
||||
844 | Factory::class => 'registerValidatorBindings', |
||||
845 | ]; |
||||
846 | } |
||||
847 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths