nkkollaw / zubr

Wrapper library to fix inconsistencies in PHP's core functions
MIT License
99 stars 6 forks source link

Handle different PHP versions #102

Open nkkollaw opened 7 years ago

nkkollaw commented 7 years ago

As mentioned in the README, Zubr supports PHP >= 7.0.0.

However, there are some differences between PHP 7.0, 7.1, and 7.2 that we'll have to account for.

PHP 7.1

For instance, 7.1 introduces a few functions that aren't present in 7.0: http://php.net/manual/en/migration71.new-functions.php

There are also changed functions (see http://php.net/manual/en/migration71.changed-functions.php), and finally some backward-imcompatible changes (see http://php.net/manual/en/migration71.incompatible.php).

PHP 7.2

There is no migration guide yet that I can link to, but there will be incompatibilities here as well.

Possible solutions

We could/should probably check that a function exists before calling it, and do something if it doesn't.

We could also have switch statements to account for changes between versions (?).

Opinions..?

ddziaduch commented 7 years ago

I think we should look whether function is declared before declaring it's wrapper

radmen commented 7 years ago

I think that @ddziaduch is right - we should bother in wrapping only existing functions (eg in PHP 7.0 Zubr\session_gc() should throw an exception).

Regarding changed functions - maybe we should stick to the latest API. Eg. getopt() received in 7.1 new argument. We could simply trigger_error when someone sets $optind argument on PHP 7.0. What do you think about it?

nkkollaw commented 7 years ago

Yes, I think we should both check if the function exists before wrapping it, and consider changed parameters.

Although, if one called a function that didn't exist, Zubr would already trigger an error by calling it...