Issues (1358)

modules/Psr15/Middleware.php (5 issues)

Labels
Severity
1
<?php
2
/**
3
 * @package  Psr15
4
 * @category modules
5
 * @author   Nazar Mokrynskyi <[email protected]>
6
 * @license  0BSD
7
 */
8
namespace cs\modules\Psr15;
9
use
10
	cs\App,
11
	cs\ExitException,
12
	cs\Page,
13
	cs\Response as System_response,
14
	cs\User,
15
	cs\modules\Psr7\Request,
16
	cs\modules\Psr7\Response,
17
	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. 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...
18
	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. 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...
19
	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. 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...
20
	Psr\Http\Message\ResponseInterface;
0 ignored issues
show
The type Psr\Http\Message\ResponseInterface 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...
21
22
class Middleware implements MiddlewareInterface {
23
	private $memory_cache_disabled = false;
24
	/**
25
	 * @var string
26
	 */
27
	protected $psr7_response_class_name;
28
	/**
29
	 * @param string $psr7_response_class_name
30
	 */
31
	public function __construct ($psr7_response_class_name) {
32
		$this->psr7_response_class_name = $psr7_response_class_name;
33
	}
34
	/**
35
	 * @inheritdoc
36
	 */
37
	public function process (ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface {
38
		try {
39
			System_response::instance()->init_with_typical_default_settings();
0 ignored issues
show
The method init_with_typical_default_settings() does not exist on cs\False_class. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

39
			System_response::instance()->/** @scrutinizer ignore-call */ init_with_typical_default_settings();
Loading history...
40
			Request::init_from_psr7($request);
41
			App::instance()->execute();
42
			if (!$this->memory_cache_disabled) {
43
				$this->memory_cache_disabled = true;
44
				User::instance()->disable_memory_cache();
45
			}
46
		} catch (ExitException $e) {
47
			if ($e->getCode() >= 400) {
48
				Page::instance()->error($e->getMessage() ?: null, $e->getJson());
49
			}
50
		}
51
		return Response::output_to_psr7(new $this->psr7_response_class_name);
52
	}
53
}
54