php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #59779 Support for unary minus
Submitted: 2011-05-22 08:31 UTC Modified: 2017-10-24 23:02 UTC
Votes:1
Avg. Score:1.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: vrana@php.net Assigned:
Status: Suspended Package: operator (PECL)
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: vrana@php.net
New email:
PHP Version: OS:

 

 [2011-05-22 08:31 UTC] vrana@php.net
Description:
------------
Negative values are not supported.

Reproduce code:
---------------
$x = -new foo(5);


Expected result:
----------------
Call of __minus() or similar method.

Actual result:
--------------
No method is called.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-07-18 02:51 UTC] pollita@php.net
So... hrmmm... this is doable, sort of.

The parser translates `- expr` into `0 - expr`, so I could watch for the binary 
subtraction op where the lhs is int(0), but that feels like it'll lead to a weird 
inconsistency where actual `0 - expr` yields a call to __minus(), but `1 - expr` 
doesn't have any overloaded meaning.

I'm going to put my implementation of this on the shelf for now and give it some 
thought...
 [2017-04-01 21:02 UTC] tpunt@php.net
-Package: operator +Package: *General Issues
 [2017-04-01 21:03 UTC] tpunt@php.net
-Package: *General Issues +Package: operator
 [2017-04-01 21:03 UTC] tpunt@php.net
I got confused...
 [2017-10-24 23:02 UTC] kalle@php.net
-Status: Open +Status: Suspended
 [2017-10-24 23:02 UTC] kalle@php.net
The operator PECL package have not had a release for 4 years and development activity seems to have ceased, if a new maintainer picks up this package, then this report should be re-opened
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Fri Nov 27 23:01:24 2020 UTC