1 | <?php |
||||||
2 | |||||||
3 | namespace SMartins\JsonHandler; |
||||||
4 | |||||||
5 | use Illuminate\Auth\Access\AuthorizationException; |
||||||
0 ignored issues
–
show
|
|||||||
6 | |||||||
7 | trait AuthorizationHandler |
||||||
8 | { |
||||||
9 | public function authorizationException(AuthorizationException $exception) |
||||||
10 | { |
||||||
11 | $error = [[ |
||||||
12 | 'status' => 403, |
||||||
13 | 'code' => $this->getCode('authorization'), |
||||||
0 ignored issues
–
show
It seems like
getCode() must be provided by classes using this trait. How about adding it as abstract method to this trait?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
14 | 'source' => ['pointer' => $exception->getFile().':'.$exception->getLine()], |
||||||
15 | 'title' => __('exception::exceptions.authorization.title'), |
||||||
0 ignored issues
–
show
The function
__ was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
16 | 'detail' => $exception->getMessage(), |
||||||
17 | ]]; |
||||||
18 | |||||||
19 | $this->jsonApiResponse->setStatus(403); |
||||||
0 ignored issues
–
show
|
|||||||
20 | $this->jsonApiResponse->setErrors($error); |
||||||
21 | } |
||||||
22 | |||||||
23 | public function generateDescription($traces) |
||||||
24 | { |
||||||
25 | $action = ''; |
||||||
0 ignored issues
–
show
|
|||||||
26 | foreach ($traces as $trace) { |
||||||
27 | if ($trace['function'] === 'authorize') { |
||||||
28 | $action = $this->extractAction($trace['args']); |
||||||
0 ignored issues
–
show
Are you sure the assignment to
$action is correct as $this->extractAction($trace['args']) targeting SMartins\JsonHandler\Aut...andler::extractAction() seems to always return null.
This check looks for function or method calls that always return null and whose return value is assigned to a variable. class A
{
function getObject()
{
return null;
}
}
$a = new A();
$object = $a->getObject();
The method The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes. ![]() |
|||||||
29 | break; |
||||||
30 | } |
||||||
31 | } |
||||||
32 | } |
||||||
33 | |||||||
34 | public function extractAction($args) |
||||||
35 | { |
||||||
36 | $action = reset($args); |
||||||
37 | |||||||
38 | $this->getWord($action); |
||||||
0 ignored issues
–
show
The method
getWord() does not exist on SMartins\JsonHandler\AuthorizationHandler . Did you maybe mean getWords() ?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed. ![]() |
|||||||
39 | } |
||||||
40 | |||||||
41 | public function getWords($action) |
||||||
42 | { |
||||||
43 | $words = explode('.', $action); |
||||||
44 | if (! (count($words) > 1)) { |
||||||
45 | $words = explode('-', $action); |
||||||
46 | if (! (count($words) > 1)) { |
||||||
47 | $words = preg_split('/(?=[A-Z])/', $action); |
||||||
0 ignored issues
–
show
|
|||||||
48 | } |
||||||
49 | } |
||||||
50 | } |
||||||
51 | } |
||||||
52 |
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