Why isn't getFacadeAccessor() method abstract?












1















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?










share|improve this question























  • abstract methods require implementation in child classes. Implementation of getFacadeAccessor is likely optional, which means abstract would be the wrong keyword to use.

    – Bytewave
    Sep 3 '17 at 17:16











  • Dis you read entire topic?

    – Robo Robok
    Sep 3 '17 at 18:35











  • Yes. If you extend an abstract class, you must provide implementations for all abstract methods in that class. However, I'm assuming that providing an implementation for getFacadeAccessor is optional, so using an abstract method would make anyone defining a Facade provide some implementation for getFacadeAccessor even if they don't want/need to. So, leaving this implementation instead means programmers aren't required to define the method themselves when making a Facade.

    – Bytewave
    Sep 3 '17 at 18:40











  • You didn't read the topic then. Take a look at the snippet. How is implementation of that method optional, if it throws the exception telling you to implement it? xD

    – Robo Robok
    Sep 3 '17 at 18:42






  • 1





    Because you don't understand I mean. It's optional in the sense that I don't have to write a class that then provides an implementation for it. If it were abstract, I'd have to provide one, even if I don't want to. I'd probably end up writing an implementation like you see above, but in my child class. So Laravel just handles that for you, and leaves it up to you if you actually want to provide an implementation instead.

    – Bytewave
    Sep 3 '17 at 18:47
















1















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?










share|improve this question























  • abstract methods require implementation in child classes. Implementation of getFacadeAccessor is likely optional, which means abstract would be the wrong keyword to use.

    – Bytewave
    Sep 3 '17 at 17:16











  • Dis you read entire topic?

    – Robo Robok
    Sep 3 '17 at 18:35











  • Yes. If you extend an abstract class, you must provide implementations for all abstract methods in that class. However, I'm assuming that providing an implementation for getFacadeAccessor is optional, so using an abstract method would make anyone defining a Facade provide some implementation for getFacadeAccessor even if they don't want/need to. So, leaving this implementation instead means programmers aren't required to define the method themselves when making a Facade.

    – Bytewave
    Sep 3 '17 at 18:40











  • You didn't read the topic then. Take a look at the snippet. How is implementation of that method optional, if it throws the exception telling you to implement it? xD

    – Robo Robok
    Sep 3 '17 at 18:42






  • 1





    Because you don't understand I mean. It's optional in the sense that I don't have to write a class that then provides an implementation for it. If it were abstract, I'd have to provide one, even if I don't want to. I'd probably end up writing an implementation like you see above, but in my child class. So Laravel just handles that for you, and leaves it up to you if you actually want to provide an implementation instead.

    – Bytewave
    Sep 3 '17 at 18:47














1












1








1








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?










share|improve this question














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?







php laravel laravel-facade






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Sep 3 '17 at 17:07









Robo RobokRobo Robok

4,62353257




4,62353257













  • abstract methods require implementation in child classes. Implementation of getFacadeAccessor is likely optional, which means abstract would be the wrong keyword to use.

    – Bytewave
    Sep 3 '17 at 17:16











  • Dis you read entire topic?

    – Robo Robok
    Sep 3 '17 at 18:35











  • Yes. If you extend an abstract class, you must provide implementations for all abstract methods in that class. However, I'm assuming that providing an implementation for getFacadeAccessor is optional, so using an abstract method would make anyone defining a Facade provide some implementation for getFacadeAccessor even if they don't want/need to. So, leaving this implementation instead means programmers aren't required to define the method themselves when making a Facade.

    – Bytewave
    Sep 3 '17 at 18:40











  • You didn't read the topic then. Take a look at the snippet. How is implementation of that method optional, if it throws the exception telling you to implement it? xD

    – Robo Robok
    Sep 3 '17 at 18:42






  • 1





    Because you don't understand I mean. It's optional in the sense that I don't have to write a class that then provides an implementation for it. If it were abstract, I'd have to provide one, even if I don't want to. I'd probably end up writing an implementation like you see above, but in my child class. So Laravel just handles that for you, and leaves it up to you if you actually want to provide an implementation instead.

    – Bytewave
    Sep 3 '17 at 18:47



















  • abstract methods require implementation in child classes. Implementation of getFacadeAccessor is likely optional, which means abstract would be the wrong keyword to use.

    – Bytewave
    Sep 3 '17 at 17:16











  • Dis you read entire topic?

    – Robo Robok
    Sep 3 '17 at 18:35











  • Yes. If you extend an abstract class, you must provide implementations for all abstract methods in that class. However, I'm assuming that providing an implementation for getFacadeAccessor is optional, so using an abstract method would make anyone defining a Facade provide some implementation for getFacadeAccessor even if they don't want/need to. So, leaving this implementation instead means programmers aren't required to define the method themselves when making a Facade.

    – Bytewave
    Sep 3 '17 at 18:40











  • You didn't read the topic then. Take a look at the snippet. How is implementation of that method optional, if it throws the exception telling you to implement it? xD

    – Robo Robok
    Sep 3 '17 at 18:42






  • 1





    Because you don't understand I mean. It's optional in the sense that I don't have to write a class that then provides an implementation for it. If it were abstract, I'd have to provide one, even if I don't want to. I'd probably end up writing an implementation like you see above, but in my child class. So Laravel just handles that for you, and leaves it up to you if you actually want to provide an implementation instead.

    – Bytewave
    Sep 3 '17 at 18:47

















