php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #72563 @unset() return error
Submitted: 2016-07-08 05:50 UTC Modified: 2016-07-13 01:39 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: security at nsa dot gov Assigned:
Status: Open Package: Scripting Engine problem
PHP Version: 7.0.8 OS: Windows
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: security at nsa dot gov
New email:
PHP Version: OS:

 

 [2016-07-08 05:50 UTC] 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

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-07-08 07:29 UTC] requinix@php.net
-Package: PHP Language Specification +Package: Scripting Engine problem
 [2016-07-08 07:29 UTC] 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 07:30 UTC] requinix@php.net
-Type: Bug +Type: Feature/Change Request
 [2016-07-13 01:39 UTC] kalle@php.net
@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);
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Oct 16 08:01:27 2024 UTC