Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include examples in documentation #833

Merged
merged 1 commit into from
Feb 21, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 33 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,16 @@ When `composer.json` contains version constraints in the

sections, the `Vendor\Composer\VersionConstraintNormalizer` will ensure that

- all constraints are trimmed
- all version constraints are trimmed

```diff
{
"homepage": "https://getcomposer.org/doc/articles/versions.md#version-range",
"require": {
- "php": " ^8.2 "
+ "php": "^8.2"
}
```

- version constraints separated by a space (` `) or comma (`,`) - treated as a logical and - are separated by a space (` `) instead

Expand All @@ -467,8 +476,29 @@ sections, the `Vendor\Composer\VersionConstraintNormalizer` will ensure that
}
```

- *or- constraints are separated by double-pipe with a single space before and after (` || `)
- *range- constraints are separated by a single space (` `)
- version constraints separated by a single- (`|`) or double-pipe (`||`) and any number of spaces before and after - treated as a logical or - are separated by a double pipe with a single space before and after (` || `)

```diff
{
"homepage": "https://getcomposer.org/doc/articles/versions.md#version-range",
"require": {
- "php": "^8.1|^8.2",
- "foo/bar": "^1.2.3 || ^2.3.4"
+ "php": "^8.1 || ^8.2",
+ "foo/bar": "^1.2.3 || ^2.3.4"
}
```

- hyphenated version constraints separated by dash (` - `) and any positive number of spaces before and after are separated by a dash with a single space before and after (` - `)

```diff
{
"homepage": "https://getcomposer.org/doc/articles/versions.md#hyphenated-version-range-",
"require": {
- "foo/bar": "1.2.3 - 2.3.4"
+ "foo/bar": "1.2.3 - 2.3.4"
}
```

:bulb: Find out more about version constraints at [Composer: Version and Constraints](https://getcomposer.org/doc/articles/versions.md).

Expand Down