abstract methods require implementation in child classes. Implementation of getFacadeAccessor is likely optional, which means abstract would be the wrong keyword to use.

– Bytewave
Sep 3 '17 at 17:16





abstract methods require implementation in child classes. Implementation of getFacadeAccessor is likely optional, which means abstract would be the wrong keyword to use.

– Bytewave
Sep 3 '17 at 17:16













Dis you read entire topic?

– Robo Robok
Sep 3 '17 at 18:35





Dis you read entire topic?

– Robo Robok
Sep 3 '17 at 18:35













Yes. If you extend an abstract class, you must provide implementations for all abstract methods in that class. However, I'm assuming that providing an implementation for getFacadeAccessor is optional, so using an abstract method would make anyone defining a Facade provide some implementation for getFacadeAccessor even if they don't want/need to. So, leaving this implementation instead means programmers aren't required to define the method themselves when making a Facade.

– Bytewave
Sep 3 '17 at 18:40





Yes. If you extend an abstract class, you must provide implementations for all abstract methods in that class. However, I'm assuming that providing an implementation for getFacadeAccessor is optional, so using an abstract method would make anyone defining a Facade provide some implementation for getFacadeAccessor even if they don't want/need to. So, leaving this implementation instead means programmers aren't required to define the method themselves when making a Facade.

– Bytewave
Sep 3 '17 at 18:40













You didn't read the topic then. Take a look at the snippet. How is implementation of that method optional, if it throws the exception telling you to implement it? xD

– Robo Robok
Sep 3 '17 at 18:42





You didn't read the topic then. Take a look at the snippet. How is implementation of that method optional, if it throws the exception telling you to implement it? xD

– Robo Robok
Sep 3 '17 at 18:42




1




1





Because you don't understand I mean. It's optional in the sense that I don't have to write a class that then provides an implementation for it. If it were abstract, I'd have to provide one, even if I don't want to. I'd probably end up writing an implementation like you see above, but in my child class. So Laravel just handles that for you, and leaves it up to you if you actually want to provide an implementation instead.

– Bytewave
Sep 3 '17 at 18:47





Because you don't understand I mean. It's optional in the sense that I don't have to write a class that then provides an implementation for it. If it were abstract, I'd have to provide one, even if I don't want to. I'd probably end up writing an implementation like you see above, but in my child class. So Laravel just handles that for you, and leaves it up to you if you actually want to provide an implementation instead.

– Bytewave
Sep 3 '17 at 18:47












1 Answer
1






active

oldest

votes


















0














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.







share|improve this answer
























  • Nice find! It's rather stupid though. Laravel is not for dummies, I'm pretty sure most developers would find a regular solution more clear than this quirky idea.

    – Robo Robok
    Nov 23 '18 at 23:48











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f46025922%2fwhy-isnt-getfacadeaccessor-method-abstract%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














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.







share|improve this answer
























  • Nice find! It's rather stupid though. Laravel is not for dummies, I'm pretty sure most developers would find a regular solution more clear than this quirky idea.

    – Robo Robok
    Nov 23 '18 at 23:48
















0














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.







share|improve this answer
























  • Nice find! It's rather stupid though. Laravel is not for dummies, I'm pretty sure most developers would find a regular solution more clear than this quirky idea.

    – Robo Robok
    Nov 23 '18 at 23:48














0












0








0







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.







share|improve this answer













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.








share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 23 '18 at 19:36









HatzegopteryxHatzegopteryx

32946




32946













  • Nice find! It's rather stupid though. Laravel is not for dummies, I'm pretty sure most developers would find a regular solution more clear than this quirky idea.

    – Robo Robok
    Nov 23 '18 at 23:48



















  • Nice find! It's rather stupid though. Laravel is not for dummies, I'm pretty sure most developers would find a regular solution more clear than this quirky idea.

    – Robo Robok
    Nov 23 '18 at 23:48

















Nice find! It's rather stupid though. Laravel is not for dummies, I'm pretty sure most developers would find a regular solution more clear than this quirky idea.

– Robo Robok
Nov 23 '18 at 23:48





Nice find! It's rather stupid though. Laravel is not for dummies, I'm pretty sure most developers would find a regular solution more clear than this quirky idea.

– Robo Robok
Nov 23 '18 at 23:48


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f46025922%2fwhy-isnt-getfacadeaccessor-method-abstract%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Berounka

Sphinx de Gizeh

Different font size/position of beamer's navigation symbols template's content depending on regular/plain...