Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:97000 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 94002 invoked from network); 18 Nov 2016 18:05:49 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 18 Nov 2016 18:05:49 -0000 Authentication-Results: pb1.pair.com header.from=php-lists@koalephant.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=php-lists@koalephant.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain koalephant.com designates 206.123.115.54 as permitted sender) X-PHP-List-Original-Sender: php-lists@koalephant.com X-Host-Fingerprint: 206.123.115.54 mail1.25mail.st Received: from [206.123.115.54] ([206.123.115.54:39356] helo=mail1.25mail.st) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 65/11-22513-AF24F285 for ; Fri, 18 Nov 2016 13:05:46 -0500 Received: from [10.0.1.23] (unknown [183.89.41.42]) by mail1.25mail.st (Postfix) with ESMTPSA id ADBA360571; Fri, 18 Nov 2016 18:05:34 +0000 (UTC) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 9.3 \(3124\)) In-Reply-To: Date: Sat, 19 Nov 2016 01:05:30 +0700 Cc: PHP Internals Content-Transfer-Encoding: quoted-printable Message-ID: <1D125748-F883-4568-9FE0-661AA2CC203D@koalephant.com> References: To: David Rodrigues X-Mailer: Apple Mail (2.3124) Subject: Re: [PHP-DEV] Declare directive to change engine version basis From: php-lists@koalephant.com (Stephen Reay) Hi David, If you wanted to do this, couldn=E2=80=99t 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 = wrote: >=20 > Hello. >=20 > 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. >=20 > - >=20 > It should works like it (eg. for engine version "7.0.13"): >=20 > declare( {{parameter}} =3D {{php_version_id}} ); >=20 > // Examples (one of that): > declare( engine_version =3D 70013 ); // or > declare( php_version =3D 70013 ); >=20 > - >=20 > By default, this declaration is not defined (null or 0), then will not > do anything to engine if it's not declared on script. >=20 > - >=20 > This declaration could be done at: >=20 > - 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); >=20 > - >=20 > 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. >=20 > - >=20 > Let working on an example from: = https://wiki.php.net/rfc/deprecations_php_7_2 >=20 > 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: >=20 > - no declared or null: just a deprecation notice; > - declare as 70200 or higher: error, (unset) cast doesn't exists > (or something like that) >=20 > - >=20 > 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. >=20 > - >=20 > 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. >=20 > - >=20 > What happen on engine code is something like that (pseudo-code): >=20 > int engine_version () { > return (int) engine_version_declaration; > } >=20 > cast type unset () { > if (engine_version() >=3D 70201) { > fatal(cast doesn't supported); > } >=20 > notice(deprecated); > return null; > } >=20 >=20 > --=20 > David Rodrigues >=20 > --=20 > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php >=20