yiisoft /
demo
| 1 | <?php |
||
| 2 | |||
| 3 | declare(strict_types=1); |
||
| 4 | |||
| 5 | namespace App\Middleware; |
||
| 6 | |||
| 7 | use App\Exception\ApplicationException; |
||
| 8 | use Psr\Http\Message\ResponseInterface; |
||
|
0 ignored issues
–
show
|
|||
| 9 | use Psr\Http\Message\ServerRequestInterface; |
||
|
0 ignored issues
–
show
The type
Psr\Http\Message\ServerRequestInterface 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...
|
|||
| 10 | use Psr\Http\Server\MiddlewareInterface; |
||
|
0 ignored issues
–
show
The type
Psr\Http\Server\MiddlewareInterface 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...
|
|||
| 11 | use Psr\Http\Server\RequestHandlerInterface; |
||
|
0 ignored issues
–
show
The type
Psr\Http\Server\RequestHandlerInterface 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...
|
|||
| 12 | use Yiisoft\DataResponse\DataResponseFactoryInterface; |
||
|
0 ignored issues
–
show
The type
Yiisoft\DataResponse\DataResponseFactoryInterface 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...
|
|||
| 13 | use Yiisoft\Http\Status; |
||
|
0 ignored issues
–
show
The type
Yiisoft\Http\Status 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...
|
|||
| 14 | use Yiisoft\Input\Http\InputValidationException; |
||
|
0 ignored issues
–
show
The type
Yiisoft\Input\Http\InputValidationException 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...
|
|||
| 15 | |||
| 16 | final class ExceptionMiddleware implements MiddlewareInterface |
||
| 17 | { |
||
| 18 | private DataResponseFactoryInterface $dataResponseFactory; |
||
| 19 | |||
| 20 | public function __construct(DataResponseFactoryInterface $dataResponseFactory) |
||
| 21 | { |
||
| 22 | $this->dataResponseFactory = $dataResponseFactory; |
||
| 23 | } |
||
| 24 | |||
| 25 | public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface |
||
| 26 | { |
||
| 27 | try { |
||
| 28 | return $handler->handle($request); |
||
| 29 | } catch (ApplicationException $e) { |
||
| 30 | return $this->dataResponseFactory->createResponse($e->getMessage(), $e->getCode()); |
||
| 31 | } catch (InputValidationException $e) { |
||
| 32 | return $this->dataResponseFactory->createResponse($e->getResult()->getErrorMessages()[0], Status::BAD_REQUEST); |
||
| 33 | } |
||
| 34 | } |
||
| 35 | } |
||
| 36 |
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