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 | /** @var ScriptDir */ |
||
|
0 ignored issues
–
show
|
|||
| 21 | private $classDir; |
||
| 22 | |||
| 23 | /** @var Container */ |
||
| 24 | private $container; |
||
| 25 | |||
| 26 | /** |
||
| 27 | * @param AbstractModule $module Binding module |
||
| 28 | * @param ScriptDir $classDir Class directory |
||
| 29 | */ |
||
| 30 | public function __construct(AbstractModule $module, string $classDir) |
||
| 31 | { |
||
| 32 | $module->install(new AssistedModule()); |
||
| 33 | $this->container = $module->getContainer(); |
||
| 34 | $this->classDir = $classDir; |
||
|
0 ignored issues
–
show
It seems like
$classDir of type string is incompatible with the declared type Ray\Di\ScriptDir of property $classDir.
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.. Loading history...
|
|||
| 35 | /** @psalm-suppress InvalidArgument */ |
||
| 36 | $this->container->weaveAspects(new Compiler($this->classDir)); |
||
| 37 | |||
| 38 | // builtin injection |
||
| 39 | (new Bind($this->container, InjectorInterface::class))->toInstance(new Injector($module)); |
||
| 40 | } |
||
| 41 | |||
| 42 | /** |
||
| 43 | * Wakeup |
||
| 44 | */ |
||
| 45 | public function __wakeup() |
||
| 46 | { |
||
| 47 | spl_autoload_register( |
||
| 48 | function (string $class): void { |
||
| 49 | $file = sprintf('%s/%s.php', $this->classDir, str_replace('\\', '_', $class)); |
||
| 50 | if (file_exists($file)) { |
||
| 51 | include $file; //@codeCoverageIgnore |
||
| 52 | } |
||
| 53 | } |
||
| 54 | ); |
||
| 55 | } |
||
| 56 | |||
| 57 | /** |
||
| 58 | * Build an object graph with give constructor parameters |
||
| 59 | * |
||
| 60 | * @param string $class class name |
||
| 61 | * @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...
|
|||
| 62 | * |
||
| 63 | * @return mixed |
||
| 64 | */ |
||
| 65 | public function newInstanceArgs(string $class, array $params) |
||
| 66 | { |
||
| 67 | return $this->container->getInstanceWithArgs($class, $params); |
||
| 68 | } |
||
| 69 | } |
||
| 70 |
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