From 3905f275d6eb8a415c1507f17446d6633f57d754 Mon Sep 17 00:00:00 2001 From: Sven Wittevrongel Date: Thu, 2 Jun 2016 14:02:11 +0100 Subject: [PATCH 1/7] RootPackage::getConfig --- .../Package/Loader/RootPackageLoader.php | 4 ++++ src/Composer/Package/RootPackage.php | 19 +++++++++++++++++++ src/Composer/Package/RootPackageInterface.php | 7 +++++++ 3 files changed, 30 insertions(+) diff --git a/src/Composer/Package/Loader/RootPackageLoader.php b/src/Composer/Package/Loader/RootPackageLoader.php index f0c25daba..a495f96b1 100644 --- a/src/Composer/Package/Loader/RootPackageLoader.php +++ b/src/Composer/Package/Loader/RootPackageLoader.php @@ -141,6 +141,10 @@ class RootPackageLoader extends ArrayLoader $realPackage->setPreferStable((bool) $config['prefer-stable']); } + if (isset($config['config'])) { + $realPackage->setConfig($config['config']); + } + $repos = RepositoryFactory::defaultRepos(null, $this->config, $this->manager); foreach ($repos as $repo) { $this->manager->addRepository($repo); diff --git a/src/Composer/Package/RootPackage.php b/src/Composer/Package/RootPackage.php index b2e812990..79c0f502f 100644 --- a/src/Composer/Package/RootPackage.php +++ b/src/Composer/Package/RootPackage.php @@ -22,6 +22,7 @@ class RootPackage extends CompletePackage implements RootPackageInterface protected $minimumStability = 'stable'; protected $preferStable = false; protected $stabilityFlags = array(); + protected $config = array(); protected $references = array(); protected $aliases = array(); @@ -79,6 +80,24 @@ class RootPackage extends CompletePackage implements RootPackageInterface return $this->preferStable; } + /** + * Set the config + * + * @param array $config + */ + public function setConfig($config) + { + $this->config = $config; + } + + /** + * {@inheritDoc} + */ + public function getConfig() + { + return $this->config; + } + /** * Set the references * diff --git a/src/Composer/Package/RootPackageInterface.php b/src/Composer/Package/RootPackageInterface.php index c1cf8c1be..7a3be9d8e 100644 --- a/src/Composer/Package/RootPackageInterface.php +++ b/src/Composer/Package/RootPackageInterface.php @@ -58,6 +58,13 @@ interface RootPackageInterface extends CompletePackageInterface */ public function getPreferStable(); + /** + * Returns the root package's configuration + * + * @return array + */ + public function getConfig(); + /** * Set the required packages * From dec44e6ba95947bc5ae3193a7387423efb522f47 Mon Sep 17 00:00:00 2001 From: Sven Wittevrongel Date: Thu, 2 Jun 2016 14:20:36 +0100 Subject: [PATCH 2/7] getconfig in RootAliasPackage --- src/Composer/Package/RootAliasPackage.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/Composer/Package/RootAliasPackage.php b/src/Composer/Package/RootAliasPackage.php index e66342136..4c2701cd6 100644 --- a/src/Composer/Package/RootAliasPackage.php +++ b/src/Composer/Package/RootAliasPackage.php @@ -62,6 +62,14 @@ class RootAliasPackage extends AliasPackage implements RootPackageInterface return $this->aliasOf->getPreferStable(); } + /** + * {@inheritDoc} + */ + public function getConfig() + { + return $this->aliasOf->config; + } + /** * {@inheritDoc} */ From d0b0d1ad244d251e2184c0dc2292a6bcf69939c0 Mon Sep 17 00:00:00 2001 From: Sven Wittevrongel Date: Thu, 2 Jun 2016 14:33:26 +0100 Subject: [PATCH 3/7] RootPackage::getScripts --- src/Composer/Package/RootAliasPackage.php | 8 ++++++++ src/Composer/Package/RootPackage.php | 19 +++++++++++++++++++ src/Composer/Package/RootPackageInterface.php | 7 +++++++ 3 files changed, 34 insertions(+) diff --git a/src/Composer/Package/RootAliasPackage.php b/src/Composer/Package/RootAliasPackage.php index 4c2701cd6..32def7e46 100644 --- a/src/Composer/Package/RootAliasPackage.php +++ b/src/Composer/Package/RootAliasPackage.php @@ -70,6 +70,14 @@ class RootAliasPackage extends AliasPackage implements RootPackageInterface return $this->aliasOf->config; } + /** + * {@inheritDoc} + */ + public function getScripts() + { + return $this->aliasOf->scripts; + } + /** * {@inheritDoc} */ diff --git a/src/Composer/Package/RootPackage.php b/src/Composer/Package/RootPackage.php index 79c0f502f..459e8d7d4 100644 --- a/src/Composer/Package/RootPackage.php +++ b/src/Composer/Package/RootPackage.php @@ -23,6 +23,7 @@ class RootPackage extends CompletePackage implements RootPackageInterface protected $preferStable = false; protected $stabilityFlags = array(); protected $config = array(); + protected $scripts = array(); protected $references = array(); protected $aliases = array(); @@ -98,6 +99,24 @@ class RootPackage extends CompletePackage implements RootPackageInterface return $this->config; } + /** + * Set the scripts + * + * @param array $scripts + */ + public function setScripts($scripts) + { + $this->scripts = $scripts; + } + + /** + * {@inheritDoc} + */ + public function getScripts() + { + return $this->scripts; + } + /** * Set the references * diff --git a/src/Composer/Package/RootPackageInterface.php b/src/Composer/Package/RootPackageInterface.php index 7a3be9d8e..7cf846955 100644 --- a/src/Composer/Package/RootPackageInterface.php +++ b/src/Composer/Package/RootPackageInterface.php @@ -65,6 +65,13 @@ interface RootPackageInterface extends CompletePackageInterface */ public function getConfig(); + /** + * Returns the root package's scripts + * + * @return array + */ + public function getScripts(); + /** * Set the required packages * From cccfb2fb22fbafe0d84799f1b4c7cb2301c5e31b Mon Sep 17 00:00:00 2001 From: Sven Wittevrongel Date: Fri, 3 Jun 2016 11:51:07 +0100 Subject: [PATCH 4/7] RootAliasPackage fix --- src/Composer/Package/RootAliasPackage.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Composer/Package/RootAliasPackage.php b/src/Composer/Package/RootAliasPackage.php index 32def7e46..1105d22aa 100644 --- a/src/Composer/Package/RootAliasPackage.php +++ b/src/Composer/Package/RootAliasPackage.php @@ -67,7 +67,7 @@ class RootAliasPackage extends AliasPackage implements RootPackageInterface */ public function getConfig() { - return $this->aliasOf->config; + return $this->aliasOf->getConfig(); } /** @@ -75,7 +75,7 @@ class RootAliasPackage extends AliasPackage implements RootPackageInterface */ public function getScripts() { - return $this->aliasOf->scripts; + return $this->aliasOf->getScripts(); } /** From 3ad5f1843b16bcf9f4d3c6e1cb1ad1391b8c0325 Mon Sep 17 00:00:00 2001 From: Sven Wittevrongel Date: Fri, 3 Jun 2016 12:00:17 +0100 Subject: [PATCH 5/7] Remove getScript from CompletePackage (it is root-only) --- src/Composer/Package/AliasPackage.php | 5 ----- src/Composer/Package/CompletePackage.php | 17 ----------------- .../Package/CompletePackageInterface.php | 7 ------- src/Composer/Package/RootPackageInterface.php | 4 ++-- 4 files changed, 2 insertions(+), 31 deletions(-) diff --git a/src/Composer/Package/AliasPackage.php b/src/Composer/Package/AliasPackage.php index 09ed4fb9b..63b75cdfd 100644 --- a/src/Composer/Package/AliasPackage.php +++ b/src/Composer/Package/AliasPackage.php @@ -307,11 +307,6 @@ class AliasPackage extends BasePackage implements CompletePackageInterface return $this->aliasOf->getDistMirrors(); } - public function getScripts() - { - return $this->aliasOf->getScripts(); - } - public function getLicense() { return $this->aliasOf->getLicense(); diff --git a/src/Composer/Package/CompletePackage.php b/src/Composer/Package/CompletePackage.php index 0a926a4ce..606fa9904 100644 --- a/src/Composer/Package/CompletePackage.php +++ b/src/Composer/Package/CompletePackage.php @@ -25,26 +25,9 @@ class CompletePackage extends Package implements CompletePackageInterface protected $authors; protected $description; protected $homepage; - protected $scripts = array(); protected $support = array(); protected $abandoned = false; - /** - * @param array $scripts - */ - public function setScripts(array $scripts) - { - $this->scripts = $scripts; - } - - /** - * {@inheritDoc} - */ - public function getScripts() - { - return $this->scripts; - } - /** * Set the repositories * diff --git a/src/Composer/Package/CompletePackageInterface.php b/src/Composer/Package/CompletePackageInterface.php index 4036b3cec..04670c4b9 100644 --- a/src/Composer/Package/CompletePackageInterface.php +++ b/src/Composer/Package/CompletePackageInterface.php @@ -19,13 +19,6 @@ namespace Composer\Package; */ interface CompletePackageInterface extends PackageInterface { - /** - * Returns the scripts of this package - * - * @return array array('script name' => array('listeners')) - */ - public function getScripts(); - /** * Returns an array of repositories * diff --git a/src/Composer/Package/RootPackageInterface.php b/src/Composer/Package/RootPackageInterface.php index 7cf846955..258d00b2e 100644 --- a/src/Composer/Package/RootPackageInterface.php +++ b/src/Composer/Package/RootPackageInterface.php @@ -66,9 +66,9 @@ interface RootPackageInterface extends CompletePackageInterface public function getConfig(); /** - * Returns the root package's scripts + * Returns the scripts of this package * - * @return array + * @return array array('script name' => array('listeners')) */ public function getScripts(); From b80c33ba5c277c991a01b77f39f9703e6e745888 Mon Sep 17 00:00:00 2001 From: Sven Wittevrongel Date: Fri, 3 Jun 2016 12:00:32 +0100 Subject: [PATCH 6/7] type-hint array for setConfig & setScripts --- src/Composer/Package/RootPackage.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Composer/Package/RootPackage.php b/src/Composer/Package/RootPackage.php index 459e8d7d4..ecaf94ae1 100644 --- a/src/Composer/Package/RootPackage.php +++ b/src/Composer/Package/RootPackage.php @@ -86,7 +86,7 @@ class RootPackage extends CompletePackage implements RootPackageInterface * * @param array $config */ - public function setConfig($config) + public function setConfig(array $config) { $this->config = $config; } @@ -104,7 +104,7 @@ class RootPackage extends CompletePackage implements RootPackageInterface * * @param array $scripts */ - public function setScripts($scripts) + public function setScripts(array $scripts) { $this->scripts = $scripts; } From ca6f7b365b6da268f4ece108565f5a6cdf0dd137 Mon Sep 17 00:00:00 2001 From: Sven Wittevrongel Date: Fri, 3 Jun 2016 12:09:50 +0100 Subject: [PATCH 7/7] revert 3ad5f1843b1 --- src/Composer/Package/AliasPackage.php | 5 +++++ src/Composer/Package/CompletePackage.php | 17 +++++++++++++++++ .../Package/CompletePackageInterface.php | 7 +++++++ src/Composer/Package/RootPackageInterface.php | 4 ++-- 4 files changed, 31 insertions(+), 2 deletions(-) diff --git a/src/Composer/Package/AliasPackage.php b/src/Composer/Package/AliasPackage.php index 63b75cdfd..09ed4fb9b 100644 --- a/src/Composer/Package/AliasPackage.php +++ b/src/Composer/Package/AliasPackage.php @@ -307,6 +307,11 @@ class AliasPackage extends BasePackage implements CompletePackageInterface return $this->aliasOf->getDistMirrors(); } + public function getScripts() + { + return $this->aliasOf->getScripts(); + } + public function getLicense() { return $this->aliasOf->getLicense(); diff --git a/src/Composer/Package/CompletePackage.php b/src/Composer/Package/CompletePackage.php index 606fa9904..0a926a4ce 100644 --- a/src/Composer/Package/CompletePackage.php +++ b/src/Composer/Package/CompletePackage.php @@ -25,9 +25,26 @@ class CompletePackage extends Package implements CompletePackageInterface protected $authors; protected $description; protected $homepage; + protected $scripts = array(); protected $support = array(); protected $abandoned = false; + /** + * @param array $scripts + */ + public function setScripts(array $scripts) + { + $this->scripts = $scripts; + } + + /** + * {@inheritDoc} + */ + public function getScripts() + { + return $this->scripts; + } + /** * Set the repositories * diff --git a/src/Composer/Package/CompletePackageInterface.php b/src/Composer/Package/CompletePackageInterface.php index 04670c4b9..4036b3cec 100644 --- a/src/Composer/Package/CompletePackageInterface.php +++ b/src/Composer/Package/CompletePackageInterface.php @@ -19,6 +19,13 @@ namespace Composer\Package; */ interface CompletePackageInterface extends PackageInterface { + /** + * Returns the scripts of this package + * + * @return array array('script name' => array('listeners')) + */ + public function getScripts(); + /** * Returns an array of repositories * diff --git a/src/Composer/Package/RootPackageInterface.php b/src/Composer/Package/RootPackageInterface.php index 258d00b2e..7cf846955 100644 --- a/src/Composer/Package/RootPackageInterface.php +++ b/src/Composer/Package/RootPackageInterface.php @@ -66,9 +66,9 @@ interface RootPackageInterface extends CompletePackageInterface public function getConfig(); /** - * Returns the scripts of this package + * Returns the root package's scripts * - * @return array array('script name' => array('listeners')) + * @return array */ public function getScripts();