1 | <?php |
||
2 | |||
0 ignored issues
–
show
Coding Style
introduced
by
![]() |
|||
3 | namespace Hhxsv5\LaravelS\Illuminate\Cleaners; |
||
4 | |||
5 | |||
6 | use Illuminate\Container\Container; |
||
0 ignored issues
–
show
The type
Illuminate\Container\Container was not found. Maybe you did not declare it correctly or list all dependencies?
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. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||
7 | |||
8 | class ContainerCleaner extends BaseCleaner |
||
0 ignored issues
–
show
|
|||
9 | { |
||
10 | private $properties = [ |
||
0 ignored issues
–
show
|
|||
11 | // Property => Initial value |
||
12 | 'reboundCallbacks' => [], |
||
13 | 'currentRoute' => [], // For Lumen: fixed wrong $request->route() |
||
14 | ]; |
||
15 | |||
16 | private $cleanProperties = [ |
||
0 ignored issues
–
show
|
|||
17 | // Property => ReflectionObject |
||
18 | ]; |
||
19 | |||
20 | public function __construct(Container $currentApp, Container $snapshotApp) |
||
0 ignored issues
–
show
|
|||
21 | { |
||
22 | parent::__construct($currentApp, $snapshotApp); |
||
23 | $currentReflection = new \ReflectionObject($this->currentApp); |
||
24 | $defaultValues = $currentReflection->getDefaultProperties(); |
||
25 | foreach ($this->properties as $property => &$initValue) { |
||
26 | if ($currentReflection->hasProperty($property)) { |
||
27 | $this->cleanProperties[$property] = $currentReflection->getProperty($property); |
||
28 | $this->cleanProperties[$property]->setAccessible(true); |
||
29 | $initValue = $defaultValues[$property]; |
||
30 | } |
||
31 | } |
||
32 | unset($initValue); |
||
33 | } |
||
34 | |||
35 | public function clean() |
||
0 ignored issues
–
show
|
|||
36 | { |
||
37 | foreach ($this->cleanProperties as $property => $reflection) { |
||
38 | $reflection->setValue($this->currentApp, $this->properties[$property]); |
||
39 | } |
||
40 | } |
||
41 | } |