Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:72045 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 91303 invoked from network); 3 Feb 2014 07:08:15 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 3 Feb 2014 07:08:15 -0000 Authentication-Results: pb1.pair.com header.from=yohgaki@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=yohgaki@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.217.179 as permitted sender) X-PHP-List-Original-Sender: yohgaki@gmail.com X-Host-Fingerprint: 209.85.217.179 mail-lb0-f179.google.com Received: from [209.85.217.179] ([209.85.217.179:59347] helo=mail-lb0-f179.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 2B/F1-15628-E504FE25 for ; Mon, 03 Feb 2014 02:08:15 -0500 Received: by mail-lb0-f179.google.com with SMTP id l4so4931624lbv.24 for ; Sun, 02 Feb 2014 23:08:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:content-type; bh=7nCO4D/IrcwM9sLo66KZY8UmGd5z80Kc5qAYUIYHWSM=; b=snEEgNKtmcX42Shn+4jnvAYjN/LKHe57L+aGMDi79cmCwTnT1m7S7POTp3jms+hr5L mGFumEMS3XpzBUUodtxmvAHTEgLve8W3Qpew/7aVH3g9IMUXFlqsFnE1hMyUnmT4qD/R LiHv0Wuzq6Dhs8vrQiWS6Ov94pJ2xSLPmw9Mp6ZY/U0pHlmqWt1arFwF7qV/OvD8A5d0 BNC4u5MnjK0++Pm8AzaXIhNHz2fygc4jgm1u8q8ZnAtWf2Dn74+4CYgndscH6DQIH3IW CH/98HaBTSG9mdPAuSb70IxCFN/Mh14um1G/D4s7M/pbcUatTSUJvpWP3H5QaIi3DmnP iqUA== X-Received: by 10.152.236.72 with SMTP id us8mr24252029lac.11.1391411291885; Sun, 02 Feb 2014 23:08:11 -0800 (PST) MIME-Version: 1.0 Sender: yohgaki@gmail.com Received: by 10.112.199.37 with HTTP; Sun, 2 Feb 2014 23:07:31 -0800 (PST) In-Reply-To: References: Date: Mon, 3 Feb 2014 16:07:31 +0900 X-Google-Sender-Auth: y1adBmE1jKBeJ7VNQ4yfJC7_02w Message-ID: To: "internals@lists.php.net" Content-Type: multipart/alternative; boundary=001a1136c0baca16f304f17b2fed Subject: Re: Declare minimum PHP version required? From: yohgaki@ohgaki.net (Yasuo Ohgaki) --001a1136c0baca16f304f17b2fed Content-Type: text/plain; charset=UTF-8 Hi all, On Mon, Feb 3, 2014 at 3:58 PM, Yasuo Ohgaki wrote: > 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>='5.6.0'); > // or PHP_VERSION_ID? using = as minimum as it could be a little faster > // and no change in declare() syntax. > declare(php_version=50600); > > 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 not > 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=050600);" > 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? > It may be good to have Zend API to register required library versions for modules. For example, declare('libxxx_version'=1.0.0); If it does not much, failed at include. Regards, -- Yasuo Ohgaki yohgaki@ohgaki.net --001a1136c0baca16f304f17b2fed--