Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:72207 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 26995 invoked from network); 4 Feb 2014 18:59:24 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 4 Feb 2014 18:59:24 -0000 Authentication-Results: pb1.pair.com smtp.mail=tyra3l@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=tyra3l@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.216.172 as permitted sender) X-PHP-List-Original-Sender: tyra3l@gmail.com X-Host-Fingerprint: 209.85.216.172 mail-qc0-f172.google.com Received: from [209.85.216.172] ([209.85.216.172:54580] helo=mail-qc0-f172.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id CF/91-13782-98831F25 for ; Tue, 04 Feb 2014 13:59:23 -0500 Received: by mail-qc0-f172.google.com with SMTP id c9so14584632qcz.31 for ; Tue, 04 Feb 2014 10:59:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=k+Al5N2E/IV/ikFZgHNQdW/uCahj4KD6X8CyaOywn5c=; b=TFmYm1JH21BTHSRkoIbVwlVitU22IMnu1OMM+C+rcIJJKkkgBxAXA1XhlASEU9zD4N tJQGGW2C6CCHnUA7VbIMuClhucUd1b5KZ7pbVBeZ5s9tROSTPGcWrNBdRUGt13b9fldK M+adEIrBfC7a73Uk4LLiO1nqo/TFasa6VWgCo2I26z4pZY4GnwcJlY4ifmYI9ySNOMoM JlfH1B35XrxYsJs6xEKJ3YSFt6RG2EBB8OGt4DrL3l12WQSvzYwR1FYopwONKFCSNNju jCpz6pOMKiMTg8vFeHPeSnyvtXE6a3I8Rxd/rjmHC08ZUFIlzYrPqKuP/H76RZsKbXY4 lYKg== MIME-Version: 1.0 X-Received: by 10.140.39.212 with SMTP id v78mr64679502qgv.77.1391540358431; Tue, 04 Feb 2014 10:59:18 -0800 (PST) Received: by 10.140.96.70 with HTTP; Tue, 4 Feb 2014 10:59:18 -0800 (PST) Received: by 10.140.96.70 with HTTP; Tue, 4 Feb 2014 10:59:18 -0800 (PST) In-Reply-To: References: Date: Tue, 4 Feb 2014 19:59:18 +0100 Message-ID: To: Yasuo Ohgaki Cc: "internals@lists.php.net" Content-Type: multipart/alternative; boundary=001a11c12662c149cf04f1993c0d Subject: Re: [PHP-DEV] Declare minimum PHP version required? From: tyra3l@gmail.com (Ferenc Kovacs) --001a11c12662c149cf04f1993c0d Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 2014.02.03. 7:59, "Yasuo Ohgaki" ezt =C3=ADrta: > > Hi all, > > I thought it might be good for us to have declaring minimum PHP version > required to execute script. > http://jp1.php.net/manual/en/control-structures.declare.php > > Something like > declare(php_version>=3D'5.6.0'); > // or PHP_VERSION_ID? using =3D as minimum as it could be a little faster > // and no change in declare() syntax. > declare(php_version=3D50600); > > If version mismatches, raise compile error and exit. Something like > > Compile error: PHP 5.6.0 or later is required to compile script. Your PHP > version is 5.x.x. > > The same thing can be done by version_compare() and die(), but it does no= t > make much sense executing script only to check PHP version and die, > especially for libraries. For library, it is preferred to fail when it is > included, not when it is executed. I wouldn't write version_compare() and > die() for libraries, but I may use it if it's a declare(). If this is > adopted widely, it may help transition to higher versions hoping users to > consider compile error more seriously. > > Issue would be current behavior for unsupported declaration. > $ php -r "declare(php_version=3D050600);" > Warning: Unsupported declare 'php_version' in Command line code on line 1 > It does not raise E_ERROR, but E_WARNING. > > Just an idea. > Any comments? > > -- > Yasuo Ohgaki > yohgaki@ohgaki.net I don't like the idea. First I don't think that it is a good practice for a library to directly terminate the execution of the application, and because this would be a compile-time check, I don't think we could provide any sane way of allowing the execution of the code. I also think that the performance gain is too small to the average/small users (compared to the usual low-hanging fruits like using an opcode cache, proper autoloading, etc.) while the big users would be doing the checks installation-time anyways, so they wouldn't use it. For general purpose applications (like drupal/wordpress/etc.) it wouldn't be useful either, because they want nice and descriptive error screens instead of php fatal errors which would most of the time just result in a blank screen and some lines in the error log. The only target audience would be the specific group of library developers who think that the execution of their lib is more important than the app which calls them, and for those people we already have version_compare() and exit. Ps: sent from my phone, sorry for the typos. --001a11c12662c149cf04f1993c0d--