litphp /
bolt
| 1 | <?php |
||
| 2 | |||
| 3 | declare(strict_types=1); |
||
| 4 | |||
| 5 | namespace Lit\Bolt\Router; |
||
| 6 | |||
| 7 | use Lit\Air\ContainerStub; |
||
|
0 ignored issues
–
show
|
|||
| 8 | use Lit\Air\Factory; |
||
| 9 | use Lit\Nimo\Handlers\CallableHandler; |
||
| 10 | use Lit\Nimo\Handlers\FixedResponseHandler; |
||
| 11 | use Lit\Voltage\Interfaces\RouterStubResolverInterface; |
||
| 12 | use Psr\Container\ContainerInterface; |
||
| 13 | use Psr\Http\Message\ResponseInterface; |
||
| 14 | use Psr\Http\Server\RequestHandlerInterface; |
||
| 15 | |||
| 16 | /** |
||
| 17 | * Standard stub resolver using DI container to resolve stubs |
||
| 18 | */ |
||
| 19 | class BoltStubResolver implements RouterStubResolverInterface |
||
| 20 | { |
||
| 21 | /** |
||
| 22 | * @var ContainerInterface |
||
| 23 | */ |
||
| 24 | protected $container; |
||
| 25 | /** |
||
| 26 | * @var mixed |
||
| 27 | */ |
||
| 28 | protected $notFound; |
||
| 29 | |||
| 30 | 1 | public function __construct(ContainerInterface $container, $notFound = null) |
|
| 31 | { |
||
| 32 | 1 | $this->container = $container; |
|
| 33 | 1 | $this->notFound = $notFound; |
|
| 34 | 1 | } |
|
| 35 | |||
| 36 | /** |
||
| 37 | * Resolve the stub and return a RequestHandler |
||
| 38 | * |
||
| 39 | * @param mixed $stub The stub value to be resolved. |
||
| 40 | * @return RequestHandlerInterface |
||
| 41 | */ |
||
| 42 | 1 | public function resolve($stub): RequestHandlerInterface |
|
| 43 | { |
||
| 44 | 1 | if ($stub === null && $this->notFound) { |
|
| 45 | $stub = $this->notFound; |
||
| 46 | } |
||
| 47 | |||
| 48 | 1 | if (is_callable($stub)) { |
|
| 49 | return new CallableHandler($stub); |
||
| 50 | } |
||
| 51 | |||
| 52 | 1 | if ($stub instanceof RequestHandlerInterface) { |
|
| 53 | 1 | return $stub; |
|
| 54 | } |
||
| 55 | |||
| 56 | 1 | if ($stub instanceof ResponseInterface) { |
|
| 57 | 1 | return FixedResponseHandler::wrap($stub); |
|
| 58 | } |
||
| 59 | |||
| 60 | 1 | $containerStub = ContainerStub::tryParse($stub); |
|
| 61 | if (!$containerStub) { |
||
| 62 | /** @var StubResolveException $exception */ |
||
| 63 | $exception = Factory::of($this->container)->instantiate(StubResolveException::class, [ |
||
| 64 | 'stub' => $stub, |
||
| 65 | ]); |
||
| 66 | |||
| 67 | throw $exception; |
||
| 68 | } |
||
| 69 | |||
| 70 | $handler = $containerStub->instantiateFrom($this->container); |
||
| 71 | assert($handler instanceof RequestHandlerInterface); |
||
| 72 | return $handler; |
||
| 73 | } |
||
| 74 | } |
||
| 75 |
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