ReflectionApp::instances()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 4
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 7
rs 10
1
<?php
2
0 ignored issues
show
Coding Style introduced by
Missing file doc comment
Loading history...
3
namespace Hhxsv5\LaravelS\Illuminate;
4
5
use Illuminate\Container\Container;
0 ignored issues
show
Bug introduced by
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. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
6
use Symfony\Component\HttpFoundation\Response;
0 ignored issues
show
Bug introduced by
The type Symfony\Component\HttpFoundation\Response 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. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
7
8
class ReflectionApp
0 ignored issues
show
Coding Style introduced by
Missing doc comment for class ReflectionApp
Loading history...
9
{
10
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
11
     * @var Container
12
     */
13
    protected $app;
14
15
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
16
     * @var \ReflectionObject
17
     */
18
    protected $reflectionApp;
19
20
    /**
21
     * ReflectionApp constructor.
22
     *
23
     * @param Container $app
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
24
     */
25
    public function __construct(Container $app)
26
    {
27
        $this->app = $app;
28
29
        $this->reflectionApp = new \ReflectionObject($app);
30
    }
31
32
    /**
33
     * Get all bindings from application container.
34
     *
35
     * @return array
36
     * @throws \ReflectionException
37
     */
38
    public function instances()
39
    {
40
        $instances = $this->reflectionApp->getProperty('instances');
41
        $instances->setAccessible(true);
42
        $instances = array_merge($this->app->getBindings(), $instances->getValue($this->app));
43
44
        return $instances;
45
    }
46
47
    /**
48
     * Call terminable middleware of Lumen.
49
     *
50
     * @param Response $response
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Tag value for @param tag indented incorrectly; expected 2 spaces but found 1
Loading history...
51
     * @throws \ReflectionException
0 ignored issues
show
Coding Style introduced by
Tag @throws cannot be grouped with parameter tags in a doc comment
Loading history...
52
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
53
    public function callTerminableMiddleware(Response $response)
54
    {
55
        $middleware = $this->reflectionApp->getProperty('middleware');
56
        $middleware->setAccessible(true);
57
58
        if (!empty($middleware->getValue($this->app))) {
59
            $callTerminableMiddleware = $this->reflectionApp->getMethod('callTerminableMiddleware');
60
            $callTerminableMiddleware->setAccessible(true);
61
            $callTerminableMiddleware->invoke($this->app, $response);
62
        }
63
    }
64
65
    /**
66
     * The parameter count of 'register' method in app container.
67
     *
68
     * @return int
69
     * @throws \ReflectionException
70
     */
71
    public function registerMethodParameterCount()
72
    {
73
        return $this->reflectionApp->getMethod('register')->getNumberOfParameters();
74
    }
75
76
    /**
77
     * Get 'loadedProviders' of application container.
78
     *
79
     * @return array
80
     * @throws \ReflectionException
81
     */
82
    public function loadedProviders()
83
    {
84
        $loadedProviders = $this->reflectLoadedProviders();
85
        return $loadedProviders->getValue($this->app);
86
    }
87
88
    /**
89
     * Set 'loadedProviders' of application container.
90
     *
91
     * @param array $loadedProviders
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Tag value for @param tag indented incorrectly; expected 2 spaces but found 1
Loading history...
92
     * @throws \ReflectionException
0 ignored issues
show
Coding Style introduced by
Tag @throws cannot be grouped with parameter tags in a doc comment
Loading history...
93
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
94
    public function setLoadedProviders(array $loadedProviders)
95
    {
96
        $reflectLoadedProviders = $this->reflectLoadedProviders();
97
        $reflectLoadedProviders->setValue($this->app, $loadedProviders);
98
    }
99
100
    /**
101
     * Get the reflect loadedProviders of application container.
102
     *
103
     * @return \ReflectionProperty
104
     * @throws \ReflectionException
105
     */
106
    protected function reflectLoadedProviders()
107
    {
108
        $loadedProviders = $this->reflectionApp->getProperty('loadedProviders');
109
        $loadedProviders->setAccessible(true);
110
        return $loadedProviders;
111
    }
112
}
113