Moodle's coding style pre-dates the standard and widely recognised PSR specifications. There have been several requests for us to start recognising these in the future.
I would like to propose that our coding style guidelines be updated to explicitly defer to the PSR standards relating to coding style where no explicit rule already exists.
Those standards are:
- PSR-12: https://www.php-fig.org/psr/psr-12/
PSR-2: https://www.php-fig.org/psr/psr-2/Replaced by PSR-12
- PSR-1: https://www.php-fig.org/psr/psr-1/
Existing coding style rules must continue to be observed, but for new styles we have not yet ruled on, we should defer to those PSRs in that order (newest to oldest).
It is suggested that the following wording replace the existing section 1.1, "Scope" of the coding style:
This document describes style guidelines for developers working on or with Moodle code. It talks purely about the mechanics of code layout and the choices we have made for Moodle. The intent of this specification is to reduce cognitive friction when scanning code from different authors. It does so by enumerating a shared set of rules and expectations about how to format PHP code.
Unless otherwise specified, this Coding Style document will defer to PSR-12, and PSR-1 in that order.
Where a de-facto Moodle standard is encountered but is undocumented, an appropriate MDLSITE issue should be raised to have the standard either documented within this Coding style guide, or rejected and the PSR recommendations adopted instead.
A "de-facto Moodle standard" is any coding style which is commonly and typically used in Moodle
This proposal has three voting options.
The wording of this proposal should be accepted in its current form.
This proposal should be rejected in its current form but should be amended to consider additional points. It may be resubmitted in the future once these points are addressed.
This proposal should be rejected, and the issue closed. It will not be re-opened for discussion in the near future, unless there is a change in situation.