-
Notifications
You must be signed in to change notification settings - Fork 20
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
Awareness of compatibility packages #237
Comments
Many versions and years later, upcoming release 6.4 will finally include this new feature ! |
I've a prototype available with the new |
That's exciting @llaville! Are you looking for me to submit a test case? |
I'll push the code to a new branch polyfill tomorrow. Your feedback, and any test you could done will be welcome ! |
@glynnforrest Code is available. We need to optimize process because polyfills initialization take too much time for me. Here is an example with PHP CompatInfo 6.4 code scanned Without polyfills, results are wrong and give PHP 8.0 as min requirements, while with polyfills, results are as expected. You need to initialized
And run data source code analyse |
BTW, after a night to think about a better solution, I've in mind, in next days, to include polyfills handle to the https://github.com/llaville/php-compatinfo-db project, and adjust code in CompatInfo. In the meantime, if somebody want to share is feedback about this feature before it will become official, he will be welcome ! |
CompatInfoDB 4.2.x-dev is ready to support polyfills. See commit llaville/php-compatinfo-db@c5ce8ac |
CompatInfo 6.4.x (with branch NOTE: it won't be necessary in final version of CompatInfoDB 4.2.0 were symfony/polyfill will be added. To add a polyfill (compatible) like https://github.com/symfony/polyfill/tree/main/src/Php80 do as follow :
|
Reminder: This report will be closed in 5 days even if I don't receive any feedback ! |
Thanks for your work on this @llaville! I can't get this feature working, am I doing something wrong? Here is an example of trying php -v
# PHP 7.4.28 (cli) (built: Mar 1 2022 01:37:04) ( NTS ) Create #!/usr/bin/env php
<?php
var_dump(str_starts_with('foobar', 'foo')); ./test.php
# PHP Fatal error: Uncaught Error: Call to undefined function str_starts_with() Add the polyfill: composer require symfony/polfill-php80 ^1.25.0 #!/usr/bin/env php
<?php
+ include 'vendor/autoload.php';
var_dump(str_starts_with('foobar', 'foo')); ./test.php
# bool(true) Now analyse with composer require bartlett/php-compatinfo ^6.4-dev
./vendor/bin/phpcompatinfo db:create
./vendor/bin/phpcompatinfo db:init # At least one distribution platform should exist. None available. Run "db:init" command to build one.
./vendor/bin/phpcompatinfo db:polyfill symfony/polyfill-php80 v1.25.0 --php 8.0 -v
./vendor/bin/phpcompatinfo db:create I see polyfill analysis in the output, but still PHP 8 is required: I tried with:
|
When you try to install source code version from a branch, take care to give the right constaint: With
Picking code from branch With following constraint
You get the right code, verified by Composer output
Now, that Polyfills feature is supported by PHP CompatInfo DB 4.2.0, you don't have to specify the So, in summary :
|
With commit 5f81d4d, unit tests and |
I've just opened a discussion #350 to explain how to understand polyfill results |
* new feature request #237 about polyfill detection * upgrade to actions/checkout v3 * raise bartlett/php-compatinfo-db constraint to 4.2 minimum to support polyfill feature
Firstly, thank you for this great tool! I thought I was going to have to write a script to figure out what extensions a project required. I'm glad I can use this tool instead.
Do you think it would be possible for the script to detect usage of 'compat' packages, that bring newer features to older PHP versions?
For example, I have some code that uses
random_bytes()
, introduced in PHP 7. By requiringparagonie/random_compat
I can have it work for older versions. It would be great ifphp-compat-info
could detect this.I guess this would require parsing the requirements in
composer.json
to see if any of these packages are being used.Some package examples:
The text was updated successfully, but these errors were encountered: