Uninitialized ++$foo->bar; does not cause a notice (but ++$bar; does!)
| Bug #49348 | Uninitialized ++$foo->bar; does not cause a notice (but ++$bar; does!) | |||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Submitted: | 2009-08-24 16:21 UTC | Modified: | 2013-02-20 08:35 UTC |
|
||||||||||
| From: | BelStudent at yandex dot ru | Assigned: | stas (profile) | |||||||||||
| Status: | Closed | Package: | Scripting Engine problem | |||||||||||
| PHP Version: | 5.*, 6 | OS: | * | |||||||||||
| Private report: | No | CVE-ID: | None | |||||||||||
[2009-08-24 16:21 UTC] BelStudent at yandex dot ru
Description:
------------
Usually, if you try to do this: ++$num, then thrown notice, that the "Undefined variable: num". This helps avoid errors.
But if you have class and you're trying to do so ++$this->num num nowhere and had not previously identified, then the issue no warnings and notices.
Accidentally deleted in the symbol and received ++$this->nu, and then climbed into hell knows what mistakes to find this place and correct to ++$this->num took several hours. So I am very concerned about the issue: how to do so were given notice, if you try to do something with uninitialized (unknown) variable in the class?
Reproduce code:
---------------
<?php
class A
{ public function __construct()
{ ++$this->num;
}
}
new A();
?>
Expected result:
----------------
Undefined property: A::$num
Actual result:
--------------
empty
Patches
Pull Requests
History
AllCommentsChangesGit/SVN commits
[2009-08-25 07:13 UTC] gwynne@php.net
[2009-08-25 08:18 UTC] jani@php.net
[2009-08-27 21:06 UTC] sjoerd@php.net
[2009-08-31 22:12 UTC] jani@php.net
[2013-02-19 04:59 UTC] stas@php.net
[2013-02-20 08:35 UTC] dmitry@php.net
[2013-02-21 08:58 UTC] stas@php.net
-Status: Assigned +Status: Closed
[2013-03-29 20:07 UTC] bugs dot php dot net at majkl578 dot cz