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

IssuesCollectorTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
dl 0
loc 18
rs 10
c 0
b 0
f 0
wmc 1
lcom 1
cbo 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A testAddingIssue() 0 11 1
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