Zum Inhalt der Seite gehen


static functions in php


Dieser Beitrag wurde bearbeitet. (8 Jahre her)
from English version of the page https://secure.php.net/manual/en/language.oop5.static.php
Caution
In PHP 5, calling non-static methods statically generates an E_STRICT level warning.

Warning
In PHP 7, calling non-static methods statically is deprecated, and will generate an E_DEPRECATED warning. Support for calling non-static methods statically may be removed in the future.



So, yes it works, but is more future-proof to declare it static
Since there seems to be no regression to declare it as static I would vote for doing it because without declaring it as 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?
Not on my side.
I have concerns on not doing it :-)