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
(html and php code would obvisouly be separated in 2 files.. putting them together for demonstration purposes)
that way I can use function and optionally import aliases to shrink it even further.
this has the problem that I no longer can rely on native autoloading though.
its easier to read
I am thinking whether it would be possible to combine the benefits of the 2 approaches
-> new use function syntax (to be discussed)
-> for static methods only
-> autoloading of the HtmlHelper class
-> readability of the function imported aliases (import alias only optional)
wdyt?
The text was updated successfully, but these errors were encountered:
This reminds me of import static from Java. I guess it could make sense for PHP too.
This is likely not hard to implement, but there are a few questions around edge cases that need to be solved:
How to handle name clashes with a local function of the same name as an alias
Should the alias be usable as a string-based callable?
Anyway, since this is a language change this requires an RFC.
If implemented like use function HtmlHelper::escape_htmlspecial as html_esc;, ie. use function with :: support, then the answers for the questions are:
* How to handle name clashes with a local function of the same name as an alias
Uh oh!
There was an error while loading. Please reload this page.
Description
use of static methods can get pretty bulky and leads to pretty long expressions, see
(html and php code would obvisouly be separated in 2 files.. putting them together for demonstration purposes)
static method have the benefit of beeing autoloaded though.
I could use namespaced functions instead:
(html and php code would obvisouly be separated in 2 files.. putting them together for demonstration purposes)
that way I can
use function
and optionally import aliases to shrink it even further.this has the problem that I no longer can rely on native autoloading though.
its easier to read
I am thinking whether it would be possible to combine the benefits of the 2 approaches
Proposal:
-> new
use function
syntax (to be discussed)-> for static methods only
-> autoloading of the HtmlHelper class
-> readability of the function imported aliases (import alias only optional)
wdyt?
The text was updated successfully, but these errors were encountered: