php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #40248 Undefined members with combined operators produce no warning
Submitted: 2007-01-26 10:12 UTC Modified: 2013-03-01 18:00 UTC
From: jontsa at amigaone dot cc Assigned: reeze (profile)
Status: Closed Package: Scripting Engine problem
PHP Version: 5.2.0 OS: Solaris
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.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: jontsa at amigaone dot cc
New email:
PHP Version: OS:

 

 [2007-01-26 10:12 UTC] jontsa at amigaone dot cc
Description:
------------
When using a combined operator like += or ++ on an undefined class member, it does not produce "undefined property" notice as expected. Tested with all errors enabled.

Reproduce code:
---------------
$a+=5;
$b=new stdClass;
$b->a+=5;


Expected result:
----------------
Notice: Undefined variable: a
Notice: Undefined property: stdClass::$a

Actual result:
--------------
Notice: Undefined variable: a

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-04-08 21:37 UTC] jani@php.net
-Package: Feature/Change Request +Package: Scripting Engine problem
 [2012-03-20 21:00 UTC] php dot net at doppy dot nl
Can still reproduce this.

--------------------
PHP 5.3.10-1ubuntu2 with Suhosin-Patch (cli) (built: Mar  5 2012 18:27:21) 
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies
--------------------


Recommend using this reproduce code:
--------------------
<?php
error_reporting(-1);
$a+=5;

$b=new stdClass;
$b->a+=5;

$b=new stdClass;
$b->a=$b->a + 5;
--------------------

Expected result:
--------------------
PHP Notice:  Undefined variable: a in /test.php on line 3
PHP Notice:  Undefined property: stdClass::$a in /test.php on line 6
PHP Notice:  Undefined property: stdClass::$a in /test.php on line 9
--------------------

Actual result:
--------------------
PHP Notice:  Undefined variable: a in /test.php on line 3
PHP Notice:  Undefined property: stdClass::$a in /test.php on line 9
--------------------
 [2013-03-01 18:00 UTC] reeze@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: reeze
 [2013-03-01 18:00 UTC] reeze@php.net
The fix for this bug has been committed.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.

 For Windows:

http://windows.php.net/snapshots/
 
Thank you for the report, and for helping us make PHP better.

This was implemented in lastest version 5.5 master
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 26 21:01:29 2024 UTC