This commit is contained in:
Barry vd. Heuvel
2024-12-29 19:42:42 +01:00
parent aed6c0c5b8
commit 6d19a48da4
2 changed files with 9 additions and 5 deletions
+7 -3
View File
@@ -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];
}
/**
@@ -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);