$reflectionMethod = new ReflectionMethod('count'); echo $reflectionMethod->getNumberOfRequiredParameters(); // Output: 1
class MyClass { public function myMethod($param1, $param2) { // code here } } $reflectionMethod = new ReflectionMethod('MyClass', 'myMethod'); echo $reflectionMethod->getNumberOfRequiredParameters(); // Output: 2This code can be found in the PHP Standard Library package.