testInterceptorGeneratorWithVoidMethod()   B
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 58

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 58
rs 8.9163
c 0
b 0
f 0
cc 1
nc 1
nop 0

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
declare(strict_types=1);
4
5
namespace ProxyManagerTest\ProxyGenerator\AccessInterceptorValueHolder\MethodGenerator\Util;
6
7
use Laminas\Code\Generator\ParameterGenerator;
8
use Laminas\Code\Generator\PropertyGenerator;
9
use PHPUnit\Framework\MockObject\MockObject;
10
use PHPUnit\Framework\TestCase;
11
use ProxyManager\Generator\MethodGenerator;
12
use ProxyManager\ProxyGenerator\AccessInterceptorValueHolder\MethodGenerator\Util\InterceptorGenerator;
13
use ProxyManagerTestAsset\BaseClass;
14
use ProxyManagerTestAsset\VoidMethodTypeHintedInterface;
15
use ReflectionMethod;
16
17
/**
18
 * Tests for {@see \ProxyManager\ProxyGenerator\AccessInterceptorValueHolderGenerator}
19
 *
20
 * @group Coverage
21
 * @covers \ProxyManager\ProxyGenerator\AccessInterceptorValueHolder\MethodGenerator\Util\InterceptorGenerator
22
 */
23
final class InterceptorGeneratorTest extends TestCase
24
{
25
    public function testInterceptorGenerator() : void
26
    {
27
        $method             = $this->createMock(MethodGenerator::class);
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $method is correct as $this->createMock(\Proxy...MethodGenerator::class) (which targets PHPUnit\Framework\TestCase::createMock()) 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 getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
28
        $bar                = $this->createMock(ParameterGenerator::class);
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $bar is correct as $this->createMock(\Lamin...ameterGenerator::class) (which targets PHPUnit\Framework\TestCase::createMock()) 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 getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
29
        $baz                = $this->createMock(ParameterGenerator::class);
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $baz is correct as $this->createMock(\Lamin...ameterGenerator::class) (which targets PHPUnit\Framework\TestCase::createMock()) 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 getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
30
        $valueHolder        = $this->createMock(PropertyGenerator::class);
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $valueHolder is correct as $this->createMock(\Lamin...opertyGenerator::class) (which targets PHPUnit\Framework\TestCase::createMock()) 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 getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
31
        $prefixInterceptors = $this->createMock(PropertyGenerator::class);
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $prefixInterceptors is correct as $this->createMock(\Lamin...opertyGenerator::class) (which targets PHPUnit\Framework\TestCase::createMock()) 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 getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
32
        $suffixInterceptors = $this->createMock(PropertyGenerator::class);
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $suffixInterceptors is correct as $this->createMock(\Lamin...opertyGenerator::class) (which targets PHPUnit\Framework\TestCase::createMock()) 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 getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
33
34
        $bar->method('getName')->willReturn('bar');
0 ignored issues
show
Bug introduced by
The method method cannot be called on $bar (of type null).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
35
        $baz->method('getName')->willReturn('baz');
0 ignored issues
show
Bug introduced by
The method method cannot be called on $baz (of type null).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
36
        $method->method('getName')->willReturn('fooMethod');
0 ignored issues
show
Bug introduced by
The method method cannot be called on $method (of type null).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
37
        $method->method('getParameters')->will(self::returnValue([$bar, $baz]));
0 ignored issues
show
Bug introduced by
The method method cannot be called on $method (of type null).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
Bug introduced by
The method returnValue() does not seem to exist on object<ProxyManagerTest\...terceptorGeneratorTest>.

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.

Loading history...
38
        $valueHolder->method('getName')->willReturn('foo');
0 ignored issues
show
Bug introduced by
The method method cannot be called on $valueHolder (of type null).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
39
        $prefixInterceptors->method('getName')->willReturn('pre');
0 ignored issues
show
Bug introduced by
The method method cannot be called on $prefixInterceptors (of type null).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
40
        $suffixInterceptors->method('getName')->willReturn('post');
0 ignored issues
show
Bug introduced by
The method method cannot be called on $suffixInterceptors (of type null).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
41
42
        // @codingStandardsIgnoreStart
43
        $expected = <<<'PHP'
44
if (isset($this->pre['fooMethod'])) {
45
    $returnEarly       = false;
46
    $prefixReturnValue = $this->pre['fooMethod']->__invoke($this, $this->foo, 'fooMethod', array('bar' => $bar, 'baz' => $baz), $returnEarly);
47
48
    if ($returnEarly) {
49
        return $prefixReturnValue;
50
    }
51
}
52
53
$returnValue = "foo";
54
55
if (isset($this->post['fooMethod'])) {
56
    $returnEarly       = false;
57
    $suffixReturnValue = $this->post['fooMethod']->__invoke($this, $this->foo, 'fooMethod', array('bar' => $bar, 'baz' => $baz), $returnValue, $returnEarly);
58
59
    if ($returnEarly) {
60
        return $suffixReturnValue;
61
    }
62
}
63
64
return $returnValue;
65
PHP;
66
        // @codingStandardsIgnoreEnd
67
68
        self::assertSame(
0 ignored issues
show
Bug introduced by
The method assertSame() does not seem to exist on object<ProxyManagerTest\...terceptorGeneratorTest>.

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.

Loading history...
69
            $expected,
70
            InterceptorGenerator::createInterceptedMethodBody(
71
                '$returnValue = "foo";',
72
                $method,
0 ignored issues
show
Documentation introduced by
$method is of type null, but the function expects a object<ProxyManager\Generator\MethodGenerator>.

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...
73
                $valueHolder,
0 ignored issues
show
Documentation introduced by
$valueHolder is of type null, but the function expects a object<Laminas\Code\Generator\PropertyGenerator>.

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...
74
                $prefixInterceptors,
0 ignored issues
show
Documentation introduced by
$prefixInterceptors is of type null, but the function expects a object<Laminas\Code\Generator\PropertyGenerator>.

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...
75
                $suffixInterceptors,
0 ignored issues
show
Documentation introduced by
$suffixInterceptors is of type null, but the function expects a object<Laminas\Code\Generator\PropertyGenerator>.

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...
76
                null
77
            )
78
        );
79
    }
80
81
    public function testInterceptorGeneratorWithVoidMethod() : void
82
    {
83
        $method             = $this->createMock(MethodGenerator::class);
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $method is correct as $this->createMock(\Proxy...MethodGenerator::class) (which targets PHPUnit\Framework\TestCase::createMock()) 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 getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
84
        $bar                = $this->createMock(ParameterGenerator::class);
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $bar is correct as $this->createMock(\Lamin...ameterGenerator::class) (which targets PHPUnit\Framework\TestCase::createMock()) 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 getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
85
        $baz                = $this->createMock(ParameterGenerator::class);
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $baz is correct as $this->createMock(\Lamin...ameterGenerator::class) (which targets PHPUnit\Framework\TestCase::createMock()) 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 getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
86
        $valueHolder        = $this->createMock(PropertyGenerator::class);
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $valueHolder is correct as $this->createMock(\Lamin...opertyGenerator::class) (which targets PHPUnit\Framework\TestCase::createMock()) 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 getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
87
        $prefixInterceptors = $this->createMock(PropertyGenerator::class);
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $prefixInterceptors is correct as $this->createMock(\Lamin...opertyGenerator::class) (which targets PHPUnit\Framework\TestCase::createMock()) 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 getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
88
        $suffixInterceptors = $this->createMock(PropertyGenerator::class);
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $suffixInterceptors is correct as $this->createMock(\Lamin...opertyGenerator::class) (which targets PHPUnit\Framework\TestCase::createMock()) 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 getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
89
90
        $bar->method('getName')->willReturn('bar');
0 ignored issues
show
Bug introduced by
The method method cannot be called on $bar (of type null).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
91
        $baz->method('getName')->willReturn('baz');
0 ignored issues
show
Bug introduced by
The method method cannot be called on $baz (of type null).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
92
        $method->method('getName')->willReturn('fooMethod');
0 ignored issues
show
Bug introduced by
The method method cannot be called on $method (of type null).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
93
        $method->method('getParameters')->will(self::returnValue([$bar, $baz]));
0 ignored issues
show
Bug introduced by
The method method cannot be called on $method (of type null).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
Bug introduced by
The method returnValue() does not seem to exist on object<ProxyManagerTest\...terceptorGeneratorTest>.

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.

Loading history...
94
        $valueHolder->method('getName')->willReturn('foo');
0 ignored issues
show
Bug introduced by
The method method cannot be called on $valueHolder (of type null).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
95
        $prefixInterceptors->method('getName')->willReturn('pre');
0 ignored issues
show
Bug introduced by
The method method cannot be called on $prefixInterceptors (of type null).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
96
        $suffixInterceptors->method('getName')->willReturn('post');
0 ignored issues
show
Bug introduced by
The method method cannot be called on $suffixInterceptors (of type null).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
97
98
        // @codingStandardsIgnoreStart
99
        $expected = <<<'PHP'
100
if (isset($this->pre['fooMethod'])) {
101
    $returnEarly       = false;
102
    $prefixReturnValue = $this->pre['fooMethod']->__invoke($this, $this->foo, 'fooMethod', array('bar' => $bar, 'baz' => $baz), $returnEarly);
103
104
    if ($returnEarly) {
105
        $prefixReturnValue;
106
return;
107
    }
108
}
109
110
$returnValue = "foo";
111
112
if (isset($this->post['fooMethod'])) {
113
    $returnEarly       = false;
114
    $suffixReturnValue = $this->post['fooMethod']->__invoke($this, $this->foo, 'fooMethod', array('bar' => $bar, 'baz' => $baz), $returnValue, $returnEarly);
115
116
    if ($returnEarly) {
117
        $suffixReturnValue;
118
return;
119
    }
120
}
121
122
$returnValue;
123
return;
124
PHP;
125
        // @codingStandardsIgnoreEnd
126
127
        self::assertSame(
0 ignored issues
show
Bug introduced by
The method assertSame() does not seem to exist on object<ProxyManagerTest\...terceptorGeneratorTest>.

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.

Loading history...
128
            $expected,
129
            InterceptorGenerator::createInterceptedMethodBody(
130
                '$returnValue = "foo";',
131
                $method,
0 ignored issues
show
Documentation introduced by
$method is of type null, but the function expects a object<ProxyManager\Generator\MethodGenerator>.

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...
132
                $valueHolder,
0 ignored issues
show
Documentation introduced by
$valueHolder is of type null, but the function expects a object<Laminas\Code\Generator\PropertyGenerator>.

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...
133
                $prefixInterceptors,
0 ignored issues
show
Documentation introduced by
$prefixInterceptors is of type null, but the function expects a object<Laminas\Code\Generator\PropertyGenerator>.

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...
134
                $suffixInterceptors,
0 ignored issues
show
Documentation introduced by
$suffixInterceptors is of type null, but the function expects a object<Laminas\Code\Generator\PropertyGenerator>.

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...
135
                new ReflectionMethod(VoidMethodTypeHintedInterface::class, 'returnVoid')
136
            )
137
        );
138
    }
139
140
    public function testInterceptorGeneratorWithNonVoidOriginalMethod() : void
141
    {
142
        $method             = $this->createMock(MethodGenerator::class);
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $method is correct as $this->createMock(\Proxy...MethodGenerator::class) (which targets PHPUnit\Framework\TestCase::createMock()) 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 getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
143
        $bar                = $this->createMock(ParameterGenerator::class);
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $bar is correct as $this->createMock(\Lamin...ameterGenerator::class) (which targets PHPUnit\Framework\TestCase::createMock()) 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 getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
144
        $baz                = $this->createMock(ParameterGenerator::class);
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $baz is correct as $this->createMock(\Lamin...ameterGenerator::class) (which targets PHPUnit\Framework\TestCase::createMock()) 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 getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
145
        $valueHolder        = $this->createMock(PropertyGenerator::class);
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $valueHolder is correct as $this->createMock(\Lamin...opertyGenerator::class) (which targets PHPUnit\Framework\TestCase::createMock()) 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 getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
146
        $prefixInterceptors = $this->createMock(PropertyGenerator::class);
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $prefixInterceptors is correct as $this->createMock(\Lamin...opertyGenerator::class) (which targets PHPUnit\Framework\TestCase::createMock()) 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 getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
147
        $suffixInterceptors = $this->createMock(PropertyGenerator::class);
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $suffixInterceptors is correct as $this->createMock(\Lamin...opertyGenerator::class) (which targets PHPUnit\Framework\TestCase::createMock()) 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 getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
148
149
        $bar->method('getName')->willReturn('bar');
0 ignored issues
show
Bug introduced by
The method method cannot be called on $bar (of type null).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
150
        $baz->method('getName')->willReturn('baz');
0 ignored issues
show
Bug introduced by
The method method cannot be called on $baz (of type null).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
151
        $method->method('getName')->willReturn('fooMethod');
0 ignored issues
show
Bug introduced by
The method method cannot be called on $method (of type null).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
152
        $method->method('getParameters')->will(self::returnValue([$bar, $baz]));
0 ignored issues
show
Bug introduced by
The method method cannot be called on $method (of type null).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
Bug introduced by
The method returnValue() does not seem to exist on object<ProxyManagerTest\...terceptorGeneratorTest>.

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.

Loading history...
153
        $valueHolder->method('getName')->willReturn('foo');
0 ignored issues
show
Bug introduced by
The method method cannot be called on $valueHolder (of type null).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
154
        $prefixInterceptors->method('getName')->willReturn('pre');
0 ignored issues
show
Bug introduced by
The method method cannot be called on $prefixInterceptors (of type null).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
155
        $suffixInterceptors->method('getName')->willReturn('post');
0 ignored issues
show
Bug introduced by
The method method cannot be called on $suffixInterceptors (of type null).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
156
157
        // @codingStandardsIgnoreStart
158
        $expected = <<<'PHP'
159
if (isset($this->pre['fooMethod'])) {
160
    $returnEarly       = false;
161
    $prefixReturnValue = $this->pre['fooMethod']->__invoke($this, $this->foo, 'fooMethod', array('bar' => $bar, 'baz' => $baz), $returnEarly);
162
163
    if ($returnEarly) {
164
        return $prefixReturnValue;
165
    }
166
}
167
168
$returnValue = "foo";
169
170
if (isset($this->post['fooMethod'])) {
171
    $returnEarly       = false;
172
    $suffixReturnValue = $this->post['fooMethod']->__invoke($this, $this->foo, 'fooMethod', array('bar' => $bar, 'baz' => $baz), $returnValue, $returnEarly);
173
174
    if ($returnEarly) {
175
        return $suffixReturnValue;
176
    }
177
}
178
179
return $returnValue;
180
PHP;
181
        // @codingStandardsIgnoreEnd
182
183
        self::assertSame(
0 ignored issues
show
Bug introduced by
The method assertSame() does not seem to exist on object<ProxyManagerTest\...terceptorGeneratorTest>.

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.

Loading history...
184
            $expected,
185
            InterceptorGenerator::createInterceptedMethodBody(
186
                '$returnValue = "foo";',
187
                $method,
0 ignored issues
show
Documentation introduced by
$method is of type null, but the function expects a object<ProxyManager\Generator\MethodGenerator>.

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...
188
                $valueHolder,
0 ignored issues
show
Documentation introduced by
$valueHolder is of type null, but the function expects a object<Laminas\Code\Generator\PropertyGenerator>.

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...
189
                $prefixInterceptors,
0 ignored issues
show
Documentation introduced by
$prefixInterceptors is of type null, but the function expects a object<Laminas\Code\Generator\PropertyGenerator>.

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...
190
                $suffixInterceptors,
0 ignored issues
show
Documentation introduced by
$suffixInterceptors is of type null, but the function expects a object<Laminas\Code\Generator\PropertyGenerator>.

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...
191
                new ReflectionMethod(BaseClass::class, 'publicMethod')
192
            )
193
        );
194
    }
195
}
196