Uploaded image for project: 'Moodle Community Sites'
  1. Moodle Community Sites
  2. MDLSITE-5879

Respect PSR-1, and PSR-12 where no existing rule exists

XMLWordPrintable

    • Icon: Improvement Improvement
    • Resolution: Done
    • Icon: Low Low
    • Coding style

      Policy: Default to PSR-12 and PSR-1

      Since 20th March 2020, this has been agreed:

      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.

      * "de-facto Moodle standard" is any coding style which is commonly and typically used in Moodle

      Background

      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.

      Proposal

      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:

      1. PSR-12: https://www.php-fig.org/psr/psr-12/
      2. PSR-2: https://www.php-fig.org/psr/psr-2/ Replaced by PSR-12
      3. 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

      Voting

      This proposal has three voting options.

      Vote "Accept"

      The wording of this proposal should be accepted in its current form.

      Vote "Reject"

      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.

      Vote "Dismiss"

      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.

            stronk7 Eloy Lafuente (stronk7)
            dobedobedoh Andrew Lyons
            Votes:
            1 Vote for this issue
            Watchers:
            9 Start watching this issue

              Created:
              Updated:
              Resolved:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.