php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #34936 Base methods influenced by masking in derived classes
Submitted: 2005-10-20 19:36 UTC Modified: 2005-10-21 18:49 UTC
From: pa-engineer at web dot de Assigned:
Status: Not a bug Package: Class/Object related
PHP Version: 5.0.5 OS: WinXP
Private report: No CVE-ID: None
 [2005-10-20 19:36 UTC] pa-engineer at web dot de
Description:
------------
Dieser Effekt hat weitreichende Konsequenzen f?r die Funktionst?chtigkeit von Methoden die wiederum Methoden desselben Objektes aufrufen, die unter dem Einfluss der Ableitung modifiziert werden k?nnten.
Anstelle dessen: Basismethoden rufen auch Basismethoden auf, unber?hrt von einer Verdeckung durch eine abgeleitete Klasse.

This Effect has a wide range of consequences in functionality of base methods whitch call methods of the same object, perhaps influenced by using modifikation in derived classes.
Instead: base methods simply call base methods, untoughed by using a mask in derived classes.


Reproduce code:
---------------
class Class_A
{
   public function Do_Something()
   {
      $this->Class_A_Method();
   }
   public function Class_A_Method()
   {
      echo "Class_A";
   }
}

class Class_B extends Class_A
{
   public function Class_A_Method()
   {
      echo "Class_B";
   }
}
	
$Instance = new Class_B();
$Instance->Do_Something();

Expected result:
----------------
Die Ausgabe hier ist offensichtlich "Class_B".
Meine Erwartung, wie auch in anderen Sprachen: "Class_A".

The Output in this case here is obviously "Class_B"
My expectation, such as in other languages: "Class_A".



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-10-20 19:54 UTC] tony2001@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


 [2005-10-21 18:49 UTC] pa-engineer at web dot de
Hallo Tony

Danke f?r die schnelle Antwort. Sie denken die Ausgabe von ?Class_B? ist richtig ? nun, vielleicht ist es kein Fehler aus Sicht ihrer Dokumentation, aber sicherlich nicht im Sinne moderner objektorientierter Mechanismen. Zu meiner ?berraschung m?sste ich den selben Fehler in JAVA feststellen, aber moderne Sprachen wie C# best?tigen meine Meinung ? den richtigen Ansatz denke ich! Wie denken Sie dar?ber?
Stellen Sie sich vor, Sie wissen nicht, was innerhalb einer Basismethode Do_Something() vor sich geht. K?nnen sie eine stabile Operation sicherstellen, wenn diese dem Einfluss der Verdeckung unterliegen? Sehen sie sich das Beispiel noch mal an.


Hello Tony

Thanks for your quick respons. You think output ?Class_B? is right ? well, referring to your documentation it might not be a bug ? I don?t know ? but apart from that and in the sense of usually object oriented mechanisms it surely is. 
Astonishingly, JAVA tells me the same ?bug?, but modern object-oriented language like C# constans my opinion ? in my point of view the right way! What do you think?
Image you don?t know what happens inside a base method Do_Something(). Can you secure a solid operation influenced by masking its direction? Look at the example again and see what happens here.

Best regards Daniel
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 23 09:01:27 2024 UTC