-
-
Notifications
You must be signed in to change notification settings - Fork 4
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
Expire comment by composer dependency package version #32
Conversation
@nikophil wdyt? feedback welcome |
@m29corey maybe you can run this against some real world projects to see possible perf impact? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, this seems to be a great idea.
In some personal open source project, I encounter the situation where I have code to support both Symfony 6 and 7 (for example) ; with a composer constraint
"symfony/symfony": "^6 || ^7"
and with a comment in my code
TODO Remove this when dropping Symfony 6 support
And even if locally my composer.lock use SF 7, I would expect to not have the error until I remove ^6
from the composer.json.
Does this PR could satisfy this need ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wow this was fast 😅
actually my rule is looking pretty much not different from yours!
// TODO: not-installed/package:<5 this should error because package is not in composer.json | ||
|
||
// TODO: phpunit/phpunit:<9 | ||
// TODO: phpunit/phpunit:<10 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wouldn't this test fail when using phpunit 10? 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
right, I had had the logic reversed. I think all feedback is addressed now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and now your rule looks even closer from mine 😅
I've also added a way to test against php version. I've done my rule few month ago, but I think if I've done this because if ('php' === $dependency) {
if (\version_compare(\PHP_VERSION, $constraint, '>=')) {
$errors[] = \sprintf('dependency "%s" satisfies constraint "%s"%s', $dependency, $constraint, $message ? ": {$message}." : '.');
}
continue;
} |
tests/data/packageVersion.php
Outdated
// TODO: phpunit/phpunit:<50 This has to be fixed when updating to phpunit 50.x | ||
|
||
// TODO: phpunit/phpunit:<5 This has to be fixed when updating to phpunit 5.x | ||
// TODO: phpunit/phpunit:5.3.* This has to be fixed when updating to phpunit 5.3.* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actually I've done my check the other way around, and the rule fails when constraint is satisfied
phpunit/phpunit:>=10
I think it reads better: "please phpstan, fail when phpunit meets this dependency"
About this specific todo: phpunit/phpunit:5.3.*
, I think it would not fail when phpunit is at 5.3.*
but it will if we have phpunit>=5.4.0 and phpunit<5.3, which seems pretty strange
My take was to always add >=
if the constraint does not specifies it
@VincentLanglet I don't think this PR satisfies your need: it only looks on what is currently required by |
I have similar stuff locally. what I don't like is, that this code depends on the runtime php version. I would want to compare the composer.json php requirement against the comment constraint.. I haven't found a way to achieve that though :) |
@VincentLanglet I think it kind of satiesfies it, but in an unexpected way. the result of the check depends on your composer.lock, which means it compares against the constraints which have been installed with this means as long as you run the check against a composer.lock which was generated with the minimum supported php version of your package, it should work |
closes #31