Req #69269 [NEW]: Allow assert to execute a closure
| From: | tom at r dot je | Date: | Fri, 20 Mar 2015 12:18:14 +0000 |
| Subject: | Req #69269 [NEW]: Allow assert to execute a closure | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-191481@lists.php.net to get a copy of this message | ||
From: tom at r dot je
Operating system: any
PHP version: 5.6.6
Package: *General Issues
Bug Type: Feature/Change Request
Bug description:Allow assert to execute a closure
Description:
------------
Currently the manual helpfully states on
http://php.net/manual/en/function.assert.php
that " The advantages of a
string assertion are less overhead when assertion checking is off"
Which makes perfect sense. The disadvantages, of course, are that
readability is reduced and IDE hints/highlighting won't work and the
parser won't immediately catch parse errors in the string.
As a happy medium I propose it would be better if assert() could take a
closure as it's first argument:
assert(function() {
return 2 < 1;
});
This has the best of both worlds as the code wouldn't be executed unless
assertions are turned on.
--
Edit bug report at https://bugs.php.net/bug.php?id=69269&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=69269&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=69269&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=69269&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=69269&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=69269&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=69269&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=69269&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=69269&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=69269&r=support
Expected behavior: https://bugs.php.net/fix.php?id=69269&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=69269&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=69269&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=69269&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=69269&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=69269&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=69269&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=69269&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=69269&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=69269&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=69269&r=mysqlcfg