|
1
|
|
|
<?php namespace Arcanedev\Composer\Entities\PackageTraits; |
|
2
|
|
|
|
|
3
|
|
|
use Arcanedev\Composer\Entities\PluginState; |
|
4
|
|
|
use Arcanedev\Composer\Utilities\Util; |
|
5
|
|
|
use Composer\Package\RootPackageInterface; |
|
6
|
|
|
|
|
7
|
|
|
/** |
|
8
|
|
|
* Trait DevTrait |
|
9
|
|
|
* |
|
10
|
|
|
* @package Arcanedev\Composer\Entities\PackageTraits |
|
11
|
|
|
* @author ARCANEDEV <[email protected]> |
|
12
|
|
|
*/ |
|
13
|
|
|
trait DevTrait |
|
14
|
|
|
{ |
|
15
|
|
|
/* ------------------------------------------------------------------------------------------------ |
|
16
|
|
|
| Properties |
|
17
|
|
|
| ------------------------------------------------------------------------------------------------ |
|
18
|
|
|
*/ |
|
19
|
|
|
/** @var \Composer\Package\CompletePackage $package */ |
|
20
|
|
|
protected $package; |
|
21
|
|
|
|
|
22
|
|
|
/** @var string $path */ |
|
23
|
|
|
protected $path; |
|
24
|
|
|
|
|
25
|
|
|
/* ------------------------------------------------------------------------------------------------ |
|
26
|
|
|
| Main Functions |
|
27
|
|
|
| ------------------------------------------------------------------------------------------------ |
|
28
|
|
|
*/ |
|
29
|
|
|
/** |
|
30
|
|
|
* Merge just the dev portion into a RootPackageInterface. |
|
31
|
|
|
* |
|
32
|
|
|
* @param \Composer\Package\RootPackageInterface $root |
|
33
|
|
|
* @param \Arcanedev\Composer\Entities\PluginState $state |
|
34
|
|
|
*/ |
|
35
|
|
|
public function mergeDevInto(RootPackageInterface $root, PluginState $state) |
|
36
|
|
|
{ |
|
37
|
|
|
$this->mergeDevRequires($root, $state); |
|
38
|
|
|
$this->mergeDevAutoload($root); |
|
39
|
|
|
$this->mergeReferences($root); |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* Merge require-dev into RootPackage. |
|
44
|
|
|
* |
|
45
|
|
|
* @param \Composer\Package\RootPackageInterface $root |
|
46
|
|
|
* @param \Arcanedev\Composer\Entities\PluginState $state |
|
47
|
|
|
*/ |
|
48
|
|
|
abstract protected function mergeDevRequires(RootPackageInterface $root, PluginState $state); |
|
49
|
|
|
|
|
50
|
|
|
/** |
|
51
|
|
|
* Merge autoload-dev into a RootPackage. |
|
52
|
|
|
* |
|
53
|
|
|
* @param \Composer\Package\RootPackageInterface $root |
|
54
|
|
|
*/ |
|
55
|
|
|
private function mergeDevAutoload(RootPackageInterface $root) |
|
56
|
|
|
{ |
|
57
|
|
|
if ( ! empty($autoload = $this->package->getDevAutoload())) { |
|
58
|
|
|
self::unwrapIfNeeded($root, 'setDevAutoload') |
|
59
|
|
|
->setDevAutoload(array_merge_recursive( |
|
60
|
|
|
$root->getDevAutoload(), Util::fixRelativePaths($this->path, $autoload) |
|
61
|
|
|
)); |
|
62
|
|
|
} |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
/** |
|
66
|
|
|
* Update the root packages reference information. |
|
67
|
|
|
* |
|
68
|
|
|
* @param \Composer\Package\RootPackageInterface $root |
|
69
|
|
|
*/ |
|
70
|
|
|
abstract protected function mergeReferences(RootPackageInterface $root); |
|
71
|
|
|
|
|
72
|
|
|
/** |
|
73
|
|
|
* Get a full featured Package from a RootPackageInterface. |
|
74
|
|
|
* |
|
75
|
|
|
* @param \Composer\Package\RootPackageInterface|\Composer\Package\RootPackage $root |
|
76
|
|
|
* @param string $method |
|
77
|
|
|
* |
|
78
|
|
|
* @return \Composer\Package\RootPackageInterface|\Composer\Package\RootPackage |
|
79
|
|
|
*/ |
|
80
|
|
|
abstract protected function unwrapIfNeeded( |
|
81
|
|
|
RootPackageInterface $root, $method = 'setExtra' |
|
82
|
|
|
); |
|
83
|
|
|
} |
|
84
|
|
|
|