Skip to content

Commit 415b54c

Browse files
author
Patrick FARRUGIA
committed
Fix 2 problems in MacrosCommand :
- We make sure we manipulate a 'macro' in the handle() method - We make sure we retrieve the proper parameter type in case it references a class (by adding a backslash) Fix KristofMorva#33
1 parent 45ed2ce commit 415b54c

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/Console/MacrosCommand.php

+9-1
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,11 @@ public function handle()
9292
$this->generateNamespace($reflection->getNamespaceName(), function () use ($macros, $reflection) {
9393
$this->generateClass($reflection->getShortName(), function () use ($macros) {
9494
foreach ($macros as $name => $macro) {
95+
if (!$macro) {
96+
// To ensure manipulating macro and not falsy value such as "null", as "false"
97+
continue;
98+
}
99+
95100
if (is_array($macro)) {
96101
list($class, $method) = $macro;
97102
$function = new \ReflectionMethod(is_object($class) ? get_class($class) : $class, $method);
@@ -186,7 +191,10 @@ protected function generateFunction($name, $parameters, $type = '', $returnType
186191
if ($paramType->allowsNull()) {
187192
$this->write("?");
188193
}
189-
$this->write($paramType->getName() . " ");
194+
195+
$paramTypeName = $paramType->getName();
196+
$paramTypeNameWrited = class_exists($paramTypeName) ? "\\" . $paramTypeName : $paramTypeName;
197+
$this->write($paramTypeNameWrited . " ");
190198
}
191199
}
192200
}

0 commit comments

Comments
 (0)