Wrap combined file content with global namespace#8530
Wrap combined file content with global namespace#8530dmolineus wants to merge 2 commits intocontao:developfrom
Conversation
|
What is wrong with |
|
@leofeyer that's a different case, you're referring to a string which always must be used with FQCN, but @dmolineus is referring to calling code in the respective files. |
|
I wanted to point out that it is not necessary to use Our goal should be to reduce PHP usage in DCA files, so we can e.g. use YAML files in the future. |
Nothing wrong with that. The benefit of And yes, the class does not have to be loaded to use the |
Using the Furthermore Contao supports callable here since 3.2(?). For using class names inside anonymously functions using the use statement would be helpful.
As long as the PHP are used, standard PHP features should be supported as well. Detecting name refences by IDEs when renaming or moving classes is one benefit from it (and a drawback of YAML files). |
|
I'm +1 on this PR. |
|
I am also 👍 I have experienced the described issue in the past and had to remove the imports from |
|
Implemented in contao/core-bundle@6669a09. |
Since Contao supports callables for dca callbacks and PHP 5.5 introduced the
Class:classconstant there are valid cases using theuse statementfor namespaced classes in the dca and config files.At the moment you cannot use the
use statementbecause of the danger that the combined files could have duplicate use statements. This pull request fixes it by wrapping each file content in a namespace notation.So it would get possible to use following code safely:
DCA file
Config file