Snookered by abstract - PHP -


I have an abstract class that I'm receiving from inheriting:

  abstract Class test {Public Function GetTests () {}}   

And I am convinced that I am using intangible class implementation for most of the time:

 < Code> class concrete extension test {// no problem}   

I had to apply a different version of GetTests method recently, and in fact I I wanted to write because it is made in all of my routing:

  class concrete test {public function GetTests ($ newArgument) {// notice $ newArgument}}   

However, I get this error message: : Convergent :: Hosting (declared) Announcement :: Test :: GetTests ()

should be compatible with By completely copying the work from abstract class for this concrete, even if I needed to implement this method differently Yes ... Is there any way to be around this?

I understand that I may have:

  abstract class tests {abstract public function GetTests (); }   

But this is the reason that I am snooker, because I do not have the ability to modify how the underlying test class has been implemented ... DOH! ... until I really should not have. .


Thank you for all the great answers ...

I have decided to snook myself (this is hurt, but this is happening) Is going to be worth it) and I will instantiate the test class inside the concrete square, apply all the test class concrete versions of the system, and then call them immediately the test class ... this means in the future (or in fact Now) I can not just call that facility ...

For reference:

  / * no longer abstract * / square UnitOfWorkController {Public Function GetUnits () {// Implementation Return View:: Creating (. ..); }}   

and ...

  class SomethingController / * now does not extend the UnitOfWorkController * / {Private $ unitOfWorkController; Public Function __Construct () {$ this-> unitOfWorkController = New UnitOfWorkController (); } Public Function GetUnits () {Return $ this- & gt; unitOfWorkController-> GetUnits (); // I can only apply my junk}}    

Your solid subclass Violation, which tells to reduce a long story, if an object of class X can be processed through a particular code, then be able to process every possible sub-class of X by the same piece of code needed.

Say that I wanted to make another subclass of the test and wanted to implement my own gate-test method. The base class method does not accept any argument, so it suggests that if my subclass is to be replaceable for its superclass, then my implementation of that method can not take any argument. If I give my implementation logic, then it will not be in accordance with the specification specified by the Superclass.

If I have code that:

  $ object = new test; $ Test - & gt; GetTests ();   

Then I can not change the option of my subclass without changing the calling code to pass in an argument. Similarly if I change it, then I have another test Test that does not require logic for gate-test, then the code has to be changed again. In fact, the same code can not be used only with those classes, which use to jump from some hoops to determine the actual class and use the appropriate calling convention, which means that the class It is important to know things about which I am about to use it. I do not have to know.

Php is about the sub-class method that matches their superclass. Qatar is less strict than Oo languages, but it will issue a warning if they do not match. The only way to correct the warning is that all subclasses have the same method signature, as they get from the Superclass.

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -