vendredi 27 février 2015

Can I tell ReflectionClass constructor to be case sensitive?

I have encountered a very interesting problem. I have two classes: APISession and ApiSession. I have an API class as well, which has a method, like this:



public static function request($category, $name, $params) {
$params["Response"] = new APIResponse();
$class = new ReflectionClass("API".$category);
return $class->getMethod($name)->invoke(null, $params);
}


I am calling the method:



$result = API::request("Session", "Check", array());


Naturally, I expect this to execute the Check method of the APISession class, however, I receive the following problem:



Fatal error: Uncaught exception 'PHPErrorException' with message 'Exception 'ReflectionException' with message 'Method Check does not exist'



I have checked the source of the problem and it is caused by the fact that the request is reaching ApiSession instead of APISession, despite the fact that the string passed to it is "APISession". My question is: is it possible to tell the ReflectionClass constructor to be case-sensitive?






Aucun commentaire:

Enregistrer un commentaire