![]() |
ReflectionClass problem
Heya, as mentioned before on this forum these type of stuff barely got any documentation so I kinda need your help.
I got like this: PHP Code:
As you probably figured out, this is used in a MVC enviroment. The problems are several. 1. If I access in the URL index.php/controller/method/arg1/arg2/ it will successfully access the method in the corresponding controller even if the method does not have any arguments at all. As an example, let's say I have this function inside the controller WelcomeController: PHP Code:
2. If I instead have a method with 2 arguments, like this: PHP Code:
Code:
Warning: Missing argument 2 for WelcomeController::index() in /Users/Tanax/Desktop/Websites/TanaxiaFramework5/modules/welcome/controllers/welcome.php on line 6The funny thing here is also that it actually outputs part of the method, except for the variable arg2 which is replaced by blank. So basically, how can I check if a method exists with the amount of arguments that I specify? I know I can check if a method exists via ReflectionClass->hasMethod('name') but that only checks if the method name exists and not any possibilities to add in arguments in the equasion. Any ideas? |
You can use the
getNumberOfParameters or getNumberOfRequiredParameters method on the return value of getMethod. |
Thanks a lot! This helped me greatly.
It was the return value of getMethod and not hasMethod that had the methods getNumberOfParameters and getNumberOfRequiredParameters by the way. |
Sorry, honest typing mistake. :)
|
Realized that :=)
|
| All times are GMT. The time now is 07:16 AM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0