Passed
Push — stable ( cff678...1149ad )
by Nuno
10:30
created

src/Provider.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
/**
4
 * This file is part of Collision.
5
 *
6
 * (c) Nuno Maduro <[email protected]>
7
 *
8
 *  For the full copyright and license information, please view the LICENSE
9
 *  file that was distributed with this source code.
10
 */
11
12
namespace NunoMaduro\Collision;
13
14
use Whoops\Run;
15
use Whoops\RunInterface;
16
use NunoMaduro\Collision\Contracts\Handler as HandlerContract;
17
use NunoMaduro\Collision\Contracts\Provider as ProviderContract;
18
19
/**
20
 * This is an Collision Provider implementation.
21
 *
22
 * @author Nuno Maduro <[email protected]>
23
 */
24
class Provider implements ProviderContract
25
{
26
    /**
27
     * Holds an instance of the Run.
28
     *
29
     * @var \Whoops\RunInterface
30
     */
31
    protected $run;
32
33
    /**
34
     * Holds an instance of the handler.
35
     *
36
     * @var \NunoMaduro\Collision\Contracts\Handler
37
     */
38
    protected $handler;
39
40
    /**
41
     * Creates a new instance of the Provider.
42
     *
43
     * @param \Whoops\RunInterface|null $run
44
     * @param \NunoMaduro\Collision\Contracts\Handler|null $handler
45
     */
46 3
    public function __construct(RunInterface $run = null, HandlerContract $handler = null)
47
    {
48 3
        $this->run = $run ?: new Run;
49 3
        $this->handler = $handler ?: new Handler;
50 3
    }
51
52
    /**
53
     * {@inheritdoc}
54
     */
55 1
    public function register(): ProviderContract
56
    {
57 1
        $this->run->pushHandler($this->handler)
0 ignored issues
show
$this->handler is of type object<NunoMaduro\Collision\Contracts\Handler>, but the function expects a callable.

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...
58 1
            ->register();
59
60 1
        return $this;
61
    }
62
63
    /**
64
     * {@inheritdoc}
65
     */
66 1
    public function getHandler(): HandlerContract
67
    {
68 1
        return $this->handler;
69
    }
70
}
71