Skip to content

Instantly share code, notes, and snippets.

@jubianchi
Created December 26, 2014 10:42
Show Gist options
  • Save jubianchi/f310c273e9b0ca7de378 to your computer and use it in GitHub Desktop.
Save jubianchi/f310c273e9b0ca7de378 to your computer and use it in GitHub Desktop.
<?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