These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace Hateoas\Configuration\Metadata\Driver; |
||
4 | |||
5 | use Hateoas\Configuration\Metadata\ClassMetadata; |
||
6 | use Hateoas\Configuration\Metadata\ConfigurationExtensionInterface; |
||
7 | use Metadata\Driver\DriverInterface; |
||
8 | |||
9 | /** |
||
10 | * @author Adrien Brault <[email protected]> |
||
11 | */ |
||
12 | class ExtensionDriver implements DriverInterface |
||
13 | { |
||
14 | /** |
||
15 | * @var DriverInterface |
||
16 | */ |
||
17 | private $delegate; |
||
18 | |||
19 | /** |
||
20 | * @var ConfigurationExtensionInterface[] |
||
21 | */ |
||
22 | private $extensions; |
||
23 | |||
24 | public function __construct(DriverInterface $delegate, array $extensions = []) |
||
25 | { |
||
26 | $this->delegate = $delegate; |
||
27 | $this->extensions = $extensions; |
||
28 | } |
||
29 | |||
30 | /** |
||
31 | * {@inheritdoc} |
||
32 | */ |
||
33 | public function loadMetadataForClass(\ReflectionClass $class) |
||
34 | { |
||
35 | $metadata = $this->delegate->loadMetadataForClass($class); |
||
36 | $newMetadata = false; |
||
37 | |||
38 | if (empty($this->extensions)) { |
||
39 | return $metadata; |
||
40 | } |
||
41 | |||
42 | if (null === $metadata) { |
||
43 | $metadata = new ClassMetadata($class->getName()); |
||
44 | $newMetadata = true; |
||
45 | } |
||
46 | |||
47 | foreach ($this->extensions as $extension) { |
||
48 | $extension->decorate($metadata); |
||
0 ignored issues
–
show
|
|||
49 | } |
||
50 | |||
51 | if ($newMetadata && count($metadata->getRelations()) < 1 && count($metadata->getRelationProviders()) < 1) { |
||
52 | $metadata = null; |
||
53 | } |
||
54 | |||
55 | return $metadata; |
||
56 | } |
||
57 | |||
58 | /** |
||
59 | * @param ConfigurationExtensionInterface $extension |
||
60 | */ |
||
61 | public function registerExtension(ConfigurationExtensionInterface $extension) |
||
62 | { |
||
63 | $this->extensions[] = $extension; |
||
64 | } |
||
65 | } |
||
66 |
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: