Why isn't getFacadeAccessor() method abstract?

2.8k views Asked by At

In Laravel's illuminate/support/Facades/Facade.php file there's a following method:

/**
 * Get the registered name of the component.
 *
 * @return string
 *
 * @throws \RuntimeException
 */
protected static function getFacadeAccessor()
{
    throw new RuntimeException('Facade does not implement getFacadeAccessor method.');
}

Is there any potential of doing that instead of just defining an abstract method, like below?

abstract protected static function getFacadeAccessor();

Why did they possibly want to reinvent the wheel?

1

There are 1 answers

1
Hatzegopteryx On

I found the following reason here:

This method is designed to be overridden when extending the Facade class to return a string, the key which the service represented by the facade is bound within the container. By default, it throws an exception if not implemented. This gives a more informative message to those creating custom facades than if the framework were to instead use an abstract method.