diff --git a/src/Illuminate/View/AnonymousComponent.php b/src/Illuminate/View/AnonymousComponent.php index 154b0a8048b7..c686b97b7f50 100644 --- a/src/Illuminate/View/AnonymousComponent.php +++ b/src/Illuminate/View/AnonymousComponent.php @@ -2,8 +2,6 @@ namespace Illuminate\View; -use ReflectionClass; - class AnonymousComponent extends Component { /** diff --git a/src/Illuminate/View/Component.php b/src/Illuminate/View/Component.php index f627956a8249..219ecd51d496 100644 --- a/src/Illuminate/View/Component.php +++ b/src/Illuminate/View/Component.php @@ -89,11 +89,15 @@ abstract class Component */ public static function ignoredParameterNames(): array { - if (!isset(static::$ignoredParameterNames[static::class])) { + if (! isset(static::$ignoredParameterNames[static::class])) { $constructor = (new ReflectionClass( static::class ))->getConstructor(); + if (!$constructor) { + static::$ignoredParameterNames[static::class] = []; + } + static::$ignoredParameterNames[static::class] = collect($constructor->getParameters()) ->map->getName() ->all();