Completed
Push — master ( 576b3f...f0fa40 )
by Marco
512:55 queued 512:16
created

MethodGenerator/SetMethodPrefixInterceptorTest.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
declare(strict_types=1);
4
5
namespace ProxyManagerTest\ProxyGenerator\AccessInterceptor\MethodGenerator;
6
7
use PHPUnit\Framework\TestCase;
8
use ProxyManager\ProxyGenerator\AccessInterceptor\MethodGenerator\SetMethodPrefixInterceptor;
9
use Zend\Code\Generator\PropertyGenerator;
10
use Zend\Code\Generator\TypeGenerator;
11
12
/**
13
 * Tests for {@see \ProxyManager\ProxyGenerator\AccessInterceptor\MethodGenerator\SetMethodPrefixInterceptor}
14
 *
15
 * @group Coverage
16
 */
17
class SetMethodPrefixInterceptorTest extends TestCase
18
{
19
    /**
20
     * @covers \ProxyManager\ProxyGenerator\AccessInterceptor\MethodGenerator\SetMethodPrefixInterceptor::__construct
21
     */
22
    public function testBodyStructure() : void
23
    {
24
        /** @var PropertyGenerator|\PHPUnit_Framework_MockObject_MockObject $suffix */
25
        $suffix = $this->createMock(PropertyGenerator::class);
26
27
        $suffix->expects(self::once())->method('getName')->will(self::returnValue('foo'));
28
29
        $setter = new SetMethodPrefixInterceptor($suffix);
30
31
        self::assertEquals(TypeGenerator::fromTypeString('void'), $setter->getReturnType());
32
        self::assertSame('setMethodPrefixInterceptor', $setter->getName());
33
        self::assertCount(2, $setter->getParameters());
0 ignored issues
show
$setter->getParameters() is of type array<integer,object<Zen...or\ParameterGenerator>>, but the function expects a object<Countable>|object...nit\Framework\iterable>.

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...
34
        self::assertSame('$this->foo[$methodName] = $prefixInterceptor;', $setter->getBody());
35
    }
36
}
37