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.

ReflectionMethod   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 88
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 9
lcom 1
cbo 5
dl 0
loc 88
ccs 31
cts 31
cp 1
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getDeclaringClass() 0 4 1
A getPrototype() 0 6 1
A getBody() 0 22 3
A getParameters() 0 11 2
A getExtension() 0 9 2
1
<?php
2
3
namespace Wingu\OctopusCore\Reflection;
4
5
use Wingu\OctopusCore\Reflection\Exceptions\RuntimeException;
6
7
/**
8
 * Reflection about a method.
9
 */
10
class ReflectionMethod extends \ReflectionMethod
11
{
12
13
    use ReflectionDocCommentTrait;
14
15
    /**
16
     * Gets declaring class.
17
     *
18
     * @return \Wingu\OctopusCore\Reflection\ReflectionClass
19
     */
20 33
    public function getDeclaringClass()
21
    {
22 33
        return new ReflectionClass(parent::getDeclaringClass()->getName());
23
    }
24
25
    /**
26
     * Gets prototype.
27
     *
28
     * @return \Wingu\OctopusCore\Reflection\ReflectionMethod
29
     */
30 3
    public function getPrototype()
31
    {
32 3
        $prototype = parent::getPrototype();
33
34 3
        return new static($prototype->getDeclaringClass()->getName(), $prototype->getName());
35
    }
36
37
    /**
38
     * Get the body of the method.
39
     *
40
     * @return string
41
     * @throws \Wingu\OctopusCore\Reflection\Exceptions\RuntimeException If the method belongs to an internal class or is abstract.
42
     */
43 27
    public function getBody()
44
    {
45 27
        if ($this->isAbstract() === true) {
46 6
            throw new RuntimeException('Can not get body of an abstract method');
47
        }
48
49 21
        $fileName = $this->getDeclaringClass()->getFileName();
50 21
        if ($fileName === false) {
51 3
            throw new RuntimeException('Can not get body of a method belonging to an internal class.');
52
        }
53
54 18
        $lines = file($fileName, FILE_IGNORE_NEW_LINES);
55 18
        $lines = array_slice($lines, $this->getStartLine() - 1, ($this->getEndLine() - $this->getStartLine() + 1),
56 18
            true);
57 18
        $lines = implode("\n", $lines);
58
59 18
        $firstBracketPos = strpos($lines, '{');
60 18
        $lastBracketPost = strrpos($lines, '}');
61 18
        $body = substr($lines, $firstBracketPos + 1, $lastBracketPost - $firstBracketPos - 1);
62
63 18
        return trim(rtrim($body), "\n\r");
64
    }
65
66
    /**
67
     * Gets parameters.
68
     *
69
     * @return \Wingu\OctopusCore\Reflection\ReflectionParameter[]
70
     */
71 6
    public function getParameters()
72
    {
73 6
        $function = array($this->getDeclaringClass()->getName(), $this->getName());
74 6
        $res = parent::getParameters();
75
76 6
        foreach ($res as $key => $val) {
77 3
            $res[$key] = new ReflectionParameter($function, $val->getName());
0 ignored issues
show
Documentation introduced by
$function is of type array<integer,string,{"0":"string","1":"string"}>, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
78 2
        }
79
80 6
        return $res;
81
    }
82
83
    /**
84
     * Gets extension info.
85
     *
86
     * @return \Wingu\OctopusCore\Reflection\ReflectionExtension
87
     */
88 6
    public function getExtension()
89
    {
90 6
        $extensionName =  $this->getExtensionName();
91 6
        if ($extensionName !== false) {
92 3
            return new ReflectionExtension($extensionName);
93
        } else {
94 3
            return null;
95
        }
96
    }
97
}
98