- Improve MetaCommand to allow to ignore some abstract names

- Auto-correct `Method` FQN type name if missing first \
- Implement unit-tests
This commit is contained in:
Thach Nguyen
2018-01-31 19:53:24 +07:00
parent 647b8ff0d1
commit 1080504a78
9 changed files with 207 additions and 9 deletions
+10 -2
View File
@@ -24,7 +24,6 @@ class Method
/** @var \ReflectionMethod */
protected $method;
protected $output = '';
protected $name;
protected $namespace;
protected $params = array();
@@ -230,7 +229,16 @@ class Method
*/
protected static function convertKeywords($string)
{
return preg_replace(array('/(^|\|)Closure(\||$)/', '/(^|\|)dynamic(\||$)/'), array('$1\Closure$2', '$1mixed$2'), $string);
$types = explode('|', $string);
foreach ($types as &$type) {
if ($type === 'Closure')
$type = '\Closure';
elseif ($type === 'dynamic')
$type = 'mixed';
elseif (strrpos($type, '\\') && $type[0] !== '\\' && (class_exists($type) || interface_exists($type)))
$type = '\\' . $type;
}
return implode('|', $types);
}
/**