1 | <?php namespace Arcanedev\Composer\Entities; |
||
17 | class Package |
||
18 | { |
||
19 | /* ----------------------------------------------------------------- |
||
20 | | Traits |
||
21 | | ----------------------------------------------------------------- |
||
22 | */ |
||
23 | |||
24 | use PackageTraits\RepositoriesTrait, |
||
25 | PackageTraits\RequiresTrait, |
||
26 | PackageTraits\AutoloadTrait, |
||
27 | PackageTraits\LinksTrait, |
||
28 | PackageTraits\SuggestsTrait, |
||
29 | PackageTraits\ExtraTrait, |
||
30 | PackageTraits\ScriptsTrait, |
||
31 | PackageTraits\DevTrait, |
||
32 | PackageTraits\ReferencesTrait; |
||
33 | |||
34 | /* ----------------------------------------------------------------- |
||
35 | | Properties |
||
36 | | ----------------------------------------------------------------- |
||
37 | */ |
||
38 | |||
39 | /** @var \Composer\Composer $composer */ |
||
40 | protected $composer; |
||
41 | |||
42 | /** @var \Arcanedev\Composer\Utilities\Logger $logger */ |
||
43 | protected $logger; |
||
44 | |||
45 | /** @var \Composer\Package\CompletePackage $package */ |
||
46 | protected $package; |
||
47 | |||
48 | /** @var string $path */ |
||
49 | protected $path; |
||
50 | |||
51 | /** @var \Composer\Package\Version\VersionParser $versionParser */ |
||
52 | protected $versionParser; |
||
53 | |||
54 | /** @var array $json */ |
||
55 | protected $json; |
||
56 | |||
57 | /* ----------------------------------------------------------------- |
||
58 | | Constructor |
||
59 | | ----------------------------------------------------------------- |
||
60 | */ |
||
61 | |||
62 | /** |
||
63 | * Make a Package instance. |
||
64 | * |
||
65 | * @param string $path |
||
66 | * @param \Composer\Composer $composer |
||
67 | * @param \Arcanedev\Composer\Utilities\Logger $logger |
||
68 | */ |
||
69 | 99 | public function __construct($path, Composer $composer, Logger $logger) |
|
78 | |||
79 | /* ----------------------------------------------------------------- |
||
80 | | Getters & Setters |
||
81 | | ----------------------------------------------------------------- |
||
82 | */ |
||
83 | |||
84 | /** |
||
85 | * Get list of additional packages to require if precessing recursively. |
||
86 | * |
||
87 | * @return array |
||
88 | */ |
||
89 | 96 | public function getRequires() |
|
93 | |||
94 | /** |
||
95 | * Get list of additional packages to include if precessing recursively. |
||
96 | * |
||
97 | * @return array |
||
98 | */ |
||
99 | 96 | public function getIncludes() |
|
103 | |||
104 | /** |
||
105 | * Get composer. |
||
106 | * |
||
107 | * @return \Composer\Composer |
||
108 | */ |
||
109 | 12 | public function getComposer() |
|
113 | |||
114 | /** |
||
115 | * Get the Logger. |
||
116 | * |
||
117 | * @return \Arcanedev\Composer\Utilities\Logger |
||
118 | */ |
||
119 | 60 | public function getLogger() |
|
123 | |||
124 | /** |
||
125 | * Get the json. |
||
126 | * |
||
127 | * @return array |
||
128 | */ |
||
129 | 99 | public function getJson() |
|
133 | |||
134 | /** |
||
135 | * Get the package. |
||
136 | * |
||
137 | * @return \Composer\Package\CompletePackage |
||
138 | */ |
||
139 | 99 | public function getPackage() |
|
143 | |||
144 | /** |
||
145 | * Get the path. |
||
146 | * |
||
147 | * @return string |
||
148 | */ |
||
149 | 12 | public function getPath() |
|
153 | |||
154 | /* ------------------------------------------------------------------------------------------------ |
||
155 | | Main Functions |
||
156 | | ------------------------------------------------------------------------------------------------ |
||
157 | */ |
||
158 | /** |
||
159 | * Merge this package into a RootPackage. |
||
160 | * |
||
161 | * @param \Composer\Package\RootPackageInterface $root |
||
162 | * @param \Arcanedev\Composer\Entities\PluginState $state |
||
163 | */ |
||
164 | 99 | public function mergeInto(RootPackageInterface $root, PluginState $state) |
|
180 | |||
181 | /* ------------------------------------------------------------------------------------------------ |
||
182 | | Other Functions |
||
183 | | ------------------------------------------------------------------------------------------------ |
||
184 | */ |
||
185 | /** |
||
186 | * Update Links with a 'self.version' constraint with the root package's version. |
||
187 | * |
||
188 | * @param string $type |
||
189 | * @param array $links |
||
190 | * @param \Composer\Package\RootPackageInterface $root |
||
191 | * |
||
192 | * @return array |
||
193 | */ |
||
194 | 63 | protected function replaceSelfVersionDependencies( |
|
195 | $type, array $links, RootPackageInterface $root |
||
196 | ) { |
||
197 | 63 | $linkType = BasePackage::$supportedLinkTypes[$type]; |
|
198 | 63 | $version = $root->getVersion(); |
|
199 | 63 | $prettyVersion = $root->getPrettyVersion(); |
|
200 | 63 | $vp = $this->versionParser; |
|
201 | 63 | $packages = $root->{'get'.ucfirst($linkType['method'])}(); |
|
202 | |||
203 | return array_map(function (Link $link) use ($linkType, $version, $prettyVersion, $vp, $packages) { |
||
204 | 63 | if ($link->getPrettyConstraint() !== 'self.version') { |
|
205 | 63 | return $link; |
|
206 | } |
||
207 | |||
208 | 9 | if (isset($packages[$link->getSource()])) { |
|
209 | /** @var \Composer\Package\Link $package */ |
||
210 | 6 | $package = $packages[$link->getSource()]; |
|
211 | 6 | $version = $package->getConstraint()->getPrettyString(); |
|
|
|||
212 | 6 | $prettyVersion = $package->getPrettyConstraint(); |
|
213 | } |
||
214 | |||
215 | 9 | return new Link( |
|
216 | 9 | $link->getSource(), |
|
217 | 9 | $link->getTarget(), |
|
218 | 9 | $vp->parseConstraints($version), |
|
219 | 9 | $linkType['description'], |
|
220 | 6 | $prettyVersion |
|
221 | ); |
||
222 | 63 | }, $links); |
|
223 | } |
||
224 | |||
225 | /** |
||
226 | * Get a full featured Package from a RootPackageInterface. |
||
227 | * |
||
228 | * @param \Composer\Package\RootPackageInterface|\Composer\Package\RootPackage $root |
||
229 | * @param string $method |
||
230 | * |
||
231 | * @return \Composer\Package\RootPackageInterface|\Composer\Package\RootPackage |
||
232 | */ |
||
233 | 99 | protected static function unwrapIfNeeded( |
|
240 | } |
||
241 |
It seems like you are assigning to a variable which was imported through a
use
statement which was not imported by reference.For clarity, we suggest to use a different name or import by reference depending on whether you would like to have the change visibile in outer-scope.
Change not visible in outer-scope
Change visible in outer-scope