kodeart /
koded
| 1 | <?php |
||
| 2 | |||
| 3 | namespace Koded\Framework\Middleware; |
||
| 4 | |||
| 5 | use Psr\Http\Message\{ResponseInterface, ServerRequestInterface}; |
||
| 6 | use Psr\Http\Server\{MiddlewareInterface, RequestHandlerInterface}; |
||
| 7 | |||
| 8 | class XPoweredByMiddleware implements MiddlewareInterface |
||
| 9 | { |
||
| 10 | 2 | public function __construct(private string|null $value = null) |
|
| 11 | { |
||
| 12 | 2 | @header_remove('x-powered-by'); |
|
|
0 ignored issues
–
show
Are you sure the usage of
header_remove('x-powered-by') is correct as it seems to always return null.
This check looks for function or method calls that always return null and whose return value is used. class A
{
function getObject()
{
return null;
}
}
$a = new A();
if ($a->getObject()) {
The method The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes. Loading history...
|
|||
| 13 | } |
||
| 14 | |||
| 15 | 2 | public function process( |
|
| 16 | ServerRequestInterface $request, |
||
| 17 | RequestHandlerInterface $handler): ResponseInterface |
||
| 18 | { |
||
| 19 | 2 | $response = $handler->handle($request); |
|
| 20 | 2 | if (null === $this->value) { |
|
| 21 | 1 | return $response; |
|
| 22 | } |
||
| 23 | 1 | return $response->withHeader('x-powered-by', $this->value); |
|
|
0 ignored issues
–
show
|
|||
| 24 | } |
||
| 25 | } |
||
| 26 |
If you suppress an error, we recommend checking for the error condition explicitly: