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

 ID:               48984
 Comment by:       themastersleader at hotmail dot com
 Reported by:      themastersleader at hotmail dot com
 Summary:          Strict errors when implementing an interface (with
                   private methods)
 Status:           Bogus
 Type:             Bug
 Package:          Class/Object related
 Operating System: Win XP
 PHP Version:      5.3.0

 New Comment:

Also the strange thing is, when you remove the empty interface from the
base class the script doesn't give an error.


Previous Comments:
------------------------------------------------------------------------
[2010-07-15 20:38:29] giorgio dot liscio at email dot it

ok i got it

i'm sorry... a private method cannot obviously public in subclasses
-__-



so you are saying that any class can have ---their own method with same
name with totally different signature---...



because private methods does not depends by parent ones



ok now i think that you are right



fields works right... here is the proof:



class A

{

     private $test;

     public function __construct(){$this->test = "THIS IS A";}

}



class B extends A

{

     private $test;

         public function printit(){echo isset($this->test) ?: '$this->test is
not set';}

}



$b = new B();

$b->printit();





as you can see every class has its own field with the same name



subclass-field does not inherits parent class's field

------------------------------------------------------------------------
[2010-07-15 20:09:47] itay dot malimovka at gmail dot com

"a private method is exactly like the others... explained by the fact
that a private method can be public in a subclass"

Nooooo



Here, try this:

class A{private function x(){}}

class B extends A{public function b(){x()}}



as you can see, class b DID NOT inherited function x, it can call it
from the parent class though, which is what you showed.



Any way, see discussion here:

http://stackoverflow.com/questions/3258523/is-this-a-php-bug-subclasses-must-declare-private-methods-with-the-same-signatur

------------------------------------------------------------------------
[2010-07-15 19:15:21] giorgio dot liscio at email dot it

a private method is exactly like the others... explained by the fact
that a private method can be public in a subclass



class A{private function x(){}}

class B extends A{public function x(){parent::x()}}

------------------------------------------------------------------------
[2010-07-15 15:16:40] itay dot malimovka at gmail dot com

@giorgio dot liscio at email dot it



This is **ONLY** true when the method is protected or public.

------------------------------------------------------------------------
[2010-07-15 11:20:50] themastersleader at hotmail dot com

Quote "extending a method means that in the sub-class the overrided
method can be used as can i use it in the parent class"



The problem is that the sub-class isn't extending the method this
because the method is defined as private.

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


The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

    http://bugs.php.net/bug.php?id=48984


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

Reply via email to