Created
December 26, 2014 10:42
-
-
Save jubianchi/f310c273e9b0ca7de378 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function foo(\stdClass $a, \stdClass ... $bs) | |
{ | |
// gestion des arguments sur ma branche (dans le cas des variadics) | |
var_dump(func_get_args()); | |
// gestion des arguments actuelle | |
var_dump(array_merge(array($a, $bs), array_slice(func_get_args(), 2))); | |
} | |
foo(new \stdClass, new \stdClass, new \stdClass, new \stdClass); | |
/* | |
//résultat: | |
// gestion des arguments sur ma branche (dans le cas des variadics) | |
array(4) { | |
[0]=> | |
object(stdClass)#1 (0) { | |
} | |
[1]=> | |
object(stdClass)#2 (0) { | |
} | |
[2]=> | |
object(stdClass)#3 (0) { | |
} | |
[3]=> | |
object(stdClass)#4 (0) { | |
} | |
} | |
// gestion des arguments actuelle | |
array(4) { | |
[0]=> | |
object(stdClass)#1 (0) { | |
} | |
[1]=> | |
array(3) { | |
[0]=> | |
object(stdClass)#2 (0) { | |
} | |
[1]=> | |
object(stdClass)#3 (0) { | |
} | |
[2]=> | |
object(stdClass)#4 (0) { | |
} | |
} | |
[2]=> | |
object(stdClass)#3 (0) { | |
} | |
[3]=> | |
object(stdClass)#4 (0) { | |
} | |
} | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment