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
We had a bug which it turned out was caused by an unexpected interaction between self and late static binding (see this PR).
This was raised in php-src where the response was that it was working as intended.
Going forward we should avoid calling static methods from self to avoid this class of bug.
Acceptance Criteria
The PHP coding standards are updated to explicitly disallow calling static methods with self (e.g. self::get())
The docs mention the rationale, i.e. we're avoiding a specific class of bug that is introduced when using late static binding downstream from self
static is fine, because it explicitly uses late static binding anyway
TO DECIDE
Are there any scenarios where self is allowed? e.g. is self okay in a type hint, and is self::class okay? Or is is better to just avoid self altogether (e.g. use the explicit class name, or __CLASS__ as a replacement of self::class)?
The text was updated successfully, but these errors were encountered:
Is there an actual issue that got cause by this? e.g. Did we have a scenario where we called self::get() in Link wanting to query all Links and ended up querying only FileLink.
We had a bug which it turned out was caused by an unexpected interaction between
self
and late static binding (see this PR).This was raised in php-src where the response was that it was working as intended.
Going forward we should avoid calling static methods from
self
to avoid this class of bug.Acceptance Criteria
self
(e.g.self::get()
)self
static
is fine, because it explicitly uses late static binding anywayTO DECIDE
self
is allowed? e.g. isself
okay in a type hint, and isself::class
okay? Or is is better to just avoidself
altogether (e.g. use the explicit class name, or__CLASS__
as a replacement ofself::class
)?The text was updated successfully, but these errors were encountered: