1 | <?php |
||
2 | |||
3 | namespace WebStream\Annotation\Attributes; |
||
4 | |||
5 | use WebStream\Annotation\Base\Annotation; |
||
6 | use WebStream\Annotation\Base\IAnnotatable; |
||
7 | use WebStream\Annotation\Base\IRead; |
||
8 | use WebStream\Annotation\Base\IMethods; |
||
9 | use WebStream\Container\Container; |
||
0 ignored issues
–
show
|
|||
10 | |||
11 | /** |
||
12 | * ExceptionHandler |
||
13 | * @author Ryuichi TANAKA. |
||
14 | * @since 2013/11/22 |
||
15 | * @version 0.4 |
||
16 | * |
||
17 | * @Annotation |
||
18 | * @Target("METHOD") |
||
19 | */ |
||
20 | class ExceptionHandler extends Annotation implements IMethods, IRead |
||
21 | { |
||
22 | /** |
||
23 | * @var array<string> 注入アノテーション情報 |
||
24 | */ |
||
25 | private array $injectAnnotation; |
||
26 | |||
27 | /** |
||
28 | * @var array<string> 読み込みアノテーション情報 |
||
29 | */ |
||
30 | private array $readAnnotation; |
||
31 | |||
32 | /** |
||
33 | * {@inheritdoc} |
||
34 | */ |
||
35 | 6 | public function onInject(array $injectAnnotation) |
|
36 | { |
||
37 | 6 | $this->injectAnnotation = $injectAnnotation; |
|
38 | 6 | $this->readAnnotation = []; |
|
39 | } |
||
40 | |||
41 | /** |
||
42 | * {@inheritdoc} |
||
43 | */ |
||
44 | 6 | public function getAnnotationInfo(): array |
|
45 | { |
||
46 | 6 | return $this->readAnnotation; |
|
47 | } |
||
48 | |||
49 | /** |
||
50 | * {@inheritdoc} |
||
51 | */ |
||
52 | 6 | public function onMethodInject(IAnnotatable $instance, \ReflectionMethod $method, Container $container) |
|
53 | { |
||
54 | 6 | $exceptions = $this->injectAnnotation['value']; |
|
55 | 6 | if (!is_array($exceptions)) { |
|
56 | 4 | $exceptions = [$exceptions]; |
|
57 | } |
||
58 | |||
59 | 6 | $this->readAnnotation = [ |
|
0 ignored issues
–
show
array('exceptions' => $e...'refMethod' => $method) is of type array<string,ReflectionMethod|array> , but the property $readAnnotation was declared to be of type string[] . Are you sure that you always receive this specific sub-class here, or does it make sense to add an instanceof 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 given class or a super-class is assigned to a property that is type hinted more strictly. Either this assignment is in error or an instanceof check should be added for that assignment. class Alien {}
class Dalek extends Alien {}
class Plot
{
/** @var Dalek */
public $villain;
}
$alien = new Alien();
$plot = new Plot();
if ($alien instanceof Dalek) {
$plot->villain = $alien;
}
![]() |
|||
60 | 6 | 'exceptions' => $exceptions, |
|
61 | 6 | 'refMethod' => $method |
|
62 | ]; |
||
63 | } |
||
64 | } |
||
65 |
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:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths