ray-di /
Ray.Di
| 1 | <?php |
||
| 2 | |||
| 3 | declare(strict_types=1); |
||
| 4 | |||
| 5 | namespace Ray\Di; |
||
| 6 | |||
| 7 | use Ray\Aop\Compiler; |
||
| 8 | |||
| 9 | use function file_exists; |
||
| 10 | use function spl_autoload_register; |
||
| 11 | use function sprintf; |
||
| 12 | use function str_replace; |
||
| 13 | |||
| 14 | /** |
||
| 15 | * @psalm-import-type MethodArguments from Types |
||
| 16 | * @psalm-import-type ScriptDir from Types |
||
| 17 | */ |
||
| 18 | final class Grapher |
||
| 19 | { |
||
| 20 | private Container $container; |
||
| 21 | |||
| 22 | /** |
||
| 23 | * @param AbstractModule $module Binding module |
||
| 24 | * @param ScriptDir $classDir Class directory |
||
|
0 ignored issues
–
show
|
|||
| 25 | */ |
||
| 26 | public function __construct(AbstractModule $module, private string $classDir) |
||
| 27 | { |
||
| 28 | $module->install(new AssistedModule()); |
||
| 29 | $this->container = $module->getContainer(); |
||
| 30 | /** @psalm-suppress InvalidArgument */ |
||
| 31 | $this->container->weaveAspects(new Compiler($this->classDir)); |
||
| 32 | |||
| 33 | // builtin injection |
||
| 34 | (new Bind($this->container, InjectorInterface::class))->toInstance(new Injector($module)); |
||
| 35 | } |
||
| 36 | |||
| 37 | /** |
||
| 38 | * Wakeup |
||
| 39 | */ |
||
| 40 | public function __wakeup() |
||
| 41 | { |
||
| 42 | spl_autoload_register( |
||
| 43 | function (string $class): void { |
||
| 44 | $file = sprintf('%s/%s.php', $this->classDir, str_replace('\\', '_', $class)); |
||
| 45 | if (file_exists($file)) { |
||
| 46 | include $file; //@codeCoverageIgnore |
||
| 47 | } |
||
| 48 | } |
||
| 49 | ); |
||
| 50 | } |
||
| 51 | |||
| 52 | /** |
||
| 53 | * Build an object graph with give constructor parameters |
||
| 54 | * |
||
| 55 | * @param string $class class name |
||
| 56 | * @param list<mixed> $params construct parameters (MethodArguments) |
||
|
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...
|
|||
| 57 | * |
||
| 58 | * @return mixed |
||
| 59 | */ |
||
| 60 | public function newInstanceArgs(string $class, array $params) |
||
| 61 | { |
||
| 62 | return $this->container->getInstanceWithArgs($class, $params); |
||
| 63 | } |
||
| 64 | } |
||
| 65 |
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