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

PSR-12 and Moodle Coding style

    • Icon: Epic Epic
    • Resolution: Unresolved
    • Icon: Medium Medium
    • Coding style
    • None
    • PSR-12 and Moodle Coding style

      This epic is to capture the discussions and decisions around Moodle LMS adopting the PSR-12 coding style for more elements of its current Coding style.

      Some of the flagged benefits of being more aligned with PSR-12 are:

      • Less of a learning curve for new Moodle developers, as Moodle LMS code will be more aligned with other PHP projects.
      • More compatibility with code analysis and code coverage tools. Which in turn can make automated tests and CI/CD operations easier.
      • Pave the way for code cleanup (some of it automated), so there aren’t multiple examples of doing something different ways.

      These need to be balanced against the change required to implement them. The policy about coding style fixes (https://moodledev.io/general/development/policies/codingstyle#policy-about-coding-style-only-fixes ) may also need to be revisited.

      PSR-12  extends, expands and replaces[ PSR-2|https://www.php-fig.org/psr/psr-2/], the coding style guide and requires adherence to[ PSR-1|https://www.php-fig.org/psr/psr-1/], the basic coding standard.

      Each issue in this epic evaluates one aspect of the Moodle Coding style (MCS) where it is different to PSR-12. The issue description themselves tries to only outline the differences and any other relevant facts. And not offer any opinions.

      PSR-12 reference: https://www.php-fig.org/psr/psr-12/ 

      PSR-1 reference: https://www.php-fig.org/psr/psr-1/ 

      Moodle coding style: https://moodledev.io/general/development/policies/codingstyle 

      Styles where MCS and PSR match already:

      Styles where MCS seems to match PSR, but PSR is not explicit. AND/OR MCS is explicit and it’s not in PSR

      These may need follow up review on individual trackers:

      The process done so far was to only compare MCS to PSR in that direction. Analysis hasn’t been done on PSR to MCS. There are some sections where PSR is more explicit. However, this extra step likely doesn’t need to be done as the MCS docs state: “Unless otherwise specified, this Coding Style document will defer to[ ** PSR-12|https://www.php-fig.org/psr/psr-12/], and[ ** PSR-1|https://www.php-fig.org/psr/psr-1/] in that order.”

            matt.porritt@moodle.com Matt Porritt
            matt.porritt@moodle.com Matt Porritt
            Martin Dougiamas Martin Dougiamas
            Nobody Nobody
            0 Vote for this issue
            7 Start watching this issue


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