php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #25908 Inherited class properties aren't inherited until after class is parsed [?]
Submitted: 2003-10-19 03:45 UTC Modified: 2003-10-19 08:12 UTC
From: kyle at putnamcabinets dot com Assigned:
Status: Not a bug Package: Class/Object related
PHP Version: 5* OS: *
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
6 + 28 = ?
Subscribe to this entry?

 
 [2003-10-19 03:45 UTC] 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] =>
)


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-10-19 04:03 UTC] kyle at putnamcabinets dot com
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
)
 [2003-10-19 04:58 UTC] helly@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

Duplicate of #25815, 25199
 [2003-10-19 08:12 UTC] helly@php.net
Also update your php source. The visibility problem you described in your second comment is fixed already.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 18 12:01:28 2024 UTC