2016-02-08 12:47:09
2016-02-07 14:30:19
2016-02-07 14:13:33
5367
static functions in php
@Friendica Support @Fabio @Friendica Developers
In reference to @Michael Vogel post about Ideas for refactoring I have a question about understanding of "static calls" of methods and static method.
To break it down: "If we want to call methods with a static call (like dfrn::import) shouldn't
From my understanding (it's how I interpret https://secure.php.net/manual/de/language.oop5.static.php - sry for the german version, but this part is not in the english version) both would be work because php5 would interpret
Calling
From all this points I would vote to declare static methods explicit as
To summarize my question:
In reference to @Michael Vogel post about Ideas for refactoring I have a question about understanding of "static calls" of methods and static method.
To break it down: "If we want to call methods with a static call (like dfrn::import) shouldn't
function import()
of the class dfrn declared explicitly as public static function
?"From my understanding (it's how I interpret https://secure.php.net/manual/de/language.oop5.static.php - sry for the german version, but this part is not in the english version) both would be work because php5 would interpret
function
as puplic static function
automatically because of compatibly issues with php4. To call function
statically would print a E_STRICT level warning in php5 and a E_DEPRECATED warning in php7.Calling
function
statically does have regression in my workflow since my IDE doesn't do autocompletion for this method (and no doxygen).From all this points I would vote to declare static methods explicit as
public static function
.To summarize my question:
function
and public static function
seems to be the same. Or I have misunderstood something?Dieser Beitrag wurde bearbeitet. (8 Jahre her)
Fabio
So, yes it works, but is more future-proof to declare it static
Rabuzarus
public static function
my IDE doesn't give me autocompletion for static calls of methods and it also won't give me the needed doxygen automatically.Any concerns on this?
Fabio
I have concerns on not doing it