Re: Declare minimum PHP version required?

From: Date: Tue, 04 Feb 2014 21:04:14 +0000
Subject: Re: Declare minimum PHP version required?
References: 1 2 3 4 5  Groups: php.internals 
Request: Send a blank email to internals+get-72211@lists.php.net to get a copy of this message
On Tue, Feb 4, 2014 at 9:24 PM, Rowan Collins <rowan.collins@gmail.com>wrote: > On 04/02/2014 09:08, Yasuo Ohgaki wrote: > >> Similar thing could be achieved with new assert() w/o any overheads. >> >> https://wiki.php.net/rfc/expectations >> >> assert('version_compare(PHP_VERSION, "5.5.0", ">=")', >> 'You need PHP 5.5.0 >> or later'); >> > > I'm confused, isn't this exactly how assert() already works? What needs to > change, for this example in particular? > > Here it is running on several versions, giving a Warning by default: > http://3v4l.org/TrBJm > And here it is without the second parameter, which in itself requires PHP > 5.3: http://3v4l.org/mcQI6 > > It's slightly confusing that assertions issue a Warning even with > ASSERT_BAIL turned on, but with that turned on (which can be at the ini > level) you can see that it aborts the script as desired: > http://3v4l.org/QZLog > > Regards, > > -- > Rowan Collins > [IMSoP] > > > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > with the current assert implementation the assert is a function, which eval()-s the expression argument, but it will return early if asserts are disabled(http://lxr.php.net/xref/PHP_5_5/ext/standard/assert.c#149) with the proposed assert (https://wiki.php.net/rfc/expectations) the assert will be changed into a language construct, which has the advantage that we can use expressions instead of passing a string for evaluation without additional cost, also executing that is cheaper than a function call, and when the assertions are disabled they will be almost zero-cost. -- Ferenc Kovács @Tyr43l - http://tyrael.hu

« previous php.internals (#72211) next »