php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #49772 Cast operators marked as non-associative
Submitted: 2009-10-04 23:00 UTC Modified: 2009-11-13 21:40 UTC
From: mjomble at gmail dot com Assigned:
Status: Closed Package: Documentation problem
PHP Version: Irrelevant OS: Windows
Private report: No CVE-ID: None
 [2009-10-04 23:00 UTC] mjomble at gmail dot com
Description:
------------
The operator precedence page (language.operators.precedence.php) lists the following operators as non-associative:

~ - (int) (float) (string) (array) (object) (bool) @

However, all of these seem to behave like right-associative operators.

Examples:
- - 3 evaluates like -(-3)) = 3
~ ~ 3 evaluates like ~(~3)) = 3
- - - 3 evaluates like -(-(-3))) = -3
~ ~ ~ 3 evaluates like ~(~(~3))) = ~3 = -4
(int) (string) 3 evaluates to integer 3
(string) (int) 3 evaluates to string "3"

It's even possible to use the @ operator more than once in front of a statement. The additional ones don't really do anything useful, but more importantly, they don't trigger any parse errors.


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-11-13 21:40 UTC] svn@php.net
Automatic comment from SVN on behalf of vrana
Revision: http://svn.php.net/viewvc/?view=revision&revision=290705
Log: Some unary operators are associative (bug #49772)
 [2009-11-13 21:40 UTC] vrana@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.


 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Mon Jun 15 22:00:02 2026 UTC