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

PHP_VERSION conditional is not recognized #201

Open
cmb69 opened this issue May 19, 2015 · 3 comments
Open

PHP_VERSION conditional is not recognized #201

cmb69 opened this issue May 19, 2015 · 3 comments
Assignees

Comments

@cmb69
Copy link
Contributor

cmb69 commented May 19, 2015

Consider the following script:

<?php

if (PHP_VERSION >= '5') {
    md5('foo', true);
}

The second parameter to md5() is only available as of PHP 5.0.0, but the call is guarded by a respective check based on PHP_VERSION. Unfortunately, phpcompatinfo-4.2.0.phar analyser:run . reports:

Requires PHP 5.0.0 (min), PHP 5.0.0 (all)

In my opinion, checking for PHP_VERSION should be generally avoided (preferring a feature test instead), but when it comes to newly introduced parameters there might not be an alternative. It would be great if PHP CompatInfo could catch at least those cases where PHP_VERSION is compared to a literal (most likely comparing to a variable isn't possible to check at all).

@llaville
Copy link
Owner

Detecting conditional code is not so easy.
Consider not just your user case, but more generally what to do when a condition is found, and what to do with code below the condition.

if (condition) 
   code_1;
   code_2;   
endif

Actually PHP CompatInfo 4.x is not able to handle it, and I dont' think its possible with monolith compatibility analyser.

Last week, I've begun to write a new migration analyser that checks for forbidden and deprecated elements (functions, constants, ini directives). It works pretty well, but I've in mind to refactor it with Sniff like PHP_CodeSniffer.
I'll open a new RFC (Request For Comments) to know point of you of all users, and see if it's usefull to write a such reloaded project.

@llaville
Copy link
Owner

RFC is now opened at #202

@llaville
Copy link
Owner

llaville commented Oct 5, 2017

Perharps a new hope with major version 6.0. Will see ...

@llaville llaville added this to the 6.0 milestone Oct 5, 2017
@llaville llaville self-assigned this Oct 5, 2017
@llaville llaville removed this from the 6.0 milestone May 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants