1 | <?php |
||||
2 | |||||
3 | namespace Zenstruck\Foundry; |
||||
4 | |||||
5 | use Doctrine\Persistence\ManagerRegistry; |
||||
6 | use Doctrine\Persistence\Mapping\MappingException; |
||||
7 | use Doctrine\Persistence\ObjectManager; |
||||
8 | use Doctrine\Persistence\ObjectRepository; |
||||
9 | |||||
10 | /** |
||||
11 | * @internal |
||||
12 | */ |
||||
13 | final class ChainManagerRegistry implements ManagerRegistry |
||||
14 | { |
||||
15 | /** @var list<ManagerRegistry> */ |
||||
0 ignored issues
–
show
|
|||||
16 | private $managerRegistries; |
||||
17 | |||||
18 | /** @param list<ManagerRegistry> $managerRegistries */ |
||||
19 | public function __construct(array $managerRegistries) |
||||
20 | { |
||||
21 | if (0 === \count($managerRegistries)) { |
||||
22 | throw new \InvalidArgumentException('no manager registry provided'); |
||||
23 | } |
||||
24 | |||||
25 | $this->managerRegistries = $managerRegistries; |
||||
0 ignored issues
–
show
It seems like
$managerRegistries of type array is incompatible with the declared type Zenstruck\Foundry\list of property $managerRegistries .
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property. Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property.. ![]() |
|||||
26 | } |
||||
27 | |||||
28 | public function getRepository($persistentObject, $persistentManagerName = null): ObjectRepository |
||||
29 | { |
||||
30 | foreach ($this->managerRegistries as $managerRegistry) { |
||||
31 | try { |
||||
32 | if ($repository = $managerRegistry->getRepository($persistentObject, $persistentManagerName)) { |
||||
33 | return $repository; |
||||
34 | } |
||||
35 | } catch (MappingException $exception) { |
||||
36 | // the class is not managed by the current manager |
||||
37 | } |
||||
38 | } |
||||
39 | |||||
40 | throw new \LogicException("Cannot find repository for class {$persistentObject}"); |
||||
41 | } |
||||
42 | |||||
43 | public function getManagerForClass($class): ?ObjectManager |
||||
44 | { |
||||
45 | foreach ($this->managerRegistries as $managerRegistry) { |
||||
46 | if ($managerForClass = $managerRegistry->getManagerForClass($class)) { |
||||
47 | return $managerForClass; |
||||
48 | } |
||||
49 | } |
||||
50 | |||||
51 | return null; |
||||
52 | } |
||||
53 | |||||
54 | public function getManagers(): array |
||||
55 | { |
||||
56 | return \array_reduce( |
||||
57 | $this->managerRegistries, |
||||
0 ignored issues
–
show
$this->managerRegistries of type Zenstruck\Foundry\list is incompatible with the type array expected by parameter $array of array_reduce() .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
58 | static function(array $carry, ManagerRegistry $managerRegistry) { |
||||
59 | return \array_merge($carry, \array_values($managerRegistry->getManagers())); |
||||
60 | }, |
||||
61 | [] |
||||
62 | ); |
||||
63 | } |
||||
64 | |||||
65 | public function getDefaultConnectionName(): string |
||||
66 | { |
||||
67 | throw new \BadMethodCallException('Not available in '.self::class); |
||||
68 | } |
||||
69 | |||||
70 | public function getConnection($name = null): object |
||||
71 | { |
||||
72 | throw new \BadMethodCallException('Not available in '.self::class); |
||||
73 | } |
||||
74 | |||||
75 | public function getConnections(): array |
||||
76 | { |
||||
77 | throw new \BadMethodCallException('Not available in '.self::class); |
||||
78 | } |
||||
79 | |||||
80 | public function getConnectionNames(): array |
||||
81 | { |
||||
82 | throw new \BadMethodCallException('Not available in '.self::class); |
||||
83 | } |
||||
84 | |||||
85 | public function getDefaultManagerName(): string |
||||
86 | { |
||||
87 | throw new \BadMethodCallException('Not available in '.self::class); |
||||
88 | } |
||||
89 | |||||
90 | public function getManager($name = null): ObjectManager |
||||
91 | { |
||||
92 | throw new \BadMethodCallException('Not available in '.self::class); |
||||
93 | } |
||||
94 | |||||
95 | public function resetManager($name = null): ObjectManager |
||||
96 | { |
||||
97 | throw new \BadMethodCallException('Not available in '.self::class); |
||||
98 | } |
||||
99 | |||||
100 | public function getAliasNamespace($alias): string |
||||
101 | { |
||||
102 | throw new \BadMethodCallException('Not available in '.self::class); |
||||
103 | } |
||||
104 | |||||
105 | public function getManagerNames(): array |
||||
106 | { |
||||
107 | throw new \BadMethodCallException('Not available in '.self::class); |
||||
108 | } |
||||
109 | } |
||||
110 |
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