GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

FirephpCollectorTest::testCollector()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 9
rs 9.6666
c 0
b 0
f 0
cc 1
eloc 6
nc 1
nop 0
1
<?php
2
/*
3
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
4
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
5
 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
6
 * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
7
 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
8
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
9
 */
10
11
namespace MpaFirephpWrapperTest\Collector;
12
13
use MpaFirephpWrapper\Collector\FirephpCollector;
14
use MpaFirephpWrapper\Service\FirephpWrapper;
15
use MpaFirephpWrapperTest\Util\ServiceManagerFactory;
16
use MpaFirephpWrapper\Options\FirephpWrapperOptions;
17
use PHPUnit\Framework\TestCase;
18
use Zend\Mvc\MvcEvent;
19
20
class FirephpCollectorTest extends TestCase
21
{
22
    protected $serviceManager;
23
24
    protected function setUp()
25
    {
26
        $this->serviceManager = ServiceManagerFactory::getServiceManager();
27
    }
28
29
    public function testCollector()
30
    {
31
        $wrapper   = new FirephpWrapper($this->serviceManager->get(FirephpWrapperOptions::class));
0 ignored issues
show
Documentation introduced by
$this->serviceManager->g...pWrapperOptions::class) is of type object|array, but the function expects a object<MpaFirephpWrapper...\FirephpWrapperOptions>.

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...
32
        $collector = new FirephpCollector($wrapper);
33
34
        $this->assertEquals('mpa_firephp_wrapper_collector', $collector->getName());
35
        $this->assertEquals(0, $collector->getHowManyLogged());
36
        $this->assertEquals(150, $collector->getPriority());
37
    }
38
39
    public function testCollectorCollects()
40
    {
41
        $this->serviceManager->get('ViewHelperManager')
42
            ->get('firephp')
43
            ->__invoke('something');
44
        $collector = new FirephpCollector($this->serviceManager->get('firephp'));
0 ignored issues
show
Documentation introduced by
$this->serviceManager->get('firephp') is of type object|array, but the function expects a object<MpaFirephpWrapper\Service\FirephpWrapper>.

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...
45
        $collector->collect($this->createMock(MvcEvent::class));
46
        $this->app = $this->serviceManager->get('Application');
0 ignored issues
show
Bug introduced by
The property app does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
47
        $this->app->bootstrap();
48
49
        $this->assertEquals(1, $collector->getHowManyLogged());
50
    }
51
}
52