Skip to content

Commit b1b4f4c

Browse files
committed
PhpNamespace: recognizes 'void' and 'iterable' as built-in types
1 parent a47a595 commit b1b4f4c

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/PhpGenerator/PhpNamespace.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ class PhpNamespace
2424
{
2525
use Nette\SmartObject;
2626

27+
private static $keywords = [
28+
'string' => 1, 'int' => 1, 'float' => 1, 'bool' => 1, 'array' => 1,
29+
'callable' => 1, 'iterable' => 1, 'void' => 1, 'self' => 1, 'parent' => 1,
30+
];
31+
2732
/** @var string */
2833
private $name;
2934

@@ -139,7 +144,7 @@ public function getUses()
139144
*/
140145
public function unresolveName($name)
141146
{
142-
if (in_array(strtolower($name), ['self', 'parent', 'array', 'callable', 'string', 'bool', 'float', 'int', ''], TRUE)) {
147+
if (isset(self::$keywords[strtolower($name)]) || $name === '') {
143148
return $name;
144149
}
145150
$name = ltrim($name, '\\');

0 commit comments

Comments
 (0)