From 32cd883daaa0e396a2f6385c212cdcef1b02042e Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Wed, 7 May 2014 18:25:28 +0200 Subject: [PATCH] Rename options to transport-options, refs #2189 --- src/Composer/Downloader/FileDownloader.php | 2 +- src/Composer/Package/BasePackage.php | 16 +++++++++------- src/Composer/Package/Dumper/ArrayDumper.php | 4 ++-- src/Composer/Package/Loader/ArrayLoader.php | 4 ++-- .../Package/Loader/ValidatingArrayLoader.php | 2 +- src/Composer/Package/PackageInterface.php | 9 +-------- src/Composer/Repository/ComposerRepository.php | 2 +- .../Test/Downloader/FileDownloaderTest.php | 4 ++-- .../Test/Downloader/ZipDownloaderTest.php | 2 +- .../Test/Package/Dumper/ArrayDumperTest.php | 5 +++-- .../Test/Package/Loader/ArrayLoaderTest.php | 2 +- .../Package/Loader/ValidatingArrayLoaderTest.php | 6 +++--- 12 files changed, 27 insertions(+), 31 deletions(-) diff --git a/src/Composer/Downloader/FileDownloader.php b/src/Composer/Downloader/FileDownloader.php index 3e2a2972d..8c98eb785 100644 --- a/src/Composer/Downloader/FileDownloader.php +++ b/src/Composer/Downloader/FileDownloader.php @@ -118,7 +118,7 @@ class FileDownloader implements DownloaderInterface $retries = 3; while ($retries--) { try { - $rfs->copy($hostname, $processedUrl, $fileName, $this->outputProgress, $package->getOptions()); + $rfs->copy($hostname, $processedUrl, $fileName, $this->outputProgress, $package->getTransportOptions()); break; } catch (TransportException $e) { // if we got an http response with a proper code, then requesting again will probably not help, abort diff --git a/src/Composer/Package/BasePackage.php b/src/Composer/Package/BasePackage.php index afc20f4b6..d756196ef 100644 --- a/src/Composer/Package/BasePackage.php +++ b/src/Composer/Package/BasePackage.php @@ -49,7 +49,7 @@ abstract class BasePackage implements PackageInterface protected $repository; protected $id; - protected $options; + protected $transportOptions; /** * All descendants' constructors should call this parent constructor @@ -61,7 +61,7 @@ abstract class BasePackage implements PackageInterface $this->prettyName = $name; $this->name = strtolower($name); $this->id = -1; - $this->options = array(); + $this->transportOptions = array(); } /** @@ -138,17 +138,19 @@ abstract class BasePackage implements PackageInterface /** * {@inheritDoc} */ - public function getOptions() + public function getTransportOptions() { - return $this->options; + return $this->transportOptions; } /** - * {@inheritDoc} + * Configures the list of options to download package dist files + * + * @param array $options */ - public function setOptions(array $options) + public function setTransportOptions(array $options) { - $this->options = $options; + $this->transportOptions = $options; } /** diff --git a/src/Composer/Package/Dumper/ArrayDumper.php b/src/Composer/Package/Dumper/ArrayDumper.php index b81912837..8741acefb 100644 --- a/src/Composer/Package/Dumper/ArrayDumper.php +++ b/src/Composer/Package/Dumper/ArrayDumper.php @@ -108,8 +108,8 @@ class ArrayDumper } } - if (count($package->getOptions()) > 0) { - $data['options'] = $package->getOptions(); + if (count($package->getTransportOptions()) > 0) { + $data['transport-options'] = $package->getTransportOptions(); } return $data; diff --git a/src/Composer/Package/Loader/ArrayLoader.php b/src/Composer/Package/Loader/ArrayLoader.php index d96de2fa9..66d48f65e 100644 --- a/src/Composer/Package/Loader/ArrayLoader.php +++ b/src/Composer/Package/Loader/ArrayLoader.php @@ -199,8 +199,8 @@ class ArrayLoader implements LoaderInterface } } - if ($this->loadOptions && isset($config['options'])) { - $package->setOptions($config['options']); + if ($this->loadOptions && isset($config['transport-options'])) { + $package->setTransportOptions($config['transport-options']); } return $package; diff --git a/src/Composer/Package/Loader/ValidatingArrayLoader.php b/src/Composer/Package/Loader/ValidatingArrayLoader.php index ac8010459..aef24f891 100644 --- a/src/Composer/Package/Loader/ValidatingArrayLoader.php +++ b/src/Composer/Package/Loader/ValidatingArrayLoader.php @@ -230,7 +230,7 @@ class ValidatingArrayLoader implements LoaderInterface // TODO validate package repositories' packages using this recursively $this->validateFlatArray('include-path'); - $this->validateArray('options'); + $this->validateArray('transport-options'); // branch alias validation if (isset($this->config['extra']['branch-alias'])) { diff --git a/src/Composer/Package/PackageInterface.php b/src/Composer/Package/PackageInterface.php index ea3a86420..337a72a83 100644 --- a/src/Composer/Package/PackageInterface.php +++ b/src/Composer/Package/PackageInterface.php @@ -314,17 +314,10 @@ interface PackageInterface */ public function getArchiveExcludes(); - /** - * Configures the list of options to download package dist files - * - * @param array $options - */ - public function setOptions(array $options); - /** * Returns a list of options to download package dist files * * @return array */ - public function getOptions(); + public function getTransportOptions(); } diff --git a/src/Composer/Repository/ComposerRepository.php b/src/Composer/Repository/ComposerRepository.php index 529128dd7..63b3dbf86 100644 --- a/src/Composer/Repository/ComposerRepository.php +++ b/src/Composer/Repository/ComposerRepository.php @@ -219,7 +219,7 @@ class ComposerRepository extends ArrayRepository implements StreamableRepository { if ($package instanceof Package && strpos($package->getDistUrl(), $this->baseUrl) === 0) { - $package->setOptions($this->options); + $package->setTransportOptions($this->options); } } diff --git a/tests/Composer/Test/Downloader/FileDownloaderTest.php b/tests/Composer/Test/Downloader/FileDownloaderTest.php index 9fb34b846..28714de4a 100644 --- a/tests/Composer/Test/Downloader/FileDownloaderTest.php +++ b/tests/Composer/Test/Downloader/FileDownloaderTest.php @@ -90,7 +90,7 @@ class FileDownloaderTest extends \PHPUnit_Framework_TestCase ->will($this->returnValue('http://example.com/script.js')) ; $packageMock->expects($this->atLeastOnce()) - ->method('getOptions') + ->method('getTransportOptions') ->will($this->returnValue(array())) ; @@ -166,7 +166,7 @@ class FileDownloaderTest extends \PHPUnit_Framework_TestCase ->will($this->returnValue('http://example.com/script.js')) ; $packageMock->expects($this->atLeastOnce()) - ->method('getOptions') + ->method('getTransportOptions') ->will($this->returnValue(array())) ; $packageMock->expects($this->any()) diff --git a/tests/Composer/Test/Downloader/ZipDownloaderTest.php b/tests/Composer/Test/Downloader/ZipDownloaderTest.php index 441777d8c..36b2c2296 100644 --- a/tests/Composer/Test/Downloader/ZipDownloaderTest.php +++ b/tests/Composer/Test/Downloader/ZipDownloaderTest.php @@ -31,7 +31,7 @@ class ZipDownloaderTest extends \PHPUnit_Framework_TestCase ->will($this->returnValue('file://'.__FILE__)) ; $packageMock->expects($this->atLeastOnce()) - ->method('getOptions') + ->method('getTransportOptions') ->will($this->returnValue(array())) ; diff --git a/tests/Composer/Test/Package/Dumper/ArrayDumperTest.php b/tests/Composer/Test/Package/Dumper/ArrayDumperTest.php index 54e8de9cc..5576e3d05 100644 --- a/tests/Composer/Test/Package/Dumper/ArrayDumperTest.php +++ b/tests/Composer/Test/Package/Dumper/ArrayDumperTest.php @@ -196,8 +196,9 @@ class ArrayDumperTest extends \PHPUnit_Framework_TestCase array('bar/baz' => '1.0.0', 'foo/bar' => '1.0.0') ), array( - 'options', - array('ssl' => array('local_cert' => '/opt/certs/test.pem')) + 'transport-options', + array('ssl' => array('local_cert' => '/opt/certs/test.pem')), + 'transportOptions' ) ); } diff --git a/tests/Composer/Test/Package/Loader/ArrayLoaderTest.php b/tests/Composer/Test/Package/Loader/ArrayLoaderTest.php index 593461fb7..04a537abd 100644 --- a/tests/Composer/Test/Package/Loader/ArrayLoaderTest.php +++ b/tests/Composer/Test/Package/Loader/ArrayLoaderTest.php @@ -117,7 +117,7 @@ class ArrayLoaderTest extends \PHPUnit_Framework_TestCase 'archive' => array( 'exclude' => array('/foo/bar', 'baz', '!/foo/bar/baz'), ), - 'options' => array('ssl' => array('local_cert' => '/opt/certs/test.pem')) + 'transport-options' => array('ssl' => array('local_cert' => '/opt/certs/test.pem')) ); $package = $this->loader->load($config); diff --git a/tests/Composer/Test/Package/Loader/ValidatingArrayLoaderTest.php b/tests/Composer/Test/Package/Loader/ValidatingArrayLoaderTest.php index 45e3f454c..593598a58 100644 --- a/tests/Composer/Test/Package/Loader/ValidatingArrayLoaderTest.php +++ b/tests/Composer/Test/Package/Loader/ValidatingArrayLoaderTest.php @@ -146,7 +146,7 @@ class ValidatingArrayLoaderTest extends \PHPUnit_Framework_TestCase 'bin/foo', 'bin/bar', ), - 'options' => array('ssl' => array('local_cert' => '/opt/certs/test.pem')) + 'transport-options' => array('ssl' => array('local_cert' => '/opt/certs/test.pem')) ), ), array( // test as array @@ -267,10 +267,10 @@ class ValidatingArrayLoaderTest extends \PHPUnit_Framework_TestCase array( array( 'name' => 'foo/bar', - 'options' => 'test', + 'transport-options' => 'test', ), array( - 'options : should be an array, string given' + 'transport-options : should be an array, string given' ) ), );