Completed
Push — develop ( 8eb671...133594 )
by Mike
19:30 queued 09:24
created

Descriptor/Filter/StripIgnoreTest.php (1 issue)

mismatching argument types.

Documentation Minor

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
 * phpDocumentor
4
 *
5
 * PHP Version 5.3
6
 *
7
 * @copyright 2010-2018 Mike van Riel / Naenius (http://www.naenius.com)
8
 * @license   http://www.opensource.org/licenses/mit-license.php MIT
9
 * @link      http://phpdoc.org
10
 */
11
12
namespace phpDocumentor\Descriptor\Filter;
13
14
use \Mockery as m;
15
use phpDocumentor\Descriptor\ProjectDescriptorBuilder;
16
17
/**
18
 * Tests the functionality for the StripIgnore class.
19
 */
20
class StripIgnoreTest extends \Mockery\Adapter\Phpunit\MockeryTestCase
21
{
22
    /** @var ProjectDescriptorBuilder|m\Mock */
23
    protected $builderMock;
24
25
    /** @var StripIgnore $fixture */
26
    protected $fixture;
27
28
    /**
29
     * Creates a new (empty) fixture object.
30
     */
31
    protected function setUp()
32
    {
33
        $this->builderMock = m::mock('phpDocumentor\Descriptor\ProjectDescriptorBuilder');
34
        $this->fixture = new StripIgnore($this->builderMock);
35
    }
36
37
    /**
38
     * @covers phpDocumentor\Descriptor\Filter\StripIgnore::__construct
39
     */
40
    public function testProjectDescriptorBuilderIsSetUponConstruction()
41
    {
42
        $this->assertAttributeSame($this->builderMock, 'builder', $this->fixture);
43
    }
44
45
    /**
46
     * @covers phpDocumentor\Descriptor\Filter\StripIgnore::filter
47
     */
48
    public function testStripsIgnoreTagFromDescription()
49
    {
50
        $descriptor = m::mock('phpDocumentor\Descriptor\DescriptorAbstract');
51
        $descriptor->shouldReceive('getTags->get')->with('ignore')->andReturn(true);
52
53
        $this->assertNull($this->fixture->filter($descriptor));
54
    }
55
56
    /**
57
     * @covers phpDocumentor\Descriptor\Filter\StripIgnore::filter
58
     */
59
    public function testDescriptorIsUnmodifiedIfThereIsNoIgnoreTag()
60
    {
61
        $descriptor = m::mock('phpDocumentor\Descriptor\DescriptorAbstract');
62
        $descriptor->shouldReceive('getTags->get')->with('ignore')->andReturn(false);
63
64
        $this->assertEquals($descriptor, $this->fixture->filter($descriptor));
65
    }
66
67
    /**
68
     * @covers phpDocumentor\Descriptor\Filter\StripIgnore::filter
69
     */
70
    public function testNullIsReturnedIfThereIsNoDescriptor()
71
    {
72
        $this->assertNull($this->fixture->filter(null));
0 ignored issues
show
null is of type null, but the function expects a object<phpDocumentor\Des...tor\DescriptorAbstract>.

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
    }
74
}
75