ID:               22489
 User updated by:  marcot at tabini dot ca
 Reported By:      marcot at tabini dot ca
 Status:           Bogus
 Bug Type:         Zend Engine 2 problem
 Operating System: Shouldn't matter
 PHP Version:      5CVS-2003-03-01 (dev)
 New Comment:

Thanks for taking the time to review the bug. You're certainly
right--my b class doesn't have a constructor, and therefore the engine
defaults to a:__construct().

Unfortunately, I still don't think that it's behaving correctly.
a:__construct() should reside in the context of a, and therefore it
should access a::$c, not create a new dynamic property b::$c. If this
is the way the engine works, then a parent class has access to its
subclasses contexts, which I don't think is right.


Previous Comments:
------------------------------------------------------------------------

[2003-03-02 08:26:28] [EMAIL PROTECTED]

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

Your class b doesn't have a constructor (only one underscore). Therefor
a::__construct is used as a constructor and that is why b->test() shows
a value.

The leak is already fixed and the rest is no bug.

------------------------------------------------------------------------

[2003-03-01 10:50:56] marcot at tabini dot ca

Okay, but even so I'm not assigning it the value `a::c'. So, even if
I'm creating a new property that hides the previous one, it should not
have any contents, no?

------------------------------------------------------------------------

[2003-03-01 10:46:23] [EMAIL PROTECTED]

NO! & YES there is an error.

No: You are declaring a *new* dynamic property c in b
which hides c from a.

YES: there is a memory leak:
/usr/src/php4-HEAD/Zend/zend_language_scanner.l(1084) :  Freeing
0x40998D38 (7 bytes),
script=/usr/src/php4-HEAD/tests/classes/private_members.php

I'll have a look into it

------------------------------------------------------------------------

[2003-03-01 10:36:25] marcot at tabini dot ca

Configure:

./configure \
--with-apxs=/usr/local/apache/bin/apxs

For example:

<?

class a
{
  private $c;

  function __construct()
  {
    $this->c = "a::c";
  }
}

class b
  extends a
{
  private $d;

  function _construct()
  {
    $this->d = 'b::d';
  }

  function test()
  {
    echo $this->c;
  }
}

$b = new b;

//echo $b->d;
$b->test();

?>

If executed, The first echo statement returns an error, as expected.
The $b->test() call, however, returns `a::c', which I think is
incorrect, as it should either not return anything or produce an error,
since a::$c is declared as private and should not be available to the b
namespace.


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=22489&edit=1

Reply via email to