Passed
Branch master (79d24d)
by Johannes
02:27
created

MetadataFactory::getMetadataForClass()   C

Complexity

Conditions 16
Paths 36

Size

Total Lines 60
Code Lines 33

Duplication

Lines 0
Ratio 0 %

Importance

Changes 7
Bugs 2 Features 2
Metric Value
c 7
b 2
f 2
dl 0
loc 60
rs 6.2854
cc 16
eloc 33
nc 36
nop 1

How to fix   Long Method    Complexity   

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
3
/*
0 ignored issues
show
introduced by
Copyright notice too long
Loading history...
4
 * Copyright 2011 Johannes M. Schmitt <[email protected]>
5
 *
6
 * Licensed under the Apache License, Version 2.0 (the "License");
7
 * you may not use this file except in compliance with the License.
8
 * You may obtain a copy of the License at
9
 *
10
 * http://www.apache.org/licenses/LICENSE-2.0
11
 *
12
 * Unless required by applicable law or agreed to in writing, software
13
 * distributed under the License is distributed on an "AS IS" BASIS,
14
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
 * See the License for the specific language governing permissions and
16
 * limitations under the License.
17
 */
18
19
namespace Metadata;
20
21
use Metadata\Driver\AdvancedDriverInterface;
22
use Metadata\Driver\DriverInterface;
23
use Metadata\Cache\CacheInterface;
24
25
class MetadataFactory implements AdvancedMetadataFactoryInterface
0 ignored issues
show
introduced by
Missing class doc comment
Loading history...
26
{
27
    private $driver;
0 ignored issues
show
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
28
    private $cache;
0 ignored issues
show
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
29
    private $loadedMetadata = array();
0 ignored issues
show
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
30
    private $loadedClassMetadata = array();
0 ignored issues
show
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
31
    private $hierarchyMetadataClass;
0 ignored issues
show
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
32
    private $includeInterfaces = false;
0 ignored issues
show
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
33
    private $debug;
0 ignored issues
show
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
34
35
    /**
0 ignored issues
show
introduced by
Missing short description in doc comment
Loading history...
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
36
     * @param DriverInterface $driver
0 ignored issues
show
introduced by
Missing parameter comment
Loading history...
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
37
     * @param string          $hierarchyMetadataClass
0 ignored issues
show
introduced by
Missing parameter comment
Loading history...
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
38
     * @param boolean         $debug
0 ignored issues
show
introduced by
Missing parameter comment
Loading history...
introduced by
Expected "bool" but found "boolean" for parameter type
Loading history...
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
39
     */
0 ignored issues
show
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
40
    public function __construct(DriverInterface $driver, $hierarchyMetadataClass = 'Metadata\ClassHierarchyMetadata', $debug = false)
0 ignored issues
show
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
41
    {
0 ignored issues
show
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
42
        $this->driver = $driver;
0 ignored issues
show
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
43
        $this->hierarchyMetadataClass = $hierarchyMetadataClass;
0 ignored issues
show
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
44
        $this->debug = (Boolean) $debug;
0 ignored issues
show
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
45
    }
0 ignored issues
show
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
46
47
    /**
0 ignored issues
show
introduced by
Missing short description in doc comment
Loading history...
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
48
     * @param boolean $include
0 ignored issues
show
introduced by
Missing parameter comment
Loading history...
introduced by
Expected "bool" but found "boolean" for parameter type
Loading history...
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
49
     */
0 ignored issues
show
introduced by
Missing @return tag in function comment
Loading history...
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
50
    public function setIncludeInterfaces($include)
0 ignored issues
show
introduced by
This function must always have a return value.
Loading history...
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
51
    {
0 ignored issues
show
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
52
        $this->includeInterfaces = (Boolean) $include;
0 ignored issues
show
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
53
    }
0 ignored issues
show
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
54
55
    public function setCache(CacheInterface $cache)
0 ignored issues
show
introduced by
This function must always have a return value.
Loading history...
introduced by
Missing function doc comment
Loading history...
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
56
    {
0 ignored issues
show
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
57
        $this->cache = $cache;
0 ignored issues
show
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
58
    }
0 ignored issues
show
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
59
60
    /**
0 ignored issues
show
introduced by
Missing short description in doc comment
Loading history...
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
61
     * @param string $className
0 ignored issues
show
introduced by
Missing parameter comment
Loading history...
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
62
     *
0 ignored issues
show
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
63
     * @return ClassHierarchyMetadata|MergeableClassMetadata|null
0 ignored issues
show
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
64
     */
0 ignored issues
show
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
65
    public function getMetadataForClass($className)
0 ignored issues
show
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
66
    {
0 ignored issues
show
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
67
        if (isset($this->loadedMetadata[$className])) {
0 ignored issues
show
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
68
            return $this->filterNullMetadata($this->loadedMetadata[$className]);
0 ignored issues
show
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
69
        }
0 ignored issues
show
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
70
71
        $metadata = null;
0 ignored issues
show
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
72
        foreach ($this->getClassHierarchy($className) as $class) {
0 ignored issues
show
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
73
            if (isset($this->loadedClassMetadata[$name = $class->getName()])) {
0 ignored issues
show
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
74
                if (null !== $classMetadata = $this->filterNullMetadata($this->loadedClassMetadata[$name])) {
0 ignored issues
show
introduced by
Assignments in condition should be surrounded by the extra pair of brackets
Loading history...
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
75
                    $this->addClassMetadata($metadata, $classMetadata);
0 ignored issues
show
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
76
                }
0 ignored issues
show
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
77
                continue;
0 ignored issues
show
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
78
            }
0 ignored issues
show
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
79
80
            // check the cache
0 ignored issues
show
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
81
            if (null !== $this->cache) {
0 ignored issues
show
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
82
                if (($classMetadata = $this->cache->loadClassMetadataFromCache($class)) instanceof NullMetadata) {
0 ignored issues
show
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
83
                    $this->loadedClassMetadata[$name] = $classMetadata;
0 ignored issues
show
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
84
                    continue;
0 ignored issues
show
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
85
                }
0 ignored issues
show
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
86
87
                if (null !== $classMetadata) {
0 ignored issues
show
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
88
                    if ( ! $classMetadata instanceof ClassMetadata) {
0 ignored issues
show
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
89
                        throw new \LogicException(sprintf('The cache must return instances of ClassMetadata, but got %s.', var_export($classMetadata, true)));
0 ignored issues
show
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
90
                    }
0 ignored issues
show
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
91
92
                    if ($this->debug && !$classMetadata->isFresh()) {
0 ignored issues
show
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
93
                        $this->cache->evictClassMetadataFromCache($classMetadata->reflection);
0 ignored issues
show
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
94
                    } else {
0 ignored issues
show
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
95
                        $this->loadedClassMetadata[$name] = $classMetadata;
0 ignored issues
show
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
96
                        $this->addClassMetadata($metadata, $classMetadata);
0 ignored issues
show
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
97
                        continue;
0 ignored issues
show
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
98
                    }
0 ignored issues
show
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
99
                }
0 ignored issues
show
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
100
            }
0 ignored issues
show
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
101
102
            // load from source
0 ignored issues
show
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
103
            if (null !== $classMetadata = $this->driver->loadMetadataForClass($class)) {
0 ignored issues
show
introduced by
Assignments in condition should be surrounded by the extra pair of brackets
Loading history...
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
104
                $this->loadedClassMetadata[$name] = $classMetadata;
0 ignored issues
show
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
105
                $this->addClassMetadata($metadata, $classMetadata);
0 ignored issues
show
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
106
107
                if (null !== $this->cache) {
0 ignored issues
show
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
108
                    $this->cache->putClassMetadataInCache($classMetadata);
0 ignored issues
show
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
109
                }
0 ignored issues
show
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
110
111
                continue;
0 ignored issues
show
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
112
            }
0 ignored issues
show
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
113
114
            if (null !== $this->cache && !$this->debug) {
0 ignored issues
show
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
115
                $this->cache->putClassMetadataInCache(new NullMetadata($class->getName()));
0 ignored issues
show
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
116
            }
0 ignored issues
show
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
117
        }
0 ignored issues
show
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
118
119
        if (null === $metadata) {
0 ignored issues
show
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
120
            $metadata = new NullMetadata($className);
0 ignored issues
show
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
121
        }
0 ignored issues
show
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
122
123
        return $this->filterNullMetadata($this->loadedMetadata[$className] = $metadata);
0 ignored issues
show
Documentation introduced by
$this->loadedMetadata[$className] = $metadata is of type object<Metadata\ClassMetadata>, but the function expects a object<Metadata\NullMetadata>|null.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
124
    }
0 ignored issues
show
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
125
126
    /**
0 ignored issues
show
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
127
     * {@inheritDoc}
0 ignored issues
show
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
128
     */
0 ignored issues
show
introduced by
Missing @return tag in function comment
Loading history...
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
129
    public function getAllClassNames()
0 ignored issues
show
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
130
    {
0 ignored issues
show
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
131
        if (!$this->driver instanceof AdvancedDriverInterface) {
0 ignored issues
show
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
132
            throw new \RuntimeException(
0 ignored issues
show
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
133
                sprintf('Driver "%s" must be an instance of "AdvancedDriverInterface".', get_class($this->driver))
0 ignored issues
show
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
134
            );
0 ignored issues
show
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
135
        }
0 ignored issues
show
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
136
137
        return $this->driver->getAllClassNames();
0 ignored issues
show
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
138
    }
0 ignored issues
show
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
139
140
    /**
0 ignored issues
show
introduced by
Missing short description in doc comment
Loading history...
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
141
     * @param ClassMetadata|null $metadata
0 ignored issues
show
introduced by
Missing parameter comment
Loading history...
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
142
     * @param ClassMetadata      $toAdd
0 ignored issues
show
introduced by
Missing parameter comment
Loading history...
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
143
     */
0 ignored issues
show
introduced by
Missing @return tag in function comment
Loading history...
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
144
    private function addClassMetadata(&$metadata, $toAdd)
0 ignored issues
show
introduced by
Type hint "ClassMetadata" missing for $toAdd
Loading history...
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
145
    {
0 ignored issues
show
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
146
        if ($toAdd instanceof MergeableInterface) {
0 ignored issues
show
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
147
            if (null === $metadata) {
0 ignored issues
show
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
148
                $metadata = clone $toAdd;
0 ignored issues
show
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
149
            } else {
0 ignored issues
show
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
150
                $metadata->merge($toAdd);
0 ignored issues
show
Bug introduced by
It seems like you code against a specific sub-type and not the parent class Metadata\ClassMetadata as the method merge() does only exist in the following sub-classes of Metadata\ClassMetadata: Metadata\MergeableClassMetadata. Maybe you want to instanceof check for one of these explicitly?

Let’s take a look at an example:

abstract class User
{
    /** @return string */
    abstract public function getPassword();
}

class MyUser extends User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different sub-classes of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the parent class:

    abstract class User
    {
        /** @return string */
        abstract public function getPassword();
    
        /** @return string */
        abstract public function getDisplayName();
    }
    
Loading history...
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
151
            }
0 ignored issues
show
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
152
        } else {
0 ignored issues
show
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
153
            if (null === $metadata) {
0 ignored issues
show
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
154
                $metadata = new $this->hierarchyMetadataClass;
0 ignored issues
show
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
155
            }
0 ignored issues
show
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
156
157
            $metadata->addClassMetadata($toAdd);
0 ignored issues
show
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
158
        }
0 ignored issues
show
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
159
    }
0 ignored issues
show
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
160
161
    /**
0 ignored issues
show
introduced by
Missing short description in doc comment
Loading history...
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
162
     * @param string $class
0 ignored issues
show
introduced by
Missing parameter comment
Loading history...
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
163
     */
0 ignored issues
show
introduced by
Missing @return tag in function comment
Loading history...
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
164
    private function getClassHierarchy($class)
0 ignored issues
show
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
165
    {
0 ignored issues
show
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
166
        $classes = array();
0 ignored issues
show
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
167
        $refl = new \ReflectionClass($class);
0 ignored issues
show
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
168
169
        do {
0 ignored issues
show
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
170
            $classes[] = $refl;
0 ignored issues
show
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
171
            $refl = $refl->getParentClass();
0 ignored issues
show
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
172
        } while (false !== $refl);
0 ignored issues
show
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
173
174
        $classes = array_reverse($classes, false);
0 ignored issues
show
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
175
176
        if (!$this->includeInterfaces) {
0 ignored issues
show
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
177
            return $classes;
0 ignored issues
show
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
178
        }
0 ignored issues
show
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
179
180
        $addedInterfaces = array();
0 ignored issues
show
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
181
        $newHierarchy = array();
0 ignored issues
show
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
182
183
        foreach ($classes as $class) {
0 ignored issues
show
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
184
            foreach ($class->getInterfaces() as $interface) {
0 ignored issues
show
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
185
                if (isset($addedInterfaces[$interface->getName()])) {
0 ignored issues
show
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
186
                    continue;
0 ignored issues
show
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
187
                }
0 ignored issues
show
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
188
                $addedInterfaces[$interface->getName()] = true;
0 ignored issues
show
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
189
190
                $newHierarchy[] = $interface;
0 ignored issues
show
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
191
            }
0 ignored issues
show
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
192
193
            $newHierarchy[] = $class;
0 ignored issues
show
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
194
        }
0 ignored issues
show
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
195
196
        return $newHierarchy;
0 ignored issues
show
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
197
    }
0 ignored issues
show
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
198
199
    /**
0 ignored issues
show
introduced by
Missing short description in doc comment
Loading history...
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
200
     * @param NullMetadata|null $metadata
0 ignored issues
show
introduced by
Missing parameter comment
Loading history...
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
201
     *
0 ignored issues
show
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
202
     * @return ClassMetadata|null
0 ignored issues
show
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
203
     */
0 ignored issues
show
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
204
    private function filterNullMetadata($metadata = null)
0 ignored issues
show
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
205
    {
0 ignored issues
show
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
206
        return !$metadata instanceof NullMetadata ? $metadata : null;
0 ignored issues
show
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
207
    }
0 ignored issues
show
introduced by
Tabs must be used to indent lines; spaces are not allowed
Loading history...
208
}
209