Completed
Push — master ( 81e1a1...0dbe46 )
by ARCANEDEV
30:13
created

ComposerServiceProvider::boot()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 7
ccs 6
cts 6
cp 1
rs 9.4286
cc 1
eloc 4
nc 1
nop 0
crap 1
1
<?php namespace Arcanesoft\Foundation\Providers;
2
3
use Arcanedev\Support\ServiceProvider;
4
5
/**
6
 * Class     ComposerServiceProvider
7
 *
8
 * @package  Arcanesoft\Foundation\Providers
9
 * @author   ARCANEDEV <[email protected]>
10
 */
11
class ComposerServiceProvider extends ServiceProvider
12
{
13
    /* ------------------------------------------------------------------------------------------------
14
     |  Main Functions
15
     | ------------------------------------------------------------------------------------------------
16
     */
17
    /**
18
     * {@inheritdoc}
19
     */
20 24
    public function boot()
21
    {
22 24
        view()->composer(
0 ignored issues
show
Bug introduced by
The method composer does only exist in Illuminate\Contracts\View\Factory, but not in Illuminate\View\View.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
23 24
            'foundation::_template.sidebar-main',
24 6
            \Arcanesoft\Foundation\ViewComposers\SidebarComposer::class
25 18
        );
26 24
    }
27
28
    /**
29
     * {@inheritdoc}
30
     */
31 24
    public function register()
32
    {
33
        //
34 24
    }
35
}
36