I get confused myself from time to time which is which in self vs. static, but I'm pretty sure we want to use static (i.e., the late static binding introduced in PHP 5.3) in most cases. So, I think most (or even all) of the self:: we currently have in our code should be switched to static::.

Comments

drunken monkey created an issue. See original summary.

drunken monkey’s picture

Status: Active » Needs review
StatusFileSize
new11.79 KB

This would be a patch.
Reasonably, PHP doesn't allow static where class constants are used at compile time, so a few self:: instances remained. (Plus some in Query::sort() where the parameter defaults to self::SORT_ASC so I found it confusing to switch the rest.)

drunken monkey’s picture

Thinking about it a bit more, it might actually be a good idea to switch almost all constant references to use self:: – otherwise, the constants aren't really constant. If someone would actually override them in a child class (so static vs. self would actually matter), this would just be a recipe for chaos.
So, at least as long as the constants are also used outside of the defining class (not the case for the DB backend – and overriding there might actually serve a purpose), self:: makes more sense.

Input welcome, in any case.

borisson_’s picture

StatusFileSize
new11.65 KB
new7.15 KB

I agree with #3, conts should use self::, methods should be static::

  • drunken monkey committed c162844 on 8.x-1.x
    Issue #2945675 by drunken monkey, borisson_: Unified use of self and...
drunken monkey’s picture

Status: Needs review » Fixed

Alright, then, thanks for your input and work!
Committed.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.