Failed Conditions
Push — master ( 2a7938...ff349a )
by Sander
27:39 queued 19:45
created

middleware/apimiddleware.php (1 issue)

Labels
Severity

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
namespace OCA\Passman\Middleware;
4
5
use OCP\AppFramework\Http\JSONResponse;
6
use OCP\AppFramework\Http\Response;
7
use \OCP\AppFramework\Middleware;
8
use OCP\IRequest;
9
10
class APIMiddleware extends Middleware {
11
12
	private $request;
13
14
	public function __construct(IRequest $request) {
15
		$this->request = $request;
16
	}
17
18
	public function afterController($controller, $methodName, Response $response) {
19
		if($response instanceof JSONResponse){
0 ignored issues
show
The class OCP\AppFramework\Http\JSONResponse does not exist. Did you forget a USE statement, or did you not list all dependencies?

This error could be the result of:

1. Missing dependencies

PHP Analyzer uses your composer.json file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects the composer.json to be in the root folder of your repository.

Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the require or require-dev section?

2. Missing use statement

PHP does not complain about undefined classes in ìnstanceof checks. For example, the following PHP code will work perfectly fine:

if ($x instanceof DoesNotExist) {
    // Do something.
}

If you have not tested against this specific condition, such errors might go unnoticed.

Loading history...
20
			$origin = $this->request->server['HTTP_ORIGIN'];
21
			if($origin) {
22
				$response->addHeader('Access-Control-Allow-Origin', $origin);
23
			}
24
		}
25
		return parent::afterController($controller, $methodName, $response);
26
	}
27
}
28
29
30