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

composer requirements verification #353

Open
deubert-it opened this issue Jul 8, 2022 · 6 comments
Open

composer requirements verification #353

deubert-it opened this issue Jul 8, 2022 · 6 comments

Comments

@deubert-it
Copy link

New Feature request

Summary

Verify or suggest changes to a given composer.json - php version/php extension requirements.

Description

Based on the required modules and php version the analyzer detects for a given path, I would like to be able to compare this information to a given composer.json.

The composer.json can hold requirements like this:

"require": {
  "php": "^7.3",
  "ext-zip": "*",
  "ext-simplexml": "*",
  "ext-json": "*",
[..]

The output of the compatinfo analysis should be compared against this to either verify its correctness, or if there are mismatches, suggest changes to the composer.json to match actual requirements from the code.

The composer.json can contain php version pinning, which should also be taken into consideration:

"config": {
  "platform": {
    "php": "7.3.24"
  }
}

If you think it makes sense to add this feature to this library, and could give me some pointers where to put what, I'd be happy to invest some time into this for implementation.

@llaville
Copy link
Owner

llaville commented Jul 8, 2022

Agree with you, it may be a cool feature ! I've a lot of work to do before, but if you are in hurry, you can submit a PR ?

@deubert-it
Copy link
Author

Hi @llaville ,

please check my PR which should be linked - there is more information about it in the PR description.

Screenshot from 2022-07-09 14-38-24

@llaville
Copy link
Owner

Sorry @deubert-it, I was very busy last weeks and have no free time to have a chance to have a look. I hope to check it next week !

@llaville
Copy link
Owner

Hello @deubert-it
I've finally took time to have a look on your PR proposal.
First I would like to thanks you for this effort, even if I think it's not the best way : I'll try to explains why !

PHP CompatInfo v6 has an architectecture based on Extension(s) (see https://github.com/llaville/php-compatinfo/blob/master/docs/01_Components/04_Extensions/Hooks.md) to extends and add new features without altering the analyser:run command.

Reporter category allows to present results on new format (see https://github.com/llaville/php-compatinfo/blob/master/docs/01_Components/04_Extensions/Reporter.md)

There are two standard extensions (Logger and ProgressBar), but in your context (needs) you have to display a new report as output, so the Reporter extension is the best example to follow.

If something is not enough clear, please ask me again !

@llaville
Copy link
Owner

Hello @deubert-it

Don't know if you've missed my previous comment, or if you're too much busy, but I'll let you know that finally branch 6.5 is available.
If you've time to provide a new PR with this code base, I'll have a review on it !
If you've no more free time to do it yourself, I'll be happy to migrate your proposal to this new code base.

Awaiting your answer :)

@llaville
Copy link
Owner

There is a use case that didn't proceed as expected for me !

When source code analysed give a version that is lower than the constraint provided in composer.json

I.e: source code analysed requires a minimum PHP 5.4 while composer constraint is ^7.4

Give such kind of output


 [ERROR] minimal required php version 5.4.0 from analysis does not match the required php version constraint in
         composer.json ^7.4

< ... MORE ...>

 [ERROR] composer.json verification failed!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants