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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: kyle at putnamcabinets dot com
New email:
PHP Version: OS:

 

 [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

Pull Requests

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: Sat Dec 21 16:01:28 2024 UTC