Efthyvoulos Tsouderos
Efthyvoulos Tsouderos

Reputation: 85

check the php version compatibility of a php script

I have a php script. I want to check the php version compatibility that each function of this script has. For example the script has the hash() function. If we look at php.net site it says that this function was added (PHP 5 >= 5.1.2, PECL hash >= 1.1). So assuming that this script has only this function we say that it is compatible with php 5.1.2 and onwards. Is there any software tool that can scan the script and tell you the changelog of every function and possibly gives you the lowest possible score e.g. (php version 4.3 and on)? It is a bit tedious to check manually every function in the script. Thank you in advance

Upvotes: 4

Views: 1501

Answers (1)

hek2mgl
hek2mgl

Reputation: 157967

As PHP supports dynamic function/method names, just searching through the source code would not give reliable results.

Example:

$function = 'strpos';
$result = $function(...);

You might use xdebug function traces together with a 100% test coverage. This could give you all function names which had been called during a test suite run with 100% coverage - meaning all code has run. But even this isn't reliable as you would have to make sure, that your test suite covered all possible dynamic function names what is impossible. (assuming the max length of a function name is unlimited)

My final answer is: this isn't reliably possible.

Upvotes: 1

Related Questions