Completed
Pull Request — master (#8)
by ARCANEDEV
06:34
created

AutoloadTrait::mergeAutoload()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 10
rs 9.4285
cc 2
eloc 5
nc 2
nop 1
1
<?php namespace Arcanedev\Composer\Entities\PackageTraits;
2
3
use Arcanedev\Composer\Utilities\Util;
4
use Composer\Package\RootPackageInterface;
5
6
/**
7
 * Trait     AutoloadTrait
8
 *
9
 * @package  Arcanedev\Composer\Entities\PackageTraits
10
 * @author   ARCANEDEV <[email protected]>
11
 */
12
trait AutoloadTrait
13
{
14
    /* ------------------------------------------------------------------------------------------------
15
     |  Main Functions
16
     | ------------------------------------------------------------------------------------------------
17
     */
18
    /**
19
     * Merge autoload into a RootPackage.
20
     *
21
     * @param  \Composer\Package\RootPackageInterface  $root
22
     */
23
    private function mergeAutoload(RootPackageInterface $root)
24
    {
25
        if ( ! empty($autoload = $this->package->getAutoload())) {
0 ignored issues
show
Bug introduced by
The property package 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...
26
            /** @var \Composer\Package\RootPackageInterface $unwrapped */
27
            $unwrapped = static::unwrapIfNeeded($root, 'setAutoload');
28
            $unwrapped->setAutoload(array_merge_recursive(
29
                $root->getAutoload(), Util::fixRelativePaths($this->path, $autoload)
0 ignored issues
show
Bug introduced by
The property path 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...
30
            ));
31
        }
32
    }
33
}
34