MethodGenerator   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 1
dl 0
loc 32
ccs 5
cts 5
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A fromReflectionWithoutBodyAndDocBlock() 0 10 1
A getDocBlock() 0 4 1
A getSourceContent() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace ProxyManager\Generator;
6
7
use Laminas\Code\Generator\DocBlockGenerator;
8
use Laminas\Code\Generator\MethodGenerator as ZendMethodGenerator;
9
use Laminas\Code\Reflection\MethodReflection;
10
11
/**
12
 * Method generator that fixes minor quirks in ZF2's method generator
13
 */
14
class MethodGenerator extends ZendMethodGenerator
15
{
16
    /**
17
     * @return static
18
     */
19
    public static function fromReflectionWithoutBodyAndDocBlock(MethodReflection $reflectionMethod) : self
20
    {
21 19
        /** @var static $method */
22
        $method = parent::copyMethodSignature($reflectionMethod);
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (copyMethodSignature() instead of fromReflectionWithoutBodyAndDocBlock()). Are you sure this is correct? If so, you might want to change this to $this->copyMethodSignature().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
23
24 19
        $method->setInterface(false);
25
        $method->setBody('');
26 19
27 19
        return $method;
28
    }
29 19
30
    /**
31
     * {@inheritDoc} override needed to specify type in more detail
32
     */
33
    public function getDocBlock() : ?DocBlockGenerator
34
    {
35
        return parent::getDocBlock();
36
    }
37
38
    /**
39
     * {@inheritDoc} override needed to specify type in more detail
40
     */
41
    public function getSourceContent() : ?string
42
    {
43
        return parent::getSourceContent();
44
    }
45
}
46