Passed
Push — feature/0.7.0 ( 75a66b...cbd99f )
by Ryuichi
43:15
created

AnnotationDelegator::readService()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 34
Code Lines 22

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 22
nc 1
nop 2
dl 0
loc 34
rs 8.8571
c 0
b 0
f 0
1
<?php
2
namespace WebStream\Delegate;
3
4
use WebStream\Core\CoreInterface;
5
use WebStream\Core\CoreController;
6
use WebStream\Core\CoreService;
7
use WebStream\Core\CoreModel;
8
use WebStream\Core\CoreView;
9
use WebStream\Core\CoreHelper;
10
use WebStream\Container\Container;
11
use WebStream\Annotation\Attributes\Alias;
12
use WebStream\Annotation\Attributes\Database;
13
use WebStream\Annotation\Attributes\ExceptionHandler;
14
use WebStream\Annotation\Attributes\Filter;
15
use WebStream\Annotation\Attributes\Header;
16
use WebStream\Annotation\Attributes\Query;
17
use WebStream\Annotation\Attributes\Template;
18
use WebStream\Annotation\Base\IAnnotatable;
19
use WebStream\Annotation\Reader\AnnotationReader;
20
use WebStream\Annotation\Reader\Extend\FilterExtendReader;
21
use WebStream\Annotation\Reader\Extend\QueryExtendReader;
22
use WebStream\Annotation\Container\AnnotationContainer;
23
use WebStream\Template\Basic;
24
use WebStream\Template\Twig;
25
26
/**
27
 * AnnotationDelegator
28
 * @author Ryuichi TANAKA.
29
 * @since 2015/02/11
30
 * @version 0.4
31
 */
32
class AnnotationDelegator
33
{
34
    /**
35
     * @var Container コンテナ
36
     */
37
    private $container;
38
39
    /**
40
     * @var Logger ロガー
0 ignored issues
show
Bug introduced by
The type WebStream\Delegate\Logger 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...
41
     */
42
    private $logger;
43
44
    /**
45
     * Constructor
46
     * @param CoreInterface インスタンス
47
     * @param Container DIContainer
48
     */
0 ignored issues
show
Documentation Bug introduced by
The doc comment インスタンス at position 0 could not be parsed: Unknown type name 'インスタンス' at position 0 in インスタンス.
Loading history...
49
    public function __construct(Container $container)
50
    {
51
        $this->container = $container;
52
        $this->logger = $container->logger;
0 ignored issues
show
Documentation Bug introduced by
It seems like $container->logger can also be of type string. However, the property $logger is declared as type WebStream\Delegate\Logger. Maybe add an additional type check?

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 mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
Bug Best Practice introduced by
The property logger does not exist on WebStream\Container\Container. Since you implemented __get, consider adding a @property annotation.
Loading history...
53
    }
54
55
    /**
56
     * Destructor
57
     */
58
    public function __destruct()
59
    {
60
        $this->logger->debug("AnnotationDelegator container is clear.");
61
    }
62
63
    /**
64
     * アノテーション情報をロードする
65
     * @param object インスタンス
66
     * @param string メソッド
67
     * @param string アノテーションクラスパス
68
     * @return Container コンテナ
69
     */
0 ignored issues
show
Documentation Bug introduced by
The doc comment インスタンス at position 0 could not be parsed: Unknown type name 'インスタンス' at position 0 in インスタンス.
Loading history...
70
    public function read($instance, $method = null, $classpath = null)
71
    {
72
        if (!$instance instanceof IAnnotatable) {
73
            $this->logger->warn("Annotation is not available this class: " . get_class($instance));
74
            return;
75
        }
76
77
        $this->container->executeMethod = $method ?: "";
0 ignored issues
show
Bug Best Practice introduced by
The property executeMethod does not exist on WebStream\Container\Container. Since you implemented __set, consider adding a @property annotation.
Loading history...
78
79
        if ($instance instanceof CoreController) {
80
            return $this->readController($instance, $classpath);
81
        } elseif ($instance instanceof CoreService) {
82
            return $this->readService($instance, $classpath);
83
        } elseif ($instance instanceof CoreModel) {
84
            return $this->readModel($instance, $classpath);
85
        } elseif ($instance instanceof CoreView) {
86
            return $this->readView($instance, $classpath);
87
        } elseif ($instance instanceof CoreHelper) {
88
            return $this->readHelper($instance, $classpath);
89
        } else {
90
            return $this->readModule($instance, $classpath);
91
        }
92
    }
93
94
    /**
95
     * Controllerのアノテーション情報をロードする
96
     * @param CoreController インスタンス
97
     * @param string アノテーションクラスパス
98
     * @return Container コンテナ
99
     */
0 ignored issues
show
Documentation Bug introduced by
The doc comment インスタンス at position 0 could not be parsed: Unknown type name 'インスタンス' at position 0 in インスタンス.
Loading history...
100
    private function readController(CoreController $instance, $classpath)
0 ignored issues
show
Unused Code introduced by
The parameter $classpath is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

100
    private function readController(CoreController $instance, /** @scrutinizer ignore-unused */ $classpath)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
101
    {
102
        $reader = new AnnotationReader($instance);
103
        $reader->setActionMethod($this->container->executeMethod);
0 ignored issues
show
Bug introduced by
It seems like $this->container->executeMethod can also be of type null; however, parameter $actionMethod of WebStream\Annotation\Rea...ader::setActionMethod() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

103
        $reader->setActionMethod(/** @scrutinizer ignore-type */ $this->container->executeMethod);
Loading history...
Bug Best Practice introduced by
The property executeMethod does not exist on WebStream\Container\Container. Since you implemented __get, consider adding a @property annotation.
Loading history...
104
105
        // @Header
106
        $container = new Container();
107
        $container->requestMethod = $this->container->request->requestMethod;
0 ignored issues
show
Bug Best Practice introduced by
The property requestMethod does not exist on WebStream\Container\Container. Since you implemented __set, consider adding a @property annotation.
Loading history...
Bug Best Practice introduced by
The property request does not exist on WebStream\Container\Container. Since you implemented __get, consider adding a @property annotation.
Loading history...
Bug introduced by
The property requestMethod does not exist on string.
Loading history...
108
        $container->contentType = 'html';
0 ignored issues
show
Bug Best Practice introduced by
The property contentType does not exist on WebStream\Container\Container. Since you implemented __set, consider adding a @property annotation.
Loading history...
109
        $container->logger = $this->container->logger;
0 ignored issues
show
Bug Best Practice introduced by
The property logger does not exist on WebStream\Container\Container. Since you implemented __get, consider adding a @property annotation.
Loading history...
Bug Best Practice introduced by
The property logger does not exist on WebStream\Container\Container. Since you implemented __set, consider adding a @property annotation.
Loading history...
110
        $reader->readable(Header::class, $container);
111
112
        // @Filter
113
        $container = new Container();
114
        $container->action = $this->container->executeMethod;
0 ignored issues
show
Bug Best Practice introduced by
The property action does not exist on WebStream\Container\Container. Since you implemented __set, consider adding a @property annotation.
Loading history...
115
        $container->logger = $this->container->logger;
116
        $reader->readable(Filter::class, $container);
117
        $reader->useExtendReader(Filter::class, FilterExtendReader::class);
118
119
        // @Template
120
        $container = new Container();
121
        $container->action = $this->container->executeMethod;
122
        $container->engine = [
0 ignored issues
show
Bug Best Practice introduced by
The property engine does not exist on WebStream\Container\Container. Since you implemented __set, consider adding a @property annotation.
Loading history...
123
            'basic' => Basic::class,
124
            'twig' => Twig::class
125
        ];
126
        $container->logger = $this->container->logger;
127
        $reader->readable(Template::class, $container);
128
129
        // @ExceptionHandler
130
        $container = new Container();
131
        $container->logger = $this->container->logger;
132
        $reader->readable(ExceptionHandler::class, $container);
133
134
        // @Alias
135
        $container = new Container();
136
        $container->action = $this->container->executeMethod;
137
        $container->logger = $this->container->logger;
138
        $reader->readable(Alias::class, $container);
139
140
        $reader->readMethod();
141
142
        $annotationContainer = new AnnotationContainer();
143
        $annotationContainer->annotationInfoList = $reader->getAnnotationInfoList();
0 ignored issues
show
Bug Best Practice introduced by
The property annotationInfoList does not exist on WebStream\Annotation\Container\AnnotationContainer. Since you implemented __set, consider adding a @property annotation.
Loading history...
144
        $annotationContainer->exception = $reader->getException();
0 ignored issues
show
Bug Best Practice introduced by
The property exception does not exist on WebStream\Annotation\Container\AnnotationContainer. Since you implemented __set, consider adding a @property annotation.
Loading history...
145
        $annotationContainer->customAnnotationInfoList = array_filter($annotationContainer->annotationInfoList, function ($key) {
0 ignored issues
show
Bug Best Practice introduced by
The property customAnnotationInfoList does not exist on WebStream\Annotation\Container\AnnotationContainer. Since you implemented __set, consider adding a @property annotation.
Loading history...
Bug Best Practice introduced by
The property annotationInfoList does not exist on WebStream\Annotation\Container\AnnotationContainer. Since you implemented __get, consider adding a @property annotation.
Loading history...
146
            return !in_array($key, [Filter::class, Header::class, ExceptionHandler::class, Template::class, Alias::class], true);
147
        }, ARRAY_FILTER_USE_KEY);
148
149
        return $annotationContainer;
150
    }
151
152
    /**
153
     * Serviceのアノテーション情報をロードする
154
     * @param CoreService インスタンス
155
     * @param string アノテーションクラスパス
156
     * @return Container コンテナ
157
     */
0 ignored issues
show
Documentation Bug introduced by
The doc comment インスタンス at position 0 could not be parsed: Unknown type name 'インスタンス' at position 0 in インスタンス.
Loading history...
158
    private function readService(CoreService $instance, $classpath)
0 ignored issues
show
Unused Code introduced by
The parameter $classpath is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

158
    private function readService(CoreService $instance, /** @scrutinizer ignore-unused */ $classpath)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
159
    {
160
        $reader = new AnnotationReader($instance);
161
        $reader->setActionMethod($this->container->executeMethod);
0 ignored issues
show
Bug introduced by
It seems like $this->container->executeMethod can also be of type null; however, parameter $actionMethod of WebStream\Annotation\Rea...ader::setActionMethod() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

161
        $reader->setActionMethod(/** @scrutinizer ignore-type */ $this->container->executeMethod);
Loading history...
Bug Best Practice introduced by
The property executeMethod does not exist on WebStream\Container\Container. Since you implemented __get, consider adding a @property annotation.
Loading history...
162
163
        // @Filter
164
        $container = new Container();
165
        $container->action = $this->container->executeMethod;
0 ignored issues
show
Bug Best Practice introduced by
The property action does not exist on WebStream\Container\Container. Since you implemented __set, consider adding a @property annotation.
Loading history...
166
        $container->logger = $this->container->logger;
0 ignored issues
show
Bug Best Practice introduced by
The property logger does not exist on WebStream\Container\Container. Since you implemented __set, consider adding a @property annotation.
Loading history...
Bug Best Practice introduced by
The property logger does not exist on WebStream\Container\Container. Since you implemented __get, consider adding a @property annotation.
Loading history...
167
        $reader->readable(Filter::class, $container);
168
        $reader->useExtendReader(Filter::class, FilterExtendReader::class);
169
170
        // @ExceptionHandler
171
        $container = new Container();
172
        $container->logger = $this->container->logger;
173
        $reader->readable(ExceptionHandler::class, $container);
174
175
        // @Alias
176
        $container = new Container();
177
        $container->action = $this->container->executeMethod;
178
        $container->logger = $this->container->logger;
179
        $reader->readable(Alias::class, $container);
180
181
        $reader->readMethod();
182
183
        $annotationContainer = new AnnotationContainer();
184
        $annotationContainer->annotationInfoList = $reader->getAnnotationInfoList();
0 ignored issues
show
Bug Best Practice introduced by
The property annotationInfoList does not exist on WebStream\Annotation\Container\AnnotationContainer. Since you implemented __set, consider adding a @property annotation.
Loading history...
185
        $annotationContainer->exception = $reader->getException();
0 ignored issues
show
Bug Best Practice introduced by
The property exception does not exist on WebStream\Annotation\Container\AnnotationContainer. Since you implemented __set, consider adding a @property annotation.
Loading history...
186
        $annotationContainer->customAnnotationInfoList = array_filter($annotationContainer->annotationInfoList, function ($key) {
0 ignored issues
show
Bug Best Practice introduced by
The property customAnnotationInfoList does not exist on WebStream\Annotation\Container\AnnotationContainer. Since you implemented __set, consider adding a @property annotation.
Loading history...
Bug Best Practice introduced by
The property annotationInfoList does not exist on WebStream\Annotation\Container\AnnotationContainer. Since you implemented __get, consider adding a @property annotation.
Loading history...
187
            return !in_array($key, [Filter::class, ExceptionHandler::class, Alias::class], true);
188
        }, ARRAY_FILTER_USE_KEY);
189
190
191
        return $annotationContainer;
192
    }
193
194
    /**
195
     * Modelのアノテーション情報をロードする
196
     * @param CoreModel インスタンス
197
     * @param string アノテーションクラスパス
198
     * @return Container コンテナ
199
     */
0 ignored issues
show
Documentation Bug introduced by
The doc comment インスタンス at position 0 could not be parsed: Unknown type name 'インスタンス' at position 0 in インスタンス.
Loading history...
200
    private function readModel(CoreModel $instance, $classpath)
0 ignored issues
show
Unused Code introduced by
The parameter $classpath is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

200
    private function readModel(CoreModel $instance, /** @scrutinizer ignore-unused */ $classpath)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
201
    {
202
        $reader = new AnnotationReader($instance);
203
        $reader->setActionMethod($this->container->executeMethod);
0 ignored issues
show
Bug introduced by
It seems like $this->container->executeMethod can also be of type null; however, parameter $actionMethod of WebStream\Annotation\Rea...ader::setActionMethod() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

203
        $reader->setActionMethod(/** @scrutinizer ignore-type */ $this->container->executeMethod);
Loading history...
Bug Best Practice introduced by
The property executeMethod does not exist on WebStream\Container\Container. Since you implemented __get, consider adding a @property annotation.
Loading history...
204
205
        // @Filter
206
        $container = new Container();
207
        $container->action = $this->container->executeMethod;
0 ignored issues
show
Bug Best Practice introduced by
The property action does not exist on WebStream\Container\Container. Since you implemented __set, consider adding a @property annotation.
Loading history...
208
        $container->logger = $this->container->logger;
0 ignored issues
show
Bug Best Practice introduced by
The property logger does not exist on WebStream\Container\Container. Since you implemented __get, consider adding a @property annotation.
Loading history...
Bug Best Practice introduced by
The property logger does not exist on WebStream\Container\Container. Since you implemented __set, consider adding a @property annotation.
Loading history...
209
        $reader->readable(Filter::class, $container);
210
        $reader->useExtendReader(Filter::class, FilterExtendReader::class);
211
212
        // @ExceptionHandler
213
        $container = new Container();
214
        $container->logger = $this->container->logger;
215
        $reader->readable(ExceptionHandler::class, $container);
216
217
        // @Database
218
        $container = new Container();
219
        $container->rootPath = $this->container->applicationInfo->applicationRoot;
0 ignored issues
show
Bug introduced by
The property applicationRoot does not exist on string.
Loading history...
Bug Best Practice introduced by
The property applicationInfo does not exist on WebStream\Container\Container. Since you implemented __get, consider adding a @property annotation.
Loading history...
Bug Best Practice introduced by
The property rootPath does not exist on WebStream\Container\Container. Since you implemented __set, consider adding a @property annotation.
Loading history...
220
        $container->logger = $this->container->logger;
221
        $reader->readable(Database::class, $container);
222
223
        // @Query
224
        $container = new Container();
225
        $container->rootPath = $this->container->applicationInfo->applicationRoot;
226
        $container->logger = $this->container->logger;
227
        $reader->readable(Query::class, $container);
228
        $reader->useExtendReader(Query::class, QueryExtendReader::class);
229
230
        // @Alias
231
        $container = new Container();
232
        $container->action = $this->container->executeMethod;
233
        $container->logger = $this->container->logger;
234
        $reader->readable(Alias::class, $container);
235
236
        $reader->readClass();
237
        $reader->readMethod();
238
239
        $annotationContainer = new AnnotationContainer();
240
        $annotationContainer->annotationInfoList = $reader->getAnnotationInfoList();
0 ignored issues
show
Bug Best Practice introduced by
The property annotationInfoList does not exist on WebStream\Annotation\Container\AnnotationContainer. Since you implemented __set, consider adding a @property annotation.
Loading history...
241
        $annotationContainer->exception = $reader->getException();
0 ignored issues
show
Bug Best Practice introduced by
The property exception does not exist on WebStream\Annotation\Container\AnnotationContainer. Since you implemented __set, consider adding a @property annotation.
Loading history...
242
        $annotationContainer->customAnnotationInfoList = array_filter($annotationContainer->annotationInfoList, function ($key) {
0 ignored issues
show
Bug Best Practice introduced by
The property customAnnotationInfoList does not exist on WebStream\Annotation\Container\AnnotationContainer. Since you implemented __set, consider adding a @property annotation.
Loading history...
Bug Best Practice introduced by
The property annotationInfoList does not exist on WebStream\Annotation\Container\AnnotationContainer. Since you implemented __get, consider adding a @property annotation.
Loading history...
243
            return !in_array($key, [Filter::class, ExceptionHandler::class, Database::class, Query::class, Alias::class], true);
244
        }, ARRAY_FILTER_USE_KEY);
245
246
        return $annotationContainer;
247
    }
248
249
    /**
250
     * Viewのアノテーション情報をロードする
251
     * @param CoreView インスタンス
252
     * @param string アノテーションクラスパス
253
     * @return Container コンテナ
254
     */
0 ignored issues
show
Documentation Bug introduced by
The doc comment インスタンス at position 0 could not be parsed: Unknown type name 'インスタンス' at position 0 in インスタンス.
Loading history...
255
    private function readView(CoreView $instance, $classpath)
0 ignored issues
show
Unused Code introduced by
The parameter $classpath is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

255
    private function readView(CoreView $instance, /** @scrutinizer ignore-unused */ $classpath)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
256
    {
257
        $reader = new AnnotationReader($instance);
258
259
        // @Filter
260
        $container = new Container();
261
        $container->action = $this->container->executeMethod;
0 ignored issues
show
Bug Best Practice introduced by
The property executeMethod does not exist on WebStream\Container\Container. Since you implemented __get, consider adding a @property annotation.
Loading history...
Bug Best Practice introduced by
The property action does not exist on WebStream\Container\Container. Since you implemented __set, consider adding a @property annotation.
Loading history...
262
        $container->logger = $this->container->logger;
0 ignored issues
show
Bug Best Practice introduced by
The property logger does not exist on WebStream\Container\Container. Since you implemented __set, consider adding a @property annotation.
Loading history...
Bug Best Practice introduced by
The property logger does not exist on WebStream\Container\Container. Since you implemented __get, consider adding a @property annotation.
Loading history...
263
        $reader->readable(Filter::class, $container);
264
        $reader->useExtendReader(Filter::class, FilterExtendReader::class);
265
266
        $reader->readMethod();
267
268
        $annotationContainer = new AnnotationContainer();
269
        $annotationContainer->annotationInfoList = $reader->getAnnotationInfoList();
0 ignored issues
show
Bug Best Practice introduced by
The property annotationInfoList does not exist on WebStream\Annotation\Container\AnnotationContainer. Since you implemented __set, consider adding a @property annotation.
Loading history...
270
        $annotationContainer->exception = $reader->getException();
0 ignored issues
show
Bug Best Practice introduced by
The property exception does not exist on WebStream\Annotation\Container\AnnotationContainer. Since you implemented __set, consider adding a @property annotation.
Loading history...
271
272
        return $annotationContainer;
273
    }
274
275
    /**
276
     * Helperのアノテーション情報をロードする
277
     * @param CoreHelper インスタンス
278
     * @param string アノテーションクラスパス
279
     * @return Container コンテナ
280
     */
0 ignored issues
show
Documentation Bug introduced by
The doc comment インスタンス at position 0 could not be parsed: Unknown type name 'インスタンス' at position 0 in インスタンス.
Loading history...
281
    private function readHelper(CoreHelper $instance, $classpath)
0 ignored issues
show
Unused Code introduced by
The parameter $classpath is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

281
    private function readHelper(CoreHelper $instance, /** @scrutinizer ignore-unused */ $classpath)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
282
    {
283
        $reader = new AnnotationReader($instance);
284
        $reader->setActionMethod($this->container->executeMethod);
0 ignored issues
show
Bug Best Practice introduced by
The property executeMethod does not exist on WebStream\Container\Container. Since you implemented __get, consider adding a @property annotation.
Loading history...
Bug introduced by
It seems like $this->container->executeMethod can also be of type null; however, parameter $actionMethod of WebStream\Annotation\Rea...ader::setActionMethod() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

284
        $reader->setActionMethod(/** @scrutinizer ignore-type */ $this->container->executeMethod);
Loading history...
285
286
        // @Filter
287
        $container = new Container();
288
        $container->action = $this->container->executeMethod;
0 ignored issues
show
Bug Best Practice introduced by
The property action does not exist on WebStream\Container\Container. Since you implemented __set, consider adding a @property annotation.
Loading history...
289
        $container->logger = $this->container->logger;
0 ignored issues
show
Bug Best Practice introduced by
The property logger does not exist on WebStream\Container\Container. Since you implemented __get, consider adding a @property annotation.
Loading history...
Bug Best Practice introduced by
The property logger does not exist on WebStream\Container\Container. Since you implemented __set, consider adding a @property annotation.
Loading history...
290
        $reader->readable(Filter::class, $container);
291
        $reader->useExtendReader(Filter::class, FilterExtendReader::class);
292
293
        // @ExceptionHandler
294
        $container = new Container();
295
        $container->logger = $this->container->logger;
296
        $reader->readable(ExceptionHandler::class, $container);
297
298
        // @Alias
299
        $container = new Container();
300
        $container->action = $this->container->executeMethod;
301
        $container->logger = $this->container->logger;
302
        $reader->readable(Alias::class, $container);
303
304
        $reader->readMethod();
305
306
        $annotationContainer = new AnnotationContainer();
307
        $annotationContainer->annotationInfoList = $reader->getAnnotationInfoList();
0 ignored issues
show
Bug Best Practice introduced by
The property annotationInfoList does not exist on WebStream\Annotation\Container\AnnotationContainer. Since you implemented __set, consider adding a @property annotation.
Loading history...
308
        $annotationContainer->exception = $reader->getException();
0 ignored issues
show
Bug Best Practice introduced by
The property exception does not exist on WebStream\Annotation\Container\AnnotationContainer. Since you implemented __set, consider adding a @property annotation.
Loading history...
309
        $annotationContainer->customAnnotationInfoList = array_filter($annotationContainer->annotationInfoList, function ($key) {
0 ignored issues
show
Bug Best Practice introduced by
The property annotationInfoList does not exist on WebStream\Annotation\Container\AnnotationContainer. Since you implemented __get, consider adding a @property annotation.
Loading history...
Bug Best Practice introduced by
The property customAnnotationInfoList does not exist on WebStream\Annotation\Container\AnnotationContainer. Since you implemented __set, consider adding a @property annotation.
Loading history...
310
            return !in_array($key, [Filter::class, ExceptionHandler::class, Alias::class], true);
311
        }, ARRAY_FILTER_USE_KEY);
312
313
        return $annotationContainer;
314
    }
315
316
    /**
317
     * 他のモジュールのアノテーション情報をロードする
318
     * @param object インスタンス
319
     * @param string アノテーションクラスパス
320
     * @return Container コンテナ
321
     */
0 ignored issues
show
Documentation Bug introduced by
The doc comment インスタンス at position 0 could not be parsed: Unknown type name 'インスタンス' at position 0 in インスタンス.
Loading history...
322
    private function readModule(IAnnotatable $instance, $classpath)
323
    {
324
        $container = $this->container;
325
        $reader = new AnnotationReader($instance, $container);
0 ignored issues
show
Unused Code introduced by
The call to WebStream\Annotation\Rea...onReader::__construct() has too many arguments starting with $container. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

325
        $reader = /** @scrutinizer ignore-call */ new AnnotationReader($instance, $container);

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
326
        $reader->read($classpath);
0 ignored issues
show
Unused Code introduced by
The call to WebStream\Annotation\Rea...nnotationReader::read() has too many arguments starting with $classpath. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

326
        $reader->/** @scrutinizer ignore-call */ 
327
                 read($classpath);

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
327
        $injectedAnnotation = $reader->getInjectedAnnotationInfo();
0 ignored issues
show
Bug introduced by
The method getInjectedAnnotationInfo() does not exist on WebStream\Annotation\Reader\AnnotationReader. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

327
        /** @scrutinizer ignore-call */ 
328
        $injectedAnnotation = $reader->getInjectedAnnotationInfo();

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
328
329
        $factory = new AnnotationDelegatorFactory($injectedAnnotation, $container);
0 ignored issues
show
Bug introduced by
The type WebStream\Delegate\AnnotationDelegatorFactory 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...
330
        $annotationContainer = new AnnotationContainer();
331
332
        // @Filter
333
        $annotationContainer->filter = $factory->createAnnotationCallable("filter");
0 ignored issues
show
Bug Best Practice introduced by
The property filter does not exist on WebStream\Annotation\Container\AnnotationContainer. Since you implemented __set, consider adding a @property annotation.
Loading history...
334
335
        // @Alias
336
        $annotationContainer->alias = $factory->createAnnotationCallable("alias");
0 ignored issues
show
Bug Best Practice introduced by
The property alias does not exist on WebStream\Annotation\Container\AnnotationContainer. Since you implemented __set, consider adding a @property annotation.
Loading history...
337
338
        // custom annotation
339
        $annotationContainer->customAnnotations = $factory->createCustomAnnotationCallable();
0 ignored issues
show
Bug Best Practice introduced by
The property customAnnotations does not exist on WebStream\Annotation\Container\AnnotationContainer. Since you implemented __set, consider adding a @property annotation.
Loading history...
340
341
        return $annotationContainer;
342
    }
343
}
344