#25908 [Opn]: Inherited class properties aren't inherited until after class is parsed [?]

From: Date: Sun, 19 Oct 2003 08:03:38 +0000
Subject: #25908 [Opn]: Inherited class properties aren't inherited until after class is parsed [?]
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-49188@lists.php.net to get a copy of this message
ID: 25908 User updated by: kyle at putnamcabinets dot com -Summary: Class properties are added automatically (at compile time?) Reported By: kyle at putnamcabinets dot com Status: Open Bug Type: Class/Object related Operating System: Debian GNU/Linux (Sid) PHP Version: 5.0.0b1 (beta1) New Comment: This also causes some undesired behavior (aside from being strange): kputnam@linus:~$ php5 -n -r ' > class thing > { > protected $ribbit = 'ZOINKS'; > } > > class frog extends thing > { > function croak() > { > echo $this->ribbit; > } > } > > $f = new frog; > print_r($f);' frog Object ( [ribbit] => [ribbit:protected] => ZOINKS ) Previous Comments: ------------------------------------------------------------------------ [2003-10-19 03:45:27] kyle at putnamcabinets dot com Description: ------------ Not sure if this is a bug, but certainly strange behavior. When class properties are mentioned in a function they are created even if the function is not called Reproduce code: --------------- php5 -n -r 'class frog { function croak() { echo $this->ribbit; } } $f = new frog; print_r($f);' Expected result: ---------------- frog Object ( ) Actual result: -------------- frog Object ( [ribbit] => ) ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=25908&edit=1

« previous php.bugs (#49188) next »