pbyrne84 / DynamicReturnTypePlugin

135 stars 7 forks source link

Inherited methods that are not overriden #44

Open chasepeeler opened 9 years ago

chasepeeler commented 9 years ago

Given the following:

<?php
namespace My;
class foo {

   public function get($name){
   }

}

class bar extends foo {
}

and

{
   "class":"\\My\\bar",
   "method":"get",
   "position":0,
  "fileReturnTypeReplacementCall": ["myfile.js","mymethod"]
}

The following will not get processed by 'mymethod'

<?php
$b = new \My\bar;
$x = $b->get("abc");

However, if you override the method in bar, even if it doesn't do anything except call its parent, then it works as intended.

pbyrne84 commented 9 years ago

Lost in my email, I'll have a look tonight.

pbyrne84 commented 9 years ago

Can I have the js file? Cheers

pbyrne84 commented 8 years ago

The inheritance/method thing was fubar. Fixed that a while ago so should work.

chasepeeler commented 6 years ago

It looks like this is happening again. Pointing to a non-overriden method in a subclass wasn't triggering my function, but, pointing to the method in the base class was.

<?php
class BaseClass {
   public function myMethod($foo){}
   public function myOtherMethod($bar){}
}

class Subclass {
   public function myOtherMethod($foo){}
}
{
  "methodCalls": [
     {
        "class": "BaseClass",
        "method":"myMethod",
        "position":0,
        "fileReturnTypeReplacementCall": [
            "ReturnTypes.js",
            "returnTypeMethod1"
         ]
     },
     {
        "class": "SubClass",
        "method":"myOtherMethod",
        "position":0,
        "fileReturnTypeReplacementCall": [
            "ReturnTypes.js",
            "returnTypeMethod2"
         ]
     }
  ]
}

In the above, everything works. But, if in the first one, you changed the class to "SubClass," it would stop working. The second one would continue to work, though.