Test Failed
Pull Request — master (#34)
by Anatoly
02:07
created

AbstractAnnotation::getComponentObjects()   A

Complexity

Conditions 3
Paths 1

Size

Total Lines 20
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 12
c 1
b 0
f 0
dl 0
loc 20
rs 9.8666
cc 3
nc 1
nop 1
1
<?php declare(strict_types=1);
2
3
/**
4
 * It's free open-source software released under the MIT License.
5
 *
6
 * @author Anatoly Fenric <[email protected]>
7
 * @copyright Copyright (c) 2018, Anatoly Fenric
8
 * @license https://github.com/sunrise-php/http-router/blob/master/LICENSE
9
 * @link https://github.com/sunrise-php/http-router
10
 */
11
12
namespace Sunrise\Http\Router\Annotation\OpenApi;
13
14
/**
15
 * Import classes
16
 */
17
use Doctrine\Common\Annotations\SimpleAnnotationReader;
18
use Sunrise\Http\Router\OpenApi\AbstractObject;
19
20
/**
21
 * Import functions
22
 */
23
use function array_merge;
24
use function array_walk_recursive;
25
26
/**
27
 * AbstractAnnotation
28
 */
29
abstract class AbstractAnnotation extends AbstractObject
30
{
31
32
    /**
33
     * {@inheritDoc}
34
     */
35
    public function getComponentObjects(SimpleAnnotationReader $annotationReader) : array
36
    {
37
        $fields = $this->getFields();
38
        $objects = [];
39
40
        array_walk_recursive($fields, function ($value) use ($annotationReader, &$objects) {
41
            if ($value instanceof AbstractAnnotation) {
42
                $objects = array_merge($objects, $value->getComponentObjects($annotationReader));
43
                return;
44
            }
45
46
            if ($value instanceof AbstractReference) {
47
                $object = $value->getAnnotation($annotationReader);
48
                $objects[] = $object;
49
                $objects = array_merge($objects, $object->getComponentObjects($annotationReader));
0 ignored issues
show
Bug introduced by
The method getComponentObjects() does not exist on Sunrise\Http\Router\Open...omponentObjectInterface. Did you maybe mean getComponentName()? ( Ignorable by Annotation )

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

49
                $objects = array_merge($objects, $object->/** @scrutinizer ignore-call */ getComponentObjects($annotationReader));

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...
50
                return;
51
            }
52
        });
53
54
        return $objects;
55
    }
56
}
57