Passed
Push — feature/0.7.0 ( ca90d0...f8dc8d )
by Ryuichi
44:44
created

AnnotationDelegator::read()   B

Complexity

Conditions 8
Paths 7

Size

Total Lines 21
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 8
eloc 16
nc 7
nop 3
dl 0
loc 21
rs 7.1428
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\Template;
17
use WebStream\Annotation\Base\IAnnotatable;
18
use WebStream\Annotation\Reader\AnnotationReader;
19
use WebStream\Annotation\Reader\Extend\FilterExtendReader;
20
use WebStream\Annotation\Container\AnnotationContainer;
21
use WebStream\Template\Basic;
22
use WebStream\Template\Twig;
23
24
/**
25
 * AnnotationDelegator
26
 * @author Ryuichi TANAKA.
27
 * @since 2015/02/11
28
 * @version 0.4
29
 */
30
class AnnotationDelegator
31
{
32
    /**
33
     * @var Container コンテナ
34
     */
35
    private $container;
36
37
    /**
38
     * @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...
39
     */
40
    private $logger;
41
42
    /**
43
     * Constructor
44
     * @param CoreInterface インスタンス
45
     * @param Container DIContainer
46
     */
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...
47
    public function __construct(Container $container)
48
    {
49
        $this->container = $container;
50
        $this->logger = $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...
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...
51
    }
52
53
    /**
54
     * Destructor
55
     */
56
    public function __destruct()
57
    {
58
        $this->logger->debug("AnnotationDelegator container is clear.");
59
    }
60
61
    /**
62
     * アノテーション情報をロードする
63
     * @param object インスタンス
64
     * @param string メソッド
65
     * @param string アノテーションクラスパス
66
     * @return Container コンテナ
67
     */
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...
68
    public function read($instance, $method = null, $classpath = null)
69
    {
70
        if (!$instance instanceof IAnnotatable) {
71
            $this->logger->warn("Annotation is not available this class: " . get_class($instance));
72
            return;
73
        }
74
75
        $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...
76
77
        if ($instance instanceof CoreController) {
78
            return $this->readController($instance, $classpath);
79
        } elseif ($instance instanceof CoreService) {
80
            return $this->readService($instance, $classpath);
81
        } elseif ($instance instanceof CoreModel) {
82
            return $this->readModel($instance, $classpath);
83
        } elseif ($instance instanceof CoreView) {
84
            return $this->readView($instance, $classpath);
85
        } elseif ($instance instanceof CoreHelper) {
86
            return $this->readHelper($instance, $classpath);
87
        } else {
88
            return $this->readModule($instance, $classpath);
89
        }
90
    }
91
92
    /**
93
     * Controllerのアノテーション情報をロードする
94
     * @param CoreController インスタンス
95
     * @param string アノテーションクラスパス
96
     * @return Container コンテナ
97
     */
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...
98
    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

98
    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...
99
    {
100
        $reader = new AnnotationReader($instance);
101
        $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

101
        $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...
102
103
        // @Header
104
        $container = new Container();
105
        $container->requestMethod = $this->container->request->requestMethod;
0 ignored issues
show
Bug introduced by
The property requestMethod does not exist on string.
Loading history...
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...
106
        $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...
107
        $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...
108
        $reader->readable(Header::class, $container);
109
110
        // @Filter
111
        $container = new Container();
112
        $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...
113
        $container->logger = $this->container->logger;
114
        $reader->readable(Filter::class, $container);
115
        $reader->useExtendReader(Filter::class, FilterExtendReader::class);
116
117
        // @Template
118
        $container = new Container();
119
        $container->action = $this->container->executeMethod;
120
        $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...
121
            'basic' => Basic::class,
122
            'twig' => Twig::class
123
        ];
124
        $container->logger = $this->container->logger;
125
        $reader->readable(Template::class, $container);
126
127
        // @ExceptionHandler
128
        $container = new Container();
129
        $container->logger = $this->container->logger;
130
        $reader->readable(ExceptionHandler::class, $container);
131
132
        // @Alias
133
        $container = new Container();
134
        $container->action = $this->container->executeMethod;
135
        $container->logger = $this->container->logger;
136
        $reader->readable(Alias::class, $container);
137
138
        // TODO custom annotation
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
146
        // var_dump($reader->getAnnotationInfoList());
147
        // exit;
148
        //
149
        // // $reader->read($classpath);
150
        // // $injectedAnnotation = $reader->getInjectedAnnotationInfo();
151
        //
152
        // $factory = new AnnotationDelegatorFactory($injectedAnnotation, $container);
153
        // $annotationContainer = new AnnotationContainer();
154
        //
155
        // // exceptions
156
        // $annotationContainer->exception = $reader->getException();
157
        //
158
        // // @Header
159
        // $annotationContainer->header = $factory->createAnnotationCallable("header");
160
        //
161
        // // @Filter
162
        // $annotationContainer->filter = $factory->createAnnotationCallable("filter");
163
        //
164
        // // @Template
165
        // $annotationContainer->template = $factory->createAnnotationCallable("template");
166
        //
167
        // // @ExceptionHandler
168
        // $annotationContainer->exceptionHandler = $factory->createAnnotationCallable("exceptionHandler");
169
        //
170
        // // @Alias
171
        // $annotationContainer->alias = $factory->createAnnotationCallable("alias");
172
        //
173
        // // custom annotation
174
        // $annotationContainer->customAnnotations = $factory->createCustomAnnotationCallable();
175
176
        return $annotationContainer;
177
    }
