StaticValue::returnValue()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
1
<?php
2
/*
3
 * This file is part of the Respect\Rest package.
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 */
8
9
namespace Respect\Rest\Routes;
10
11
use ReflectionMethod;
12
13
/** A callback-based route */
14
class StaticValue extends AbstractRoute
15
{
16
    protected $value;
17
    /** @var ReflectionFunctionAbstract */
18
    protected $reflection;
19
20 13
    public function __construct($method, $pattern, $value)
21
    {
22 13
        $this->value = $value;
23 13
        parent::__construct($method, $pattern);
24 13
        $this->reflection = new ReflectionMethod($this, 'returnValue');
0 ignored issues
show
Documentation Bug introduced by
It seems like new \ReflectionMethod($this, 'returnValue') of type object<ReflectionMethod> is incompatible with the declared type object<Respect\Rest\Rout...ectionFunctionAbstract> of property $reflection.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
25 13
    }
26
27 10
    public function getReflection($method)
28
    {
29 10
        return $this->reflection;
30
    }
31
32 10
    public function runTarget($method, &$params)
33
    {
34 10
        return $this->returnValue($method, $params);
0 ignored issues
show
Unused Code introduced by
The call to StaticValue::returnValue() has too many arguments starting with $method.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
35
    }
36
37 10
    public function returnValue()
38
    {
39 10
        return $this->value;
40
    }
41
}
42