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

Normalizing of version constraints not suitable for all use-cases - can it be made disable/confgurable in some way ? #1287

Closed
sbuerk opened this issue Feb 5, 2024 · 4 comments
Assignees
Labels

Comments

@sbuerk
Copy link

sbuerk commented Feb 5, 2024

Steps required to reproduce the problem

  1. composer require "php":"^7.4 || ^8.0 || ^8.1 || ^8.2 || ^8.3"
  2. Execute composer normalize

Expected Result

  • "php": "^7.4 || ^8.0 || ^8.1 || ^8.2 || ^8.3"

Actual Result

  • "php": "^7.4 || ^8.0"

Remarks

I know that there are different opionons out there about how to deal with dependecy version constraints, and therefore I'd say a option to disable the dependency version constraint normalization at whole would be nice.

For me this means, the normalizer is not usable because of this - but I would pretty much use all
the other normalization this tools offers - specially as a pipeline check.

Can we made this a config / command option in some way ?

sbuerk added a commit to sbuerk/shortcut-redirect-statuscodes that referenced this issue Feb 5, 2024
The introduced scheduled job dispatcher failes
due to insufficient permissions. To mitigate,
a proper permission request needs to be added.

This change modifes the `scheduled.yml` GitHub
action workflow to request required permissions.

Note: composer normalizer is disabled temporarly
due to a unwanted behaviour. Todo comment for
disabled workflow action is added. [1]

[1] ergebnis/composer-normalize#1287

Resolves: #2
Releases: main
sbuerk added a commit to sbuerk/shortcut-redirect-statuscodes that referenced this issue Feb 5, 2024
The introduced scheduled job dispatcher failes
due to insufficient permissions. To mitigate,
a proper permission request needs to be added.

This change modifes the `scheduled.yml` GitHub
action workflow to request required permissions.

Note: composer normalizer is disabled temporarly
due to a unwanted behaviour. Todo comment for
disabled workflow action is added. [1]

[1] ergebnis/composer-normalize#1287

Resolves: #2
Releases: main
sbuerk added a commit to sbuerk/shortcut-redirect-statuscodes that referenced this issue Feb 5, 2024
The introduced scheduled job dispatcher failes
due to insufficient permissions. To mitigate,
a proper permission request needs to be added.

This change modifes the `scheduled.yml` GitHub
action workflow to request required permissions.

Note: composer normalizer is disabled temporarly
due to a unwanted behaviour. Todo comment for
disabled workflow action is added. [1]

[1] ergebnis/composer-normalize#1287

Resolves: #2
Releases: main
@fredden
Copy link

fredden commented Feb 5, 2024

^8.0 already allows for / includes 8.1.2, so specifying ^8.1 is redundant. This tool is removing the redundancy.

As an example, compare https://semver.madewithlove.com/?package=composer%2Fcomposer&constraint=%5E2.5 with https://semver.madewithlove.com/?package=composer%2Fcomposer&constraint=%5E2.5+%7C%7C+%5E2.6

It looks like you intended to say "php":"~7.4.0 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0". (Note the use of the tilde operator, not the caret operator.) https://getcomposer.org/doc/articles/versions.md#next-significant-release-operators

Note that by saying "php": "^7.4 || ^8.0", you're claiming support for PHP version 8.6, which does not exist at time of writing. I don't think that PHP follows semantic versioning, so using the caret operator doesn't make sense here.

@fredden
Copy link

fredden commented Feb 5, 2024

Normalizing of version constraints not suitable for all use-cases

The example you have provided is where this tool removes a completely redundant set of constraints. Is this the only use-case that you don't like, or is there another example you can provide?

@sbuerk
Copy link
Author

sbuerk commented Feb 6, 2024

As mentioned, different opinions. Ack, technical it's redunant and there is no point against it. However, from a human readable point, expresession them in that way can be taken as "these are official supported minor php versions branches, newer once may work work or not. Which allows using higher php version to test it until it is added.

Using the stricter variant

~7.4.0 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0

means that only these can be used and forbids newer php version per default. And if PHP 8.4 is released at some point requireing projects/packages needs to wait until it is added or using nasty platform-ignore-req hacks which opens other can of worms. It's matter of reading and understanding, not the pure technical aspect what it means and acts like.

Don't get me wrong - it was simply a question and I know a lot of people not using composer-normalize exactly out of this reason / behaviour.

