ID:               41090
 User updated by:  ozone at cname dot com
 Reported By:      ozone at cname dot com
-Status:           Bogus
+Status:           Open
-Bug Type:         Class/Object related
+Bug Type:         Documentation problem
 Operating System: linux
 PHP Version:      5.2.1
 New Comment:

This still needs better documentation; the (silent) inability to
override a private method in a derivative class is somewhat
counterintuitive. Put another way, I had to burn time writing test cases
after a careful study of the documentation didn't mention the behavior I
saw. IMNSHO, a production-quality language doesn't require careful
"figuring out" of its behaviors, and if I'm repeatedly told that the
issues I experience are "not a bug" , I'll stop wasting the time to file
bug reports.


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

[2007-04-15 09:04:18] [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

Calling scope matters

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

[2007-04-15 01:12:20] ozone at cname dot com

Description:
------------
The page on Visibility states: "Private limits visibility only to the
class that defines the item." Apparently, private methods may not be
superseded by a child of that class; in the following code, a new object
e inherits the __constructor() which calls "$this->df", but because f()
is declared private, it is silently not overridden. This behavior may
not constitute a "bug" in the context of PHP inheritance, but it
deserves a warning message and/or some mention in the documentation.

Note that if f() is declared protected (or public) in both classes,
inheritance works as expected; if the two f()s are declared with
differing protection, an error message results, which is somewhat ironic
considering the above-described silent failure mode.


Reproduce code:
---------------
class d {
 function __construct() {
  $this->f();
 }
 private function f() {
  echo "d->f()\n";
 }
}
class e extends d {
 private function f() {
  echo "e->f()\n";
 }
}
$t = new e();


Expected result:
----------------
e->f()

(Because $this refers to an instance of e when it is executed.)

Actual result:
--------------
d->f()




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


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

Reply via email to