178
179
    /**
180
     * Serviceのアノテーション情報をロードする
181
     * @param CoreService インスタンス
182
     * @param string アノテーションクラスパス
183
     * @return Container コンテナ
184
     */
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...
185
    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

185
    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...
186
    {
187
        $reader = new AnnotationReader($instance);
188
        $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

188
        $reader->setActionMethod(/** @scrutinizer ignore-type */ $this->container->executeMethod);
Loading history...
189
190
        // @Filter
191
        $container = new Container();
192
        $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...
193
        $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...
194
        $reader->readable(Filter::class, $container);
195
        $reader->useExtendReader(Filter::class, FilterExtendReader::class);
196
197
        // @ExceptionHandler
198
        $container = new Container();
199
        $container->logger = $this->container->logger;
200
        $reader->readable(ExceptionHandler::class, $container);
201
202
        // @Alias
203
        $container = new Container();
204
        $container->action = $this->container->executeMethod;
205
        $container->logger = $this->container->logger;
206
        $reader->readable(Alias::class, $container);
207
208
        // TODO custom annotation
209
210
        $reader->readMethod();
211
212
        $annotationContainer = new AnnotationContainer();
213
        $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...
214
        $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...
215
216
        return $annotationContainer;
217
    }
218
219
    /**
220
     * Modelのアノテーション情報をロードする
221
     * @param CoreModel インスタンス
222
     * @param string アノテーションクラスパス
223
     * @return Container コンテナ
224
     */
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...
225
    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

225
    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...
226
    {
227
        $reader = new AnnotationReader($instance);
228
        $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

228
        $reader->setActionMethod(/** @scrutinizer ignore-type */ $this->container->executeMethod);
Loading history...
229
230
        // @Filter
231
        $container = new Container();
232
        $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...
233
        $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...
234
        $reader->readable(Filter::class, $container);
235
        $reader->useExtendReader(Filter::class, FilterExtendReader::class);
236
237
        // @ExceptionHandler
238
        $container = new Container();
239
        $container->logger = $this->container->logger;
240
        $reader->readable(ExceptionHandler::class, $container);
241
242
        // @Database
243
        $container = new Container();
244
        $container->rootPath = $this->container->applicationInfo->applicationRoot;
0 ignored issues
show
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 introduced by
The property applicationRoot does not exist on string.
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...
245
        $container->logger = $this->container->logger;
246
        $reader->readable(Database::class, $container);
247
248
        // @Query
249
        $container = new Container();
250
        $container->rootPath = $this->container->applicationInfo->applicationRoot;
251
        $reader->readable(Query::class, $container);
0 ignored issues
show
Bug introduced by
The type WebStream\Delegate\Query 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...
252
        $reader->useExtendReader(Query::class, QueryExtendReader::class);
0 ignored issues
show
Bug introduced by
The type WebStream\Delegate\QueryExtendReader 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...
253
254
        // @Alias
255
        $container = new Container();
256
        $container->action = $this->container->executeMethod;
257
        $container->logger = $this->container->logger;
258
        $reader->readable(Alias::class, $container);
259
260
        // TODO custom annotation
261
262
        $reader->readClass();
263
        $reader->readMethod();
264
265
        $annotationContainer = new AnnotationContainer();
266
        $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...
267
        $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...
268
269
        return $annotationContainer;
270
    }
271
272
    /**
273
     * Viewのアノテーション情報をロードする
274
     * @param CoreView インスタンス
275
     * @param string アノテーションクラスパス
276
     * @return Container コンテナ
277
     */
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...
278
    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

278
    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...
279
    {
280
        $reader = new AnnotationReader($instance);
281
        // $reader->setActionMethod($this->container->executeMethod);
282
283
        // @Filter
284
        $container = new Container();
285
        $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...
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...
286
        $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...
287
        $reader->readable(Filter::class, $container);
288
        $reader->useExtendReader(Filter::class, FilterExtendReader::class);
289
        $reader->readMethod();
290
291
        $annotationContainer = new AnnotationContainer();
292
        $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...
293
        $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...
294
295
        //
296
        // $container = $this->container;
297
        // $reader = new AnnotationReader($instance, $container);
298
        // $reader->read($classpath);
299
        // $injectedAnnotation = $reader->getInjectedAnnotationInfo();
300
        //
301
        // $factory = new AnnotationDelegatorFactory($injectedAnnotation, $container);
302
        // $annotationContainer = new AnnotationContainer();
303
        //
304
        // // exceptions
305
        // $annotationContainer->exception = $reader->getException();
306
        //
307
        // // @Filter
308
        // $annotationContainer->filter = $factory->createAnnotationCallable("filter");
309
310
        return $annotationContainer;
311
    }
312
313
    /**
314
     * Helperのアノテーション情報をロードする
315
     * @param CoreHelper インスタンス
316
     * @param string アノテーションクラスパス
317
     * @return Container コンテナ
318
     */
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...
319
    private function readHelper(CoreHelper $instance, $classpath)
320
    {
321
        $container = $this->container;
322
        $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

322
        $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...
323
        $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

323
        $reader->/** @scrutinizer ignore-call */ 
324
                 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...
324
        $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

324
        /** @scrutinizer ignore-call */ 
325
        $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...
325
326
        $factory = new AnnotationDelegatorFactory($injectedAnnotation, $container);
327
        $annotationContainer = new AnnotationContainer();
328
329
        // exceptions
330
        $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...
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
        // @ExceptionHandler
336
        $annotationContainer->exceptionHandler = $factory->createAnnotationCallable("exceptionHandler");
0 ignored issues
show
Bug Best Practice introduced by
The property exceptionHandler does not exist on WebStream\Annotation\Container\AnnotationContainer. Since you implemented __set, consider adding a @property annotation.
Loading history...
337
338
        // @Alias
339
        $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...
340
341
        // custom annotation
342
        $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...
343
344
        return $annotationContainer;
345
    }
346
347
    /**
348
     * 他のモジュールのアノテーション情報をロードする
349
     * @param object インスタンス
350
     * @param string アノテーションクラスパス
351
     * @return Container コンテナ
352
     */
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...
353
    private function readModule(IAnnotatable $instance, $classpath)
354
    {
355
        $container = $this->container;
356
        $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

356
        $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...
357
        $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

357
        $reader->/** @scrutinizer ignore-call */ 
358
                 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...
358
        $injectedAnnotation = $reader->getInjectedAnnotationInfo();
359
360
        $factory = new AnnotationDelegatorFactory($injectedAnnotation, $container);
361
        $annotationContainer = new AnnotationContainer();
362
363
        // @Filter
364
        $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...
365
366
        // @Alias
367
        $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...
368
369
        // custom annotation
370
        $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...
371
372
        return $annotationContainer;
373
    }
374
}
375