I'm not asking for a default change in behaviour - only for a configurable opt-in. If that's not wanted it's fully okay. I don't want to fight about it. If a option is not reasonable to disable/change that behaviour I will simply not use composer normalizer as it is not suitable for me. (and maybe others). Doing the work to fork the dependency chain and maintain it is not worth for me.

sbuerk added a commit to sbuerk/shortcut-redirect-statuscodes that referenced this issue Feb 8, 2024
The hyped `"ergebnis/composer-normalize"` composer plugin to
normalize composer.json file and using it as a pipeline check
operats strictly on semver and not allowing a more practical
approach regardin the version handling of dependencies.

Due to the fact that having another mindset then this plugin,
it's not usable until it can be controlled. [1]

Therefore, the plugin is removed again until this point which
may never come. Handling the composer.json file manually in
shape is doable.

Used command(s):

```terminal
> Build/Scripts/runTests.sh -s composer \
    -- remove --dev "ergebnis/composer-normalize"
```

[1] ergebnis/composer-normalize#1287

Releases: main
sbuerk added a commit to sbuerk/shortcut-redirect-statuscodes that referenced this issue Feb 8, 2024
The hyped `"ergebnis/composer-normalize"` composer plugin to
normalize composer.json file and using it as a pipeline check
operats strictly on semver and not allowing a more practical
approach regardin the version handling of dependencies.

Due to the fact that having another mindset then this plugin,
it's not usable until it can be controlled. [1]

Therefore, the plugin is removed again until this point which
may never come. Handling the composer.json file manually in
shape is doable.

Used command(s):

```terminal
> Build/Scripts/runTests.sh -s composer \
    -- remove --dev "ergebnis/composer-normalize"
```

[1] ergebnis/composer-normalize#1287

Releases: main
sbuerk added a commit to sbuerk/shortcut-redirect-statuscodes that referenced this issue Feb 8, 2024
The hyped `"ergebnis/composer-normalize"` composer plugin to
normalize composer.json file and using it as a pipeline check
operats strictly on semver and not allowing a more practical
approach regardin the version handling of dependencies.

Due to the fact that having another mindset then this plugin,
it's not usable until it can be controlled. [1]

Therefore, the plugin is removed again until this point which
may never come. Handling the composer.json file manually in
shape is doable.

Used command(s):

```terminal
> Build/Scripts/runTests.sh -s composer \
    -- remove --dev "ergebnis/composer-normalize"
```

[1] ergebnis/composer-normalize#1287

Releases: main
sbuerk added a commit to sbuerk/shortcut-redirect-statuscodes that referenced this issue Feb 8, 2024
The hyped `"ergebnis/composer-normalize"` composer plugin to
normalize composer.json file and using it as a pipeline check
operats strictly on semver and not allowing a more practical
approach regardin the version handling of dependencies.

Due to the fact that having another mindset then this plugin,
it's not usable until it can be controlled. [1]

Therefore, the plugin is removed again until this point which
may never come. Handling the composer.json file manually in
shape is doable.

Used command(s):

```terminal
> Build/Scripts/runTests.sh -s composer \
    -- remove --dev "ergebnis/composer-normalize"
```

[1] ergebnis/composer-normalize#1287

Releases: main
@localheinz
Copy link
Member

@sbuerk

Allowing to configure ergebnis/composer-normalize beyond the existing configuration options is something I would like to avoid - it's unnecessary complexity.

Having said that, I agree with @fredden's comment #1287 (comment).

Example

Running

composer require composer/semver

and creating a file test.php with the following content

<?php

declare(strict_types=1);

use Composer\Semver;

require_once __DIR__ . '/vendor/autoload.php';

$parser = new Semver\VersionParser();

$one = $parser->parseConstraints('^7.4 || ^8.0 || ^8.1 || ^8.2 || ^8.3');
$two = $parser->parseConstraints('^7.4 || ^8.0');

var_dump(
    $one->matches($two),
    $two->matches($one),
);

and running

php test.php

yields

bool(true)
bool(true)

The example above confirms what @fredden said in #1287 (comment).

Documenting PHP version support

If you want to document your PHP version support and prevent installation of a package on unsupported versions of PHP you could use the ~ operator, as suggested by @fredden.

For reference, see

@localheinz localheinz self-assigned this Feb 8, 2024
@localheinz localheinz reopened this Feb 8, 2024
@localheinz localheinz closed this as not planned Won't fix, can't repro, duplicate, stale Feb 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants