note 117609 added to reflectionfunctionabstract.getnumberofrequiredparameters
| From: | cesar at magic3w dot com | Date: | Tue, 07 Jul 2015 12:45:23 +0000 |
| Subject: | note 117609 added to reflectionfunctionabstract.getnumberofrequiredparameters | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-203057@lists.php.net to get a copy of this message | ||
It's interesting to note that this function will treat optional parameters that come before a
required parameter as required too. This is good since it allows you to verify that the function
will be receiving enough parameters for the it to work, regardless where they are located.
<?php
class MyTest() {
public function test($a = null, $b) {}
public function test2($a = null, $b, $c = null) {}
}
//Create the reflection
$r = new \ReflectionMethod('MyTest', 'test');
$r2 = new \ReflectionMethod('MyTest', 'test2');
//Verify the numbers
echo 'Test: ' . $r->getNumberOfRequiredParameters()); //Output: 2
echo 'Test2: ' . $r->getNumberOfRequiredParameters()); //Output: 2
?>
----
Server IP: 72.52.91.14
Probable Submitter: 188.193.149.239
----
Manual Page -- http://php.net/manual/en/reflectionfunctionabstract.getnumberofrequiredparameters.php
Edit -- https://master.php.net/note/edit/117609
Del: integrated -- https://master.php.net/note/delete/117609/integrated
Del: useless -- https://master.php.net/note/delete/117609/useless
Del: bad code -- https://master.php.net/note/delete/117609/bad+code
Del: spam -- https://master.php.net/note/delete/117609/spam
Del: non-english -- https://master.php.net/note/delete/117609/non-english
Del: in docs -- https://master.php.net/note/delete/117609/in+docs
Del: other reasons-- https://master.php.net/note/delete/117609
Reject -- https://master.php.net/note/reject/117609
Search -- https://master.php.net/manage/user-notes.php