Some of the reactions to my last blog post on https://verraes.net/2014/06/named-constructors-in-php/, originate from the notion that static methods are inherently bad and should never be used. Static methods are nothing more than namespaced global functions.

As for global functions: We use those all the time.

You might still feel resistance against something like Calculator::sum($x, $y), because it can not be extended or mocked.

There is, in PHP, an interesting distinction between + and Calculator::sum($x, $y): the former can not be injected, the latter can:
Newsletter

Get the latest Laravel/PHP jobs, events and curated articles straight to your inbox, once a week

Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge. Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge.
Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Shirts painstakingly handcrafted by under-caffeinated developers. Shirts painstakingly handcrafted by under-caffeinated developers.
Community Partners