ray-di /
Ray.Di
| 1 | <?php |
||||
| 2 | |||||
| 3 | declare(strict_types=1); |
||||
| 4 | |||||
| 5 | namespace Ray\Di; |
||||
| 6 | |||||
| 7 | use Ray\Di\Exception\Unbound; |
||||
| 8 | use ReflectionMethod; |
||||
| 9 | |||||
| 10 | /** |
||||
| 11 | * @psalm-import-type ArgumentsList from Types |
||||
| 12 | * @psalm-import-type MethodArguments from Types |
||||
| 13 | */ |
||||
| 14 | final class Arguments implements AcceptInterface |
||||
| 15 | { |
||||
| 16 | /** @var ArgumentsList */ |
||||
|
0 ignored issues
–
show
|
|||||
| 17 | private $arguments = []; |
||||
| 18 | |||||
| 19 | public function __construct(ReflectionMethod $method, Name $name) |
||||
| 20 | { |
||||
| 21 | $parameters = $method->getParameters(); |
||||
| 22 | foreach ($parameters as $parameter) { |
||||
| 23 | $this->arguments[] = new Argument($parameter, $name($parameter)); |
||||
| 24 | } |
||||
| 25 | } |
||||
| 26 | |||||
| 27 | /** |
||||
| 28 | * Return arguments |
||||
| 29 | * |
||||
| 30 | * @return list<mixed> |
||||
|
0 ignored issues
–
show
The type
Ray\Di\list was not found. Maybe you did not declare it correctly or list all dependencies?
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. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||||
| 31 | * |
||||
| 32 | * @throws Exception\Unbound |
||||
| 33 | */ |
||||
| 34 | public function inject(Container $container): array |
||||
| 35 | { |
||||
| 36 | $parameters = []; |
||||
| 37 | foreach ($this->arguments as $parameter) { |
||||
| 38 | /** @psalm-suppress MixedAssignment */ |
||||
| 39 | $parameters[] = $this->getParameter($container, $parameter); |
||||
| 40 | } |
||||
| 41 | |||||
| 42 | return $parameters; |
||||
| 43 | } |
||||
| 44 | |||||
| 45 | public function accept(VisitorInterface $visitor) |
||||
| 46 | { |
||||
| 47 | $visitor->visitArguments($this->arguments); |
||||
|
0 ignored issues
–
show
$this->arguments of type Ray\Di\ArgumentsList is incompatible with the type array expected by parameter $arguments of Ray\Di\VisitorInterface::visitArguments().
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 48 | } |
||||
| 49 | |||||
| 50 | /** |
||||
| 51 | * @return mixed |
||||
| 52 | * |
||||
| 53 | * @throws Unbound |
||||
| 54 | */ |
||||
| 55 | private function getParameter(Container $container, Argument $argument) |
||||
| 56 | { |
||||
| 57 | $this->bindInjectionPoint($container, $argument); |
||||
| 58 | try { |
||||
| 59 | return $container->getDependency((string) $argument); |
||||
| 60 | } catch (Unbound $e) { |
||||
| 61 | if ($argument->isDefaultAvailable()) { |
||||
| 62 | return $argument->getDefaultValue(); |
||||
| 63 | } |
||||
| 64 | |||||
| 65 | throw new Unbound($argument->getMeta(), 0, $e); |
||||
| 66 | } |
||||
| 67 | } |
||||
| 68 | |||||
| 69 | private function bindInjectionPoint(Container $container, Argument $argument): void |
||||
| 70 | { |
||||
| 71 | $isSelf = (string) $argument === InjectionPointInterface::class . '-' . Name::ANY; |
||||
| 72 | if ($isSelf) { |
||||
| 73 | return; |
||||
| 74 | } |
||||
| 75 | |||||
| 76 | (new Bind($container, InjectionPointInterface::class))->toInstance(new InjectionPoint($argument->get())); |
||||
| 77 | } |
||||
| 78 | } |
||||
| 79 |
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