Skip to content

Commit 78261a9

Browse files
Merge pull request #307 from N1ebieski/Fix-Call-to-a-member-function-getParameters-on-null-#9
Fix call to a member function get parameters on null
2 parents 408e8fe + 37e22fd commit 78261a9

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

php-templates/blade-components.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ protected function getStandardClasses()
9090
$class = \Illuminate\Support\Str::of($item['path'])
9191
->after('View/Components/')
9292
->replace('.php', '')
93+
->replace('/', '\\')
9394
->prepend($appNamespace . 'View\\Components\\')
9495
->toString();
9596

@@ -98,7 +99,7 @@ protected function getStandardClasses()
9899
}
99100

100101
$reflection = new \ReflectionClass($class);
101-
$parameters = collect($reflection->getConstructor()->getParameters())
102+
$parameters = collect($reflection->getConstructor()?->getParameters() ?? [])
102103
->filter(fn($p) => $p->isPromoted())
103104
->flatMap(fn($p) => [$p->getName() => $p->isOptional() ? $p->getDefaultValue() : null])
104105
->all();

src/templates/blade-components.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ $components = new class {
9090
$class = \\Illuminate\\Support\\Str::of($item['path'])
9191
->after('View/Components/')
9292
->replace('.php', '')
93+
->replace('/', '\\\\')
9394
->prepend($appNamespace . 'View\\\\Components\\\\')
9495
->toString();
9596
@@ -98,7 +99,7 @@ $components = new class {
9899
}
99100
100101
$reflection = new \\ReflectionClass($class);
101-
$parameters = collect($reflection->getConstructor()->getParameters())
102+
$parameters = collect($reflection->getConstructor()?->getParameters() ?? [])
102103
->filter(fn($p) => $p->isPromoted())
103104
->flatMap(fn($p) => [$p->getName() => $p->isOptional() ? $p->getDefaultValue() : null])
104105
->all();

0 commit comments

Comments
 (0)