Req #72563 [Opn]: @unset() return error
| From: | kalle@php.net | Date: | Wed, 13 Jul 2016 01:39:12 +0000 |
| Subject: | Req #72563 [Opn]: @unset() return error | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-202261@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=72563&edit=1
ID: 72563
Updated by: kalle@php.net
Reported by: security at nsa dot gov
Summary: @unset() return error
Status: Open
Type: Feature/Change Request
Package: Scripting Engine problem
Operating System: Windows
PHP Version: 7.0.8
Block user comment: N
Private report: N
New Comment:
@requinix I agree that we should perhaps allow the silence operator to operate on language
constructs, or at least allow line 16 of your example (unset(@$...)), since we already allow to
silence individual variables or calls like:
call_something(@$hopefully_callable);
Previous Comments:
------------------------------------------------------------------------
[2016-07-08 07:29:45] requinix@php.net
@ is only allowed with expressions and unset is considered a statement, like control structures and
return.
It is possible for unset(expr) to raise an error <https://3v4l.org/idvWY>, and it looks like @ is implemented as
a begin/execute/end sequence rather than a "silence the next expression" operation, so
maybe @ could be promoted to support statements too? Code like
@foreach ($array as $var) {
looks a bit odd, but I can't think of any reason why it should specifically not be supported.
(Putting aside the general "don't use the error suppression operator" advice, that
is.)
------------------------------------------------------------------------
[2016-07-08 05:50:17] security at nsa dot gov
Description:
------------
If I use @ to supress error, PHP failed to parse @unset.
Test script:
---------------
<?php
$a='aaa';
@unset($a);
?>
Expected result:
----------------
No error
Actual result:
--------------
Erros parsing
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=72563&edit=1