From 1c2213ef5da84dfc3a321f15515ee1cfbb4053e9 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Wed, 2 Oct 2013 01:11:53 +0200 Subject: [PATCH 1/6] Format the possible version formats as a table Note I: This syntax is supported by MarkdownExtra, which both getcomposer and github are using. Note II: This patch currently breaks the PDF, because pandoc does not like non-standard markdown tables. Ideas for fixing this appreciated. Note III: The idea for this patch came up a few weeks ago on IRC. We agreed back then that a table would be a good idea. Note IIII: This patch creates a stability section which opens the door for finally documenting how stability works in the composer docs. --- doc/01-basic-usage.md | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/doc/01-basic-usage.md b/doc/01-basic-usage.md index bc4a88c1e..89b77a43b 100644 --- a/doc/01-basic-usage.md +++ b/doc/01-basic-usage.md @@ -58,31 +58,31 @@ smaller decoupled parts. ### Package Versions -We are requiring version `1.0.*` of monolog. This means any version in the `1.0` -development branch. It would match `1.0.0`, `1.0.2` or `1.0.20`. +In the previous example we were requiring version `1.0.*` of monolog. This +means any version in the `1.0` development branch. It would match `1.0.0`, +`1.0.2` or `1.0.20`. Version constraints can be specified in a few different ways. -* **Exact version:** You can specify the exact version of a package, for - example `1.0.2`. +Name | Example | Description +-------------- | --------------------- | ----------- +Exact version | `1.0.2` | You can specify the exact version of a package. +Range | `>=1.0` `>=1.0,<2.0` | By using comparison operators you can specify ranges of valid versions. Valid operators are `>`, `>=`, `<`, `<=`, `!=`. You can define multiple ranges, separated by a comma, which will be treated as a **logical AND**. +Wildcard | `1.0.*` | You can specify a pattern with a `*` wildcard. `1.0.*` is the equivalent of `>=1.0,<1.1`. +Tilde Operator | `~1.2` | Very useful for projects that follow semantic versioning. `~1.2` is equivalent to `>=1.2,<2.0`. For more details, read the next section below. -* **Range:** By using comparison operators you can specify ranges of valid - versions. Valid operators are `>`, `>=`, `<`, `<=`, `!=`. An example range - would be `>=1.0`. You can define multiple ranges, separated by a comma: - `>=1.0,<2.0`. +### Next Significant Release (Tilde Operator) -* **Wildcard:** You can specify a pattern with a `*` wildcard. `1.0.*` is the - equivalent of `>=1.0,<1.1`. +The `~` operator is best explained by example: `~1.2` is equivalent to +`>=1.2,<2.0`, while `~1.2.3` is equivalent to `>=1.2.3,<1.3`. As you can see +it is mostly useful for projects respecting [semantic +versioning](http://semver.org/). A common usage would be to mark the minimum +minor version you depend on, like `~1.2` (which allows anything up to, but not +including, 2.0). Since in theory there should be no backwards compatibility +breaks until 2.0, that works well. Another way of looking at it is that using +`~` specifies a minimum version, but allows the last digit specified to go up. -* **Next Significant Release (Tilde Operator):** The `~` operator is best - explained by example: `~1.2` is equivalent to `>=1.2,<2.0`, while `~1.2.3` is - equivalent to `>=1.2.3,<1.3`. As you can see it is mostly useful for projects - respecting [semantic versioning](http://semver.org/). A common usage would be - to mark the minimum minor version you depend on, like `~1.2` (which allows - anything up to, but not including, 2.0). Since in theory there should be no - backwards compatibility breaks until 2.0, that works well. Another way of - looking at it is that using `~` specifies a minimum version, but allows the - last digit specified to go up. +### Stability By default only stable releases are taken into consideration. If you would like to also get RC, beta, alpha or dev versions of your dependencies you can do From 30b5d2f1fcbafb3d6b90f788175c64dc3dde3868 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Wed, 2 Oct 2013 12:52:47 +0200 Subject: [PATCH 2/6] Document logical OR constraints --- doc/01-basic-usage.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/doc/01-basic-usage.md b/doc/01-basic-usage.md index 89b77a43b..c353b8b6f 100644 --- a/doc/01-basic-usage.md +++ b/doc/01-basic-usage.md @@ -64,12 +64,12 @@ means any version in the `1.0` development branch. It would match `1.0.0`, Version constraints can be specified in a few different ways. -Name | Example | Description --------------- | --------------------- | ----------- -Exact version | `1.0.2` | You can specify the exact version of a package. -Range | `>=1.0` `>=1.0,<2.0` | By using comparison operators you can specify ranges of valid versions. Valid operators are `>`, `>=`, `<`, `<=`, `!=`. You can define multiple ranges, separated by a comma, which will be treated as a **logical AND**. -Wildcard | `1.0.*` | You can specify a pattern with a `*` wildcard. `1.0.*` is the equivalent of `>=1.0,<1.1`. -Tilde Operator | `~1.2` | Very useful for projects that follow semantic versioning. `~1.2` is equivalent to `>=1.2,<2.0`. For more details, read the next section below. +Name | Example | Description +-------------- | --------------------- | ----------- +Exact version | `1.0.2` | You can specify the exact version of a package. +Range | `>=1.0` `>=1.0,<2.0` `>=1.0,<1.1 | >=1.2` | By using comparison operators you can specify ranges of valid versions. Valid operators are `>`, `>=`, `<`, `<=`, `!=`.
You can define multiple ranges, separated by a comma, which will be treated as a **logical AND**. A pipe symbol `|` will be treated as a **logical OR**.
AND has higher precedence than OR. +Wildcard | `1.0.*` | You can specify a pattern with a `*` wildcard. `1.0.*` is the equivalent of `>=1.0,<1.1`. +Tilde Operator | `~1.2` | Very useful for projects that follow semantic versioning. `~1.2` is equivalent to `>=1.2,<2.0`. For more details, read the next section below. ### Next Significant Release (Tilde Operator) From 4c8e8ca7020447b2a16baa0a7dc3ec3a7ccf2e41 Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Mon, 14 Oct 2013 14:47:55 -0700 Subject: [PATCH 3/6] Allow specifying HHVM as a dependency --- src/Composer/Repository/PlatformRepository.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/Composer/Repository/PlatformRepository.php b/src/Composer/Repository/PlatformRepository.php index dcf791857..214c8022f 100644 --- a/src/Composer/Repository/PlatformRepository.php +++ b/src/Composer/Repository/PlatformRepository.php @@ -144,5 +144,19 @@ class PlatformRepository extends ArrayRepository $lib->setDescription('The '.$name.' PHP library'); parent::addPackage($lib); } + + if (defined('HHVM_VERSION')) { + try { + $prettyVersion = HHVM_VERSION; + $version = $versionParser->normalize($prettyVersion); + } catch (\UnexpectedValueException $e) { + $prettyVersion = preg_replace('#^([^~+-]+).*$#', '$1', HHVM_VERSION); + $version = $versionParser->normalize($prettyVersion); + } + + $hhvm = new CompletePackage('hhvm', $version, $prettyVersion); + $hhvm->setDescription('The HHVM Runtime (64bit)'); + parent::addPackage($hhvm); + } } } From 4f51db72f85c6bee5c65aae9ca78919be5257b49 Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Mon, 14 Oct 2013 14:54:08 -0700 Subject: [PATCH 4/6] hhvm version constant still called HPHP on older versions so use it for bc --- src/Composer/Repository/PlatformRepository.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Composer/Repository/PlatformRepository.php b/src/Composer/Repository/PlatformRepository.php index 214c8022f..550d180db 100644 --- a/src/Composer/Repository/PlatformRepository.php +++ b/src/Composer/Repository/PlatformRepository.php @@ -145,12 +145,12 @@ class PlatformRepository extends ArrayRepository parent::addPackage($lib); } - if (defined('HHVM_VERSION')) { + if (defined('HPHP_VERSION')) { try { - $prettyVersion = HHVM_VERSION; + $prettyVersion = HPHP_VERSION; $version = $versionParser->normalize($prettyVersion); } catch (\UnexpectedValueException $e) { - $prettyVersion = preg_replace('#^([^~+-]+).*$#', '$1', HHVM_VERSION); + $prettyVersion = preg_replace('#^([^~+-]+).*$#', '$1', HPHP_VERSION); $version = $versionParser->normalize($prettyVersion); } From 42dd2f2ee8dad155ec566fe8405980dea7b2196f Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Mon, 14 Oct 2013 15:15:09 -0700 Subject: [PATCH 5/6] Check only part of the error message as it's different in hhvm --- tests/Composer/Test/Util/ErrorHandlerTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Composer/Test/Util/ErrorHandlerTest.php b/tests/Composer/Test/Util/ErrorHandlerTest.php index 485c2bd39..cb16a1e13 100644 --- a/tests/Composer/Test/Util/ErrorHandlerTest.php +++ b/tests/Composer/Test/Util/ErrorHandlerTest.php @@ -38,7 +38,7 @@ class ErrorHandlerTest extends TestCase */ public function testErrorHandlerCaptureWarning() { - $this->setExpectedException('\ErrorException', 'array_merge(): Argument #2 is not an array'); + $this->setExpectedException('\ErrorException', 'array_merge'); ErrorHandler::register(); From 565f86f30d9d9ef5ba6b9993e51a99affa98e14d Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Mon, 14 Oct 2013 17:53:02 -0700 Subject: [PATCH 6/6] Fix stream context option test to really only verify content-type is last --- tests/Composer/Test/Util/StreamContextFactoryTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Composer/Test/Util/StreamContextFactoryTest.php b/tests/Composer/Test/Util/StreamContextFactoryTest.php index a12419afa..9e1bae090 100644 --- a/tests/Composer/Test/Util/StreamContextFactoryTest.php +++ b/tests/Composer/Test/Util/StreamContextFactoryTest.php @@ -192,6 +192,6 @@ class StreamContextFactoryTest extends \PHPUnit_Framework_TestCase ); $context = StreamContextFactory::getContext('http://example.org', $options); $ctxoptions = stream_context_get_options($context); - $this->assertEquals(join("\n", $ctxoptions['http']['header']), join("\n", $expectedOptions['http']['header'])); + $this->assertEquals(end($ctxoptions['http']['header']), end($expectedOptions['http']['header'])); } }