llaville / php-compatinfo

Library that find out the minimum version and the extensions required for a piece of code to run
https://llaville.github.io/php-compatinfo/7.1/
Other
373 stars 20 forks source link

Closures that work in PHP 5.3 are reported as requiring 5.4 #231

Closed jack126guy closed 7 years ago

jack126guy commented 7 years ago

The following code works on PHP 5.3 (confirmation on 3v4l.org) but PHP CompatInfo 5.0.6 reports it as requiring PHP 5.4:

<?php
function call_with_world($f) {
        call_user_func($f, 'world');
}

call_with_world(function($name) {
        echo 'Hello, ' . $name;
});

I believe this is a result of the fix for #229: It seems that any variable in a closure triggers the "upgrade" to a 5.4 requirement.

jack126guy commented 7 years ago

It does not even have to be a parameter. The following code is also reported as requiring PHP 5.4, even though it works in 5.3 (3v4l confirmation):

<?php
$f = function() {
    $name = 'world';
    echo 'Hello, ' . $name;
};

call_user_func($f);
llaville commented 7 years ago

Hello, Thanks for this analysis. I think your're right about origin of regression (issue #229 ). I'll try to fix it tonight, just after released a new php-compatinfo-db (add support to php 7.0.19).

thanks for reporting

remicollet commented 7 years ago

(add support to php 7.0.19)

You mean 7.0.20 ? (release on June 8th)

llaville commented 7 years ago

@remicollet I 've forgotten to release the php-compatinfo-db 1.21 that support PHP 7.0.19 So I'll do it right now; But I'll try to publish a new version 1.22 that will support PHP 7.0.20 (today release) this saturday morning.

llaville commented 7 years ago

php-compatinfo-db 1.22 just been released. Next one will include support of PHP 7.0.20 but also the same behavior for sqlite database. Store in same directory either for phar or standard distrib (user .bartlett folder)

llaville commented 7 years ago

I've just been released php-compatinfo-db 1.22.0 and forget to add new behavior (see previous comment). DB in same folder : see also https://github.com/llaville/php-compatinfo-db/issues/9

Will be for next version now.

I'm on my way to release the php-compatinfo 5.0.7 in few minutes now !