Completed
Pull Request — master (#183)
by Danny
11:18
created

IssuesCollectorTest::testAddingIssue()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 7
nc 1
nop 0
dl 0
loc 11
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace Tests\PHPSA;
4
5
use PHPSA\IssuesCollector;
6
7
class IssuesCollectorTest extends \PHPUnit_Framework_TestCase
8
{
9
    /**
10
     * @covers \PHPSA\IssuesCollector::addIssue()
11
     * @covers \PHPSA\IssuesCollector::getIssues()
12
     */
13
    public function testAddingIssue()
14
    {
15
        $collector = new IssuesCollector();
16
17
        $this->assertNull($collector->addIssue(100, 'Test issue', __FILE__, 26));
0 ignored issues
show
Documentation introduced by
100 is of type integer, but the function expects a object<PHPSA\Issue>.

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...
Unused Code introduced by
The call to IssuesCollector::addIssue() has too many arguments starting with 'Test issue'.

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...
18
        $this->assertCount(1, $collector->getIssues());
19
        $this->assertSame(
20
            [['type' => 100, 'message' => 'Test issue', 'file' => __FILE__, 'line' => 26]],
21
            $collector->getIssues()
22
        );
23
    }
24
}
25