Skip to content

Instantly share code, notes, and snippets.

@kobus1998
Created August 13, 2018 08:50
Show Gist options
  • Save kobus1998/fa8a74a526007897bce88652be47e2af to your computer and use it in GitHub Desktop.
Save kobus1998/fa8a74a526007897bce88652be47e2af to your computer and use it in GitHub Desktop.
PHP Reflection get type hint
<?php
class X {
public function get(array $arr) {
return $arr;
}
}
$reflect = new ReflectionMethod('X', 'get');
// first param for sake of example
$param = @reset($reflect->getParameters());
print_r($param->getType()->getName());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment