You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Could you explain please why you suggest class as a alternative of function in this case?
Why classes whouldn't conflict between each other like functions in that example?
And why namespaces and naming convenction wouldn't resolve this sort of issue?
I guess such kind of a solution would work fine as well:
use function \App\Helpers\config as myConfig; //just for instance
use function \Path\To\Imported\Package\config;
$app = new Application();
$app->setConfig(myConfig());
$app->setConfig(config());
The text was updated successfully, but these errors were encountered:
andreyvolosyuk
changed the title
Don't write to global functions (classes without namespaces???)
Don't write to global functions (classes without namespaces?)
May 14, 2018
andreyvolosyuk
changed the title
Don't write to global functions (classes without namespaces?)
Don't write to global functions (classes?)
May 14, 2018
I think the problem is related to the fact that this section is copied and not very well adapted for PHP.
Of course, the introduction of namespaces is also a solution to the problem.
I would emphasize that Configuration class should be used as Dependency Injection, and config() function, even in namespace, is global and can be used anywhere in the program as a global variable.
https://github.com/jupeter/clean-code-php#dont-write-to-global-functions
Could you explain please why you suggest class as a alternative of function in this case?
Why classes whouldn't conflict between each other like functions in that example?
And why namespaces and naming convenction wouldn't resolve this sort of issue?
I guess such kind of a solution would work fine as well:
The text was updated successfully, but these errors were encountered: