Skip to content

Instantly share code, notes, and snippets.

@thekid
Created March 17, 2014 18:59
Show Gist options
  • Select an option

  • Save thekid/9605952 to your computer and use it in GitHub Desktop.

Select an option

Save thekid/9605952 to your computer and use it in GitHub Desktop.
<?php
function with_array(array $a) { }
function with_callable(callable $c) { }
function with_class(Exception $e) { }
function with_primitive($p) { }
if (strstr($argv[1], '::')) {
$param= new ReflectionParameter(explode('::', $argv[1]), 0);
} else {
$param= new ReflectionParameter($argv[1], 0);
}
if ($param->isArray()) {
echo "Array\n";
} else if ($param->isCallable()) {
echo "Callable\n";
} else if (null !== ($class= $param->getClass())) {
echo "Class ", $class->getName(), "\n";
} else {
echo "Primitive\n";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment