diff --git a/src/Console/MetaCommand.php b/src/Console/MetaCommand.php index cccc0f5..7e83cda 100644 --- a/src/Console/MetaCommand.php +++ b/src/Console/MetaCommand.php @@ -251,12 +251,16 @@ class MetaCommand extends Command */ protected function loadTemplate($name) { - if (!isset($this->templates[$name])) { + if (!isset($this->templateCache[$name])) { $file = __DIR__ . '/../../php-templates/' . basename($name) . '.php'; - $this->templates[$name] = $this->files->requireOnce($file); + $value = $this->files->requireOnce($file) ?: []; + if (!$value instanceof Collection) { + $value = collect($value); + } + $this->templateCache[$name] = $value; } - return $this->templates[$name]; + return $this->templateCache[$name]; } /** diff --git a/tests/Console/MetaCommand/MetaCommandTest.php b/tests/Console/MetaCommand/MetaCommandTest.php index fad391e..116f7ae 100644 --- a/tests/Console/MetaCommand/MetaCommandTest.php +++ b/tests/Console/MetaCommand/MetaCommandTest.php @@ -27,7 +27,7 @@ class MetaCommandTest extends TestCase $mockFileSystem ->shouldReceive('getRequire') - ->andReturnUsing(function ($__path, $__data) { + ->andReturnUsing(function ($__path, $__data = []) { return (static function () use ($__path, $__data) { extract($__data, EXTR_SKIP); @@ -60,7 +60,7 @@ class MetaCommandTest extends TestCase $mockFileSystem ->shouldReceive('getRequire') - ->andReturnUsing(function ($__path, $__data) { + ->andReturnUsing(function ($__path, $__data = []) { return (static function () use ($__path, $__data) { extract($__data, EXTR_SKIP);