php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #26182 Object properties created redundantly
Submitted: 2003-11-08 19:47 UTC Modified: 2003-12-16 03:01 UTC
From: hongnk at hotmail dot com Assigned: andi (profile)
Status: Closed Package: Scripting Engine problem
PHP Version: 5CVS OS: *
Private report: No CVE-ID: None
 [2003-11-08 19:47 UTC] hongnk at hotmail dot com
Description:
------------
Whenever a variable is refered anywhere inside a class under the form $this->varname, it is automatically created in class instances.



Reproduce code:
---------------
class A {
	function NotAConstructor(){
		if(isset($this->x)){
			//just for demo
		}
	}
}

$t=new A();
var_dump($t);

Expected result:
----------------
object(a)#1 (0) { }


Actual result:
--------------
object(a)#1 (1) { ["x"]=> NULL }


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-11-25 04:20 UTC] sniper@php.net
Works as expected with PHP 4, fails with PHP 5.

 [2003-11-27 12:05 UTC] helly@php.net
PHP5 knows the concepts of implicit public properties and dynamic properties.

Implicit public properties are properties that are declared by simply using them.

Dynamic properties are properties that can be 'attached' to an object while using it.
 [2003-11-27 12:06 UTC] helly@php.net
Reopen as feature request:

Shouldn't creation of implicit public properties be an E_STRICE error?
 [2003-12-01 07:10 UTC] sniper@php.net
This is a bug, not feature request.
Andi: Assigned to you as reminder.. :)


 [2003-12-16 03:01 UTC] sniper@php.net
This bug has been fixed in CVS.

In case this was a PHP problem, 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/.
 
In case this was a documentation problem, the fix will show up soon at
http://www.php.net/manual/.

In case this was a PHP.net website problem, the change will show
up on the PHP.net site and on the mirror sites in short time.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 11:01:30 2024 UTC