Passed
Push — feature/0.7.0 ( 54b1aa...9c1bf9 )
by Ryuichi
44:30
created

AnnotationDelegator   A

Complexity

Total Complexity 16

Size/Duplication

Total Lines 325
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 325
rs 10
c 0
b 0
f 0
wmc 16

9 Methods

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

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

100
        $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...
101
102
        // @Header
103
        $container = new Container();
104
        $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...
105
        $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...
106
        $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...
107
        $reader->readable(Header::class, $container);
108
109
        // @Filter
110
        $container = new Container();
111
        $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...
112
        $container->logger = $this->container->logger;
113
        $reader->readable(Filter::class, $container);
114
        $reader->useExtendReader(Filter::class, FilterExtendReader::class);
115
116
        // @Template
117
        $container = new Container();
118
        $container->action = $this->container->executeMethod;
119
        $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...
120
            'basic' => Basic::class,
121
            'twig' => Twig::class
122
        ];
123
        $container->logger = $this->container->logger;
124
        $reader->readable(Template::class, $container);
125
126
        // @ExceptionHandler
127
        $container = new Container();
128
        $container->logger = $this->container->logger;
129
        $reader->readable(ExceptionHandler::class, $container);
130
131
        // @Alias
132
        $container = new Container();
133
        $container->action = $this->container->executeMethod;
134
        $container->logger = $this->container->logger;
135
        $reader->readable(Alias::class, $container);
136
137
        // TODO custom annotation
138
139
        $reader->readMethod();
140
141
        $annotationContainer = new AnnotationContainer();
142
        $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...
143
        $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...
144
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)
186
    {
187
        $container = $this->container;
188
        $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

188
        $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...
189
        $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

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

190
        /** @scrutinizer ignore-call */ 
191
        $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...
191
192
        $factory = new AnnotationDelegatorFactory($injectedAnnotation, $container);
193
        $annotationContainer = new AnnotationContainer();
194
195
        // exceptions
196
        $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...
197
198
        // @Filter
199
        $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...
200
201
        // @ExceptionHandler
202
        $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...
203
204
        // @Alias
205
        $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...
206
207
        // custom annotation
208
        $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...
209
210
        return $annotationContainer;
211
    }
212
213
    /**
214
     * Modelのアノテーション情報をロードする
215
     * @param CoreModel インスタンス
216
     * @param string アノテーションクラスパス
217
     * @return Container コンテナ
218
     */
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...
219
    private function readModel(CoreModel $instance, $classpath)
220
    {
221
        $container = $this->container;
222
        $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

222
        $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...
223
        $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

223
        $reader->/** @scrutinizer ignore-call */ 
224
                 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...
224
        $injectedAnnotation = $reader->getInjectedAnnotationInfo();
225
226
        $factory = new AnnotationDelegatorFactory($injectedAnnotation, $container);
227
        $annotationContainer = new AnnotationContainer();
228
229
        // exceptions
230
        $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...
231
232
        // @Filter
233
        $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...
234
235
        // @ExceptionHandler
236
        $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...
237
238
        // @Database
239
        $annotationContainer->database = $factory->createAnnotationCallable("database");
0 ignored issues
show
Bug Best Practice introduced by
The property database does not exist on WebStream\Annotation\Container\AnnotationContainer. Since you implemented __set, consider adding a @property annotation.
Loading history...
240
241
        // @Query
242
        $annotationContainer->query = $factory->createAnnotationCallable("query");
0 ignored issues
show
Bug Best Practice introduced by
The property query does not exist on WebStream\Annotation\Container\AnnotationContainer. Since you implemented __set, consider adding a @property annotation.
Loading history...
243
244
        // @Alias
245
        $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...
246
247
        // custom annotation
248
        $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...
249
250
        return $annotationContainer;
251
    }
252
253
    /**
254
     * Viewのアノテーション情報をロードする
255
     * @param CoreView インスタンス
256
     * @param string アノテーションクラスパス
257
     * @return Container コンテナ
258
     */
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...
259
    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

259
    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...
260
    {
261
        $reader = new AnnotationReader($instance);
262
        // $reader->setActionMethod($this->container->executeMethod);
263
264
        // @Filter
265
        $container = new Container();
266
        // $container->action = $this->container->executeMethod;
267
        $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...
268
        $reader->readable(Filter::class, $container);
269
        $reader->useExtendReader(Filter::class, FilterExtendReader::class);
270
        $reader->readMethod();
271
272
        $annotationContainer = new AnnotationContainer();
273
        $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...
274
        $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...
275
276
        //
277
        // $container = $this->container;
278
        // $reader = new AnnotationReader($instance, $container);
279
        // $reader->read($classpath);
280
        // $injectedAnnotation = $reader->getInjectedAnnotationInfo();
281
        //
282
        // $factory = new AnnotationDelegatorFactory($injectedAnnotation, $container);
283
        $annotationContainer = new AnnotationContainer();
284
285
        // exceptions
286
        $annotationContainer->exception = $reader->getException();
287
288
        // @Filter
289
        $annotationContainer->filter = $factory->createAnnotationCallable("filter");
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $factory seems to be never defined.
Loading history...
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...
290
291
        return $annotationContainer;
292
    }
293
294
    /**
295
     * Helperのアノテーション情報をロードする
296
     * @param CoreHelper インスタンス
297
     * @param string アノテーションクラスパス
298
     * @return Container コンテナ
299
     */
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...
300
    private function readHelper(CoreHelper $instance, $classpath)
301
    {
302
        $container = $this->container;
303
        $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

303
        $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...
304
        $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

304
        $reader->/** @scrutinizer ignore-call */ 
305
                 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...
305
        $injectedAnnotation = $reader->getInjectedAnnotationInfo();
306
307
        $factory = new AnnotationDelegatorFactory($injectedAnnotation, $container);
308
        $annotationContainer = new AnnotationContainer();
309
310
        // exceptions
311
        $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...
312
313
        // @Filter
314
        $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...
315
316
        // @ExceptionHandler
317
        $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...
318
319
        // @Alias
320
        $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...
321
322
        // custom annotation
323
        $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...
324
325
        return $annotationContainer;
326
    }
327
328
    /**
329
     * 他のモジュールのアノテーション情報をロードする
330
     * @param object インスタンス
331
     * @param string アノテーションクラスパス
332
     * @return Container コンテナ
333
     */
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...
334
    private function readModule(IAnnotatable $instance, $classpath)
335
    {
336
        $container = $this->container;
337
        $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

337
        $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...
338
        $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

338
        $reader->/** @scrutinizer ignore-call */ 
339
                 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...
339
        $injectedAnnotation = $reader->getInjectedAnnotationInfo();
340
341
        $factory = new AnnotationDelegatorFactory($injectedAnnotation, $container);
342
        $annotationContainer = new AnnotationContainer();
343
344
        // @Filter
345
        $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...
346
347
        // @Alias
348
        $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...
349
350
        // custom annotation
351
        $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...
352
353
        return $annotationContainer;
354
    }
355
}
356