zaphpa / zaphpa

Zaphpa is a super-lightweight, robust and easy library for quickly developing RESTful HTTP APIs in PHP. Inspired by Sinatra.rb and Express.js/Node.js it is probably the easiest and most powerful web micro-framework for RESTful APIs in PHP.

Home Page:http://zaphpa.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Zaphpa_Callback_Util::getCallback doesn't support inheritance

jeffpritchard opened this issue · comments

commented

If the method you want to route to is an inherited method, the getCallback method will change the class from what you specified to the parent. This is caused by using ReflectionMethod to get the class name and method name after using it to see if the method is static or not. $method->class will return the class the method appears in, not the class you want to call it in.

Example:

class a {
 function foo() {
  $this->bar();
 }
}

class b inherits a {
 function bar() {
  print 'routed!';
 }
}

If I use Zaphpa to route to Array('b', 'foo'), getCallback with instantiate 'a' instead, and the code will fail.

Submitted pull request ( #16 ) with fix.