Passed
Push — feature/0.7.0 ( b4ac8e...ca90d0 )
by Ryuichi
43:26
created

AnnotationDelegator::readModel()   A

Complexity

Conditions 1
Paths 0

Size

Total Lines 67
Code Lines 34

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 34
c 0
b 0
f 0
nc 0
nop 2
dl 0
loc 67
rs 9.2815

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

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
        $reader->readClass();
249
250
        $annotationContainer = new AnnotationContainer();
251
        $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...
252
        $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...
253
254
255
        var_dump($annotationContainer->annotationInfoList);
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...
Security Debugging Code introduced by
var_dump($annotationCont...er->annotationInfoList) looks like debug code. Are you sure you do not want to remove it?
Loading history...
256
        exit;
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
257
258
259
260
261
262
        $container = $this->container;
0 ignored issues
show
Unused Code introduced by
$container = $this->container is not reachable.

This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.

Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.

Loading history...
263
        $reader = new AnnotationReader($instance, $container);
264
        $reader->read($classpath);
265
        $injectedAnnotation = $reader->getInjectedAnnotationInfo();
266
267
        $factory = new AnnotationDelegatorFactory($injectedAnnotation, $container);
268
        $annotationContainer = new AnnotationContainer();
269
270
        // exceptions
271
        $annotationContainer->exception = $reader->getException();
272
273
        // @Filter
274
        $annotationContainer->filter = $factory->createAnnotationCallable("filter");
275
276
        // @ExceptionHandler
277
        $annotationContainer->exceptionHandler = $factory->createAnnotationCallable("exceptionHandler");
278
279
        // @Database
280
        $annotationContainer->database = $factory->createAnnotationCallable("database");
281
282
        // @Query
283
        $annotationContainer->query = $factory->createAnnotationCallable("query");
284
285
        // @Alias
286
        $annotationContainer->alias = $factory->createAnnotationCallable("alias");
287
288
        // custom annotation
289
        $annotationContainer->customAnnotations = $factory->createCustomAnnotationCallable();
290
291
        return $annotationContainer;
292
    }
293
294
    /**
295
     * Viewのアノテーション情報をロードする
296
     * @param CoreView インスタンス
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 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

300
    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...
301
    {
302
        $reader = new AnnotationReader($instance);
303
        // $reader->setActionMethod($this->container->executeMethod);
304
305
        // @Filter
306
        $container = new Container();
307
        $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...
308
        $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...
309
        $reader->readable(Filter::class, $container);
310
        $reader->useExtendReader(Filter::class, FilterExtendReader::class);
311
        $reader->readMethod();
312
313
        $annotationContainer = new AnnotationContainer();
314
        $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...
315
        $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...
316
317
        //
318
        // $container = $this->container;
319
        // $reader = new AnnotationReader($instance, $container);
320
        // $reader->read($classpath);
321
        // $injectedAnnotation = $reader->getInjectedAnnotationInfo();
322
        //
323
        // $factory = new AnnotationDelegatorFactory($injectedAnnotation, $container);
324
        // $annotationContainer = new AnnotationContainer();
325
        //
326
        // // exceptions
327
        // $annotationContainer->exception = $reader->getException();
328
        //
329
        // // @Filter
330
        // $annotationContainer->filter = $factory->createAnnotationCallable("filter");
331
332
        return $annotationContainer;
333
    }
334
335
    /**
336
     * Helperのアノテーション情報をロードする
337
     * @param CoreHelper インスタンス
338
     * @param string アノテーションクラスパス
339
     * @return Container コンテナ
340
     */
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...
341
    private function readHelper(CoreHelper $instance, $classpath)
342
    {
343
        $container = $this->container;
344
        $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

344
        $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...
345
        $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

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

346
        /** @scrutinizer ignore-call */ 
347
        $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...
347
348
        $factory = new AnnotationDelegatorFactory($injectedAnnotation, $container);
349
        $annotationContainer = new AnnotationContainer();
350
351
        // exceptions
352
        $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...
353
354
        // @Filter
355
        $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...
356
357
        // @ExceptionHandler
358
        $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...
359
360
        // @Alias
361
        $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...
362
363
        // custom annotation
364
        $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...
365
366
        return $annotationContainer;
367
    }
368
369
    /**
370
     * 他のモジュールのアノテーション情報をロードする
371
     * @param object インスタンス
372
     * @param string アノテーションクラスパス
373
     * @return Container コンテナ
374
     */
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...
375
    private function readModule(IAnnotatable $instance, $classpath)
376
    {
377
        $container = $this->container;
378
        $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

378
        $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...
379
        $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

379
        $reader->/** @scrutinizer ignore-call */ 
380
                 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...
380
        $injectedAnnotation = $reader->getInjectedAnnotationInfo();
381
382
        $factory = new AnnotationDelegatorFactory($injectedAnnotation, $container);
383
        $annotationContainer = new AnnotationContainer();
384
385
        // @Filter
386
        $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...
387
388
        // @Alias
389
        $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...
390
391
        // custom annotation
392
        $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...
393
394
        return $annotationContainer;
395
    }
396
}
397