GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Pull Request — master (#10)
by Lukáš
01:47
created

ResourcePresenter::checkRequirements()   B

Complexity

Conditions 5
Paths 5

Size

Total Lines 25
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 25
c 0
b 0
f 0
rs 8.439
cc 5
eloc 16
nc 5
nop 1
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace Lookyman\Nette\OAuth2\Server\UI;
6
7
use League\OAuth2\Server\Exception\OAuthServerException;
8
use League\OAuth2\Server\ResourceServer;
9
use Lookyman\Nette\OAuth2\Server\Psr7\ApplicationPsr7ResponseInterface;
10
use Nette\Application\UI\ComponentReflection;
11
use Nette\Application\UI\Presenter;
12
use Nette\Http\IResponse;
13
use Psr\Http\Message\ServerRequestInterface;
14
use Psr\Log\LoggerAwareInterface;
15
use Psr\Log\LoggerAwareTrait;
16
17
/**
18
 * @method void onAuthorized(ServerRequestInterface $request)
19
 */
20
abstract class ResourcePresenter extends Presenter implements LoggerAwareInterface
21
{
22
	use LoggerAwareTrait;
23
	use Psr7Trait;
24
25
	/**
26
	 * @var callable[]
27
	 */
28
	public $onAuthorized;
29
30
	/**
31
	 * @var ResourceServer
32
	 * @inject
33
	 */
34
	public $resourceServer;
35
36
	/**
37
	 * @param mixed $element
38
	 */
39
	final public function checkRequirements($element)
40
	{
41
		if (!$element instanceof ComponentReflection) {
0 ignored issues
show
Bug introduced by
The class Nette\Application\UI\ComponentReflection 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...
42
			return;
43
		}
44
45
		$request = $this->createServerRequest();
46
		$response = $this->createResponse();
47
		try {
48
			$request = $this->resourceServer->validateAuthenticatedRequest($request);
49
50
		} catch (OAuthServerException $e) {
0 ignored issues
show
Bug introduced by
The class League\OAuth2\Server\Exc...on\OAuthServerException does not exist. Did you forget a USE statement, or did you not list all dependencies?

Scrutinizer analyzes your composer.json/composer.lock file if available to determine the classes, and functions that are defined by your dependencies.

It seems like the listed class was neither found in your dependencies, nor was it found in the analyzed files in your repository. If you are using some other form of dependency management, you might want to disable this analysis.

Loading history...
51
			/** @var ApplicationPsr7ResponseInterface $response */
52
			$response = $e->generateHttpResponse($response);
53
			$this->sendResponse($response);
54
55
		} catch (\Throwable $e) {
56
			if ($this->logger) {
57
				$this->logger->error($e->getMessage(), ['exception' => $e]);
58
			}
59
			$body = $this->createStream();
60
			$body->write('Unknown error');
61
			/** @var ApplicationPsr7ResponseInterface $response */
62
			$response = $response->withStatus(IResponse::S500_INTERNAL_SERVER_ERROR)->withBody($body);
63
			$this->sendResponse($response);
64
		}
65
66
		$this->onAuthorized($request);
67
	}
68
69
}
70