Issues (101)

src/di/AspectBind.php (2 issues)

1
<?php
2
3
declare(strict_types=1);
4
5
namespace Ray\Di;
6
7
use Ray\Aop\Bind as AopBind;
8
use Ray\Aop\MethodInterceptor;
9
10
use function assert;
11
12
/**
13
 * @psalm-import-type MethodInterceptorBindings from Types
14
 */
15
final class AspectBind implements AcceptInterface
16
{
17
    /** @var AopBind */
18
    private $bind;
19
20
    public function __construct(AopBind $bind)
21
    {
22
        $this->bind = $bind;
23
    }
24
25
    /**
26
     * Instantiate interceptors
27
     *
28
     * @return MethodInterceptorBindings
0 ignored issues
show
The type Ray\Di\MethodInterceptorBindings 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. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
29
     */
30
    public function inject(Container $container): array
31
    {
32
        $bindings = $this->bind->getBindings();
33
        $instantiatedBindings = [];
34
        foreach ($bindings as $methodName => $interceptorClassNames) {
35
            $interceptors = [];
36
            foreach ($interceptorClassNames as $interceptorClassName) {
37
                /** @var class-string $interceptorClassName */
38
                $interceptor = $container->getInstance($interceptorClassName);
39
                assert($interceptor instanceof MethodInterceptor);
40
                $interceptors[] = $interceptor;
41
            }
42
43
            $instantiatedBindings[$methodName] = $interceptors;
44
        }
45
46
        return $instantiatedBindings;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $instantiatedBindings returns the type array which is incompatible with the documented return type Ray\Di\MethodInterceptorBindings.
Loading history...
47
    }
48
49
    /** @inheritDoc */
50
    public function accept(VisitorInterface $visitor)
51
    {
52
        $visitor->visitAspectBind($this->bind);
53
    }
54
}
55