Home » PHP » PHP_CompatInfo » Bug #6056
Add support for reporting max PHP version
Details
| Request #6056 | Add support for reporting max PHP version |
|---|---|
| Submitted | 2005-11-24 11:35 UTC |
| From | giunta dot gaetano at sea-aeroportimilano dot it |
| Assigned | farell |
| Status | Closed |
| Package | PHP_CompatInfo |
| PHP Version | 4.4.1 |
| OS | irrelevant |
| Roadmaps | (Not assigned) |
Comments
[2005-11-24 11:35 UTC] giunta dot gaetano at sea-aeroportimilano dot it
Description:
------------
Hi there.
I added support for a 'max supported php version' to the script. It is added as new key ('max_version') to the fileinfo array.
The patched version of the script is below, copy'n'pasted.
To actually have the script emit anyting, the func_array and const_array must be augmented, adding an 'end' key indicating the maximum php version that supports a feature. If the key is absent from the data arrays, the script assumes max version is infinite, i.e. no warning will be emitted when running with current data arrays.
The only function that has been removed, off the top of my head is php_check_syntax (PHP 5 <= 5.0.4), but there might be others...
NB: future updates I might post: adding a 'supported os + webserver' calculating routine, based on the used extensions; analysis of parameter count for functions, so that functions that got parameters added in later releases can be detected; analysis of usage of 'include/require', 'eval' and similar constructs, so that user can be informed in those cases about the analysis not being accurate.
Test script:
---------------
Diff to CompatInfo.php,v 1.15
59,64d58
< /**
< * @var string Last version of PHP to use
< */
<
< var $earliest_version = '';
<
152,153d145
< $earliest_version = $this->earliest_version;
<
188,191d179
< if ($file['max_version'] != '') {
< if ($earliest_version = '' || 1 === version_compare($earliest_version, $file['max_version']))
< $earliest_version = $file['max_version'];
< }
211d198
< $files['max_version'] = $earliest_version;
261d247
< $earliest_version = $this->earliest_version;
295,298d280
< if ($file['max_version'] != '') {
< if ($earliest_version = '' || 1 === version_compare($earliest_version, $file['max_version']))
< $earliest_version = $file['max_version'];
< }
315d296
< $files_parsed['max_version'] = $earliest_version;
338d318
< $earliest_version = $this->earliest_version;
411,415d390
< if (array_key_exists('end', $GLOBALS['funcs'][$name])) {
< if ($earliest_version == '' || 1 === version_compare($earliest_version,$GLOBALS['funcs'][$name]['end'])) {
< $earliest_version = $GLOBALS['funcs'][$name]['init'];
< }
< }
438,442d412
< if (array_key_exists('end', $GLOBALS['const'][$constant])) {
< if ($earliest_version == '' || 1 === version_compare($earliest_version,$GLOBALS['const'][$constant]['end'])) {
< $earliest_version = $GLOBALS['funcs'][$name]['init'];
< }
< }
453d422
< $functions_version['max_version'] = $earliest_version;
519d487
<
[2006-06-19 07:47 UTC] giunta dot gaetano at sea-aeroportimilano dot it
There is a lot of stuff that changed between php 4 and php 5...
As an example, in PHP 5 the charset param used for creation of an xml parser has been deprecated. The same applies for the 'var' keyword...
[2006-06-28 14:59 UTC] giunta dot gaetano at sea-aeroportimilano dot it
I did not really check the source code, but the end results look fine to me (at least when parsing the test file you provided).
What do you exactly mean by "ambiguity that is possible" ?