Document that Drupal aims to be PSR-1 compliant in the coding standards

Created on 10 April 2016, almost 9 years ago
Updated 13 February 2025, 9 days ago

Problem/Motivation

Drupal is fully PSR-1 compliant http://www.php-fig.org/psr/psr-1/ , but this is not mentioned on the coding standards page at all.

Proposed resolution

Mention PSR-1 on the coding standards page.

Change the current text:

Note: The Drupal Coding Standards apply to code within Drupal and its contributed modules. This document is loosely based on the PEAR Coding standards.

To:

Note: The Drupal Coding Standards apply to code within Drupal and its contributed modules. This document is loosely based on the PEAR Coding standards. Drupal Coding Standards follow PSR-1.

Remaining tasks

Build agreement that we want to add that to the coding standards page, tune the wording and do it. We don't need to make an announcement for a coding standard change, because we are only documenting what we already follow.

📌 Task
Status

Active

Component

Coding Standards

Created by

🇦🇹Austria klausi 🇦🇹 Vienna

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇳🇿New Zealand quietone

    Updating,

    (11.x)$ ag -l "^function|^class|^interface" `ag -l "^require_once"` | nl
         1  core/tests/Drupal/Tests/Core/Error/DrupalLogErrorTest.php

    PSR1 states, "This means each class is in a file by itself, and is in a namespace of at least one level: a top-level vendor name." but there are 125 files with two classes.

  • 🇧🇪Belgium borisson_ Mechelen, 🇧🇪

    So we clearly aren't there yet, but I guess we can look at the individual rules that make up that phpcs --standard=PSR1, and introduce them into our own phpcs.xml, so that we can eventually say we are compliant with PSR-1?

  • 🇳🇿New Zealand quietone

    Yes, it would be nice to say we comply. I updated the remaining task with some steps.

    I also am changing this to 'Minor'. While we don't have a definition of the priorities for Coding Standards, I think 'normal' would be issues that directly affect our code base.

Production build 0.71.5 2024