Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:72176 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 35027 invoked from network); 4 Feb 2014 06:34:06 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 4 Feb 2014 06:34:06 -0000 Authentication-Results: pb1.pair.com smtp.mail=larry@garfieldtech.com; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=larry@garfieldtech.com; sender-id=unknown Received-SPF: error (pb1.pair.com: domain garfieldtech.com from 66.111.4.28 cause and error) X-PHP-List-Original-Sender: larry@garfieldtech.com X-Host-Fingerprint: 66.111.4.28 out4-smtp.messagingengine.com Received: from [66.111.4.28] ([66.111.4.28:35865] helo=out4-smtp.messagingengine.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id C9/B4-09069-DD980F25 for ; Tue, 04 Feb 2014 01:34:06 -0500 Received: from compute2.internal (compute2.nyi.mail.srv.osa [10.202.2.42]) by gateway1.nyi.mail.srv.osa (Postfix) with ESMTP id F3AA820AE4 for ; Tue, 4 Feb 2014 01:34:02 -0500 (EST) Received: from frontend1 ([10.202.2.160]) by compute2.internal (MEProxy); Tue, 04 Feb 2014 01:34:02 -0500 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=message-id:date:from:mime-version:to :subject:references:in-reply-to:content-type :content-transfer-encoding; s=smtpout; bh=GLjWVDBbT7PlFYqPMrfpJd D2FH8=; b=qmoQp0Qxao1P1+o1BnK3IPQNkrR66UmlrDAXVULDx+Hq0y6awKw39t QatoNItOCIZdy9zEk8mUxYutl2a0j46cDWTKVMbWJfQVx/irL78XN5YzH6ZzTJRP hphIUgsh4WgGH9RwADPko7TY8JZoteDpXSYIqJuiDMfo/YvDGws2o= X-Sasl-enc: rqi74kkOr0iHM2Eo9bn670B4IveUeAfVeumUxyp+S9m6 1391495642 Received: from [192.168.42.21] (unknown [98.206.137.135]) by mail.messagingengine.com (Postfix) with ESMTPA id 56A0FC0000C for ; Tue, 4 Feb 2014 01:34:02 -0500 (EST) Message-ID: <52F089DB.7000107@garfieldtech.com> Date: Tue, 04 Feb 2014 00:34:03 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 MIME-Version: 1.0 To: internals@lists.php.net References: <52EF4BF8.60005@sugarcrm.com> <52EF7ADA.8090001@lsces.co.uk> <52EFF13F.4050704@sugarcrm.com> <52F0359E.1060707@garfieldtech.com> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Declare minimum PHP version required? From: larry@garfieldtech.com (Larry Garfield) On 02/03/2014 09:51 PM, Yasuo Ohgaki wrote: > >> I have to agree with Stas and Sara on this one. This is not the job of >> the language syntax. This is the package manager's job; once the code is >> installed (not compiled, installed), you shouldn't be changing your version >> anyway without knowing what you're doing / verifying on a test system >> anyway. >> >> If this were more like Javascript's "use strict", where it affected the >> parsing rules of that file, that would at least be useful (if potentially >> mind-bendingly painful for the engine; no I'm not suggesting we do that). >> But a shortcut for if (version_compare()) die; is not needed, and that >> would be a dumb way to go about implementing version requirements in the >> first place. > > This assumption is not valid as I already wrote. > There will be SCL in RHEL7 and there are tools like phpenv. > Installing PHP does not have to be executing PHP. I don't know what SCL is, nor what phpenv is. Thus "installing PHP does not have to be executing PHP" makes little sense to me as a sentence. > Version and module requirement checks are popular and I > don't think it is dumb at all. It is dumb that if script didn't > work as it should be due to version mismatch, isn't it? Well usually it will fatal anyway if it's written for a too-new version. I know software has version checks in it; Drupal (the project I work on primarily) has had a version check in it for years... but in the installer, not in arbitrary non-installer files. > BTW, it is not a short cut of version check, but "elimination of > run time check overheads". Many people don't understand > what declare() is, it seems. > > declare() is compiler directive, *NOT* a function. Thus it could > instruct what compiler should do at compile time. Since declare() > is compiler directive, compiler may omit byte code for declare > block. Therefore, run time overheads of declare block may be > eliminated with byte code cache. I can think of exactly one use case for compiling or not compiling a given file depending on the version, and that's for function backports (like the old PHP_Compat library, or the backport of the password hash functions from PHP 5.5.) Those are trivial enough to just wrap the require statement in a version_compare(). Or, really, the opcode overhead of that compared to the size of a typical code base these days is probably negligible. > Isn't checking requirements over and over a waste of resources? Yes. So don't do it. :-) Really, I have no clue what the use case is here. --Larry Garfield