silverstripe / developer-docs

Developer documentation for Silverstripe CMS
Other
6 stars 67 forks source link

Update PHP coding standards to avoid using `self` #486

Closed GuySartorelli closed 5 months ago

GuySartorelli commented 8 months ago

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.

Notes

Acceptance Criteria

Code writing script

Kitchen sink CI

PRs

maxime-rainville commented 7 months ago

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.

GuySartorelli commented 7 months ago

Is there an actual issue that got cause by this?

Yes. I'll link you the slack thread.

GuySartorelli commented 5 months ago

PRs merged. I've raised https://github.com/silverstripe/silverstripe-standards/issues/8 to add a rule in CI to catch this happening in the future.