Hi David, If you wanted to do this, couldn’t you simply use the following, already:
set_error_handler( function (int $err_severity, string $err_msg, string $err_file, int $err_line, array $err_context) { throw new ErrorException($err_msg, 0, $err_severity, $err_file, $err_line) }, E_DEPRECATED ); ? > On 18 Nov 2016, at 23:18, David Rodrigues <david.pro...@gmail.com> wrote: > > Hello. > > I like to propose a creation of a new declare() directive that allows > "emulates a future engine version". And where I say engine I mean PHP > itself. > > - > > It should works like it (eg. for engine version "7.0.13"): > > declare( {{parameter}} = {{php_version_id}} ); > > // Examples (one of that): > declare( engine_version = 70013 ); // or > declare( php_version = 70013 ); > > - > > By default, this declaration is not defined (null or 0), then will not > do anything to engine if it's not declared on script. > > - > > This declaration could be done at: > > - First execution file.php (bootstrap): then all application will > follow this engine rules; > - Any file.php: then only current file will follow this rules (to > override locally first declaration); > - php.ini: to set this declaration as default to all applications > (optional); > > - > > What it does: in pratical, if the engine will deprecated or change > something on future versions (mainly causing BCs), you should wait for > a new major version (eg. 7.x -> 8.x). With this declaration you could > emulates a future version to prepares your scripts to a new major > version. > > - > > Let working on an example from: https://wiki.php.net/rfc/deprecations_php_7_2 > > The (unset) cast should not be used anymore because it's have not any > effect (just return null, but not affect the expression or variable). > Let supposed that this deprecation is done at 7.2.0 (id 70200), then > if I'm using this version and I declare engine_version like: > > - no declared or null: just a deprecation notice; > - declare as 70200 or higher: error, (unset) cast doesn't exists > (or something like that) > > - > > Then, what the engine_version does is set some variable to engine that > could check if it could be executed on declared version, then > developers can code their files to future versions without need wait > for it. > > - > > If the installed version is different of declared version, then the > engine will always consider the lowest version between both. For > instance: if installed version is 70201 (7.2.1) and declared version > is 70205 (7.2.5), then engine will consider changes from 70201 (7.2.1, > once that installed is lower). And again: engine will works > differently only if declaration is done, else, it'll works by > deprecation notice, for instance. > > - > > What happen on engine code is something like that (pseudo-code): > > int engine_version () { > return (int) engine_version_declaration; > } > > cast type unset () { > if (engine_version() >= 70201) { > fatal(cast doesn't supported); > } > > notice(deprecated); > return null; > } > > > -- > David Rodrigues > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php