Skip to content
This repository was archived by the owner on Sep 8, 2023. It is now read-only.

Commit 9c85fab

Browse files
authored
Merge pull request #22 from mortenscheel/fix-namespacing-return-types
Don't move zend types to the global namespace
2 parents 054bbd6 + 49bfbbc commit 9c85fab

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

src/Console/MacrosCommand.php

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,9 @@ protected function generateFunction($name, $parameters, $type = '', $returnType
180180
} else {
181181
$paramType = $parameter->getType();
182182
if ($paramType instanceof \ReflectionNamedType) {
183+
if ($paramType->allowsNull()) {
184+
$this->write("?");
185+
}
183186
$this->write($paramType->getName() . " ");
184187
}
185188
}
@@ -196,10 +199,21 @@ protected function generateFunction($name, $parameters, $type = '', $returnType
196199
$this->write(")");
197200
if (version_compare(PHP_VERSION, '7.1', '<')) {
198201
if ($returnType) {
199-
$this->write(": \\$returnType");
202+
if (class_exists($returnType)) {
203+
$this->write(": \\$returnType");
204+
} else {
205+
$this->write(": $returnType");
206+
}
200207
}
201208
} elseif ($returnType instanceof \ReflectionNamedType) {
202-
$this->write(": \\" . $returnType->getName());
209+
$this->write(": ");
210+
if ($returnType->allowsNull()) {
211+
$this->write("?");
212+
}
213+
if (class_exists($returnType->getName())) {
214+
$this->write("\\");
215+
}
216+
$this->write($returnType->getName());
203217
}
204218
$this->writeLine(" {");
205219

0 commit comments

Comments
 (0)