[Policy] Consider creating coding standards depended on specific PHP versions

Created on 8 December 2019, over 4 years ago
Updated 11 April 2024, about 2 months ago

Problem/Motivation

There are a few issues related to PHP 7 and all of them typically declare something like this.

once Drupal 8 drops PHP 5 support

Even though Drupal has just dropped support for PHP 5 I think the above statement is totally wrong because it does not reflect the fact that Drupal coding standards are intended not only for Drupal core. Contributed and custom projects do not have to support outdated PHP versions. In fact, I believe most of Drupal 8 sites run on PHP 7 for quite a long time. And they have to invent own coding standards for PHP 7 because Drupal coding standards do not cover features that come with new PHP versions.

Consider typed properties added in PHP 7.4. If you start a new Drupal project on PHP 7.4 you may want to use them. But will Drupal coding standards allow those? If so will this be mandatory or optional? With the current workflow these questions will likely be answered only in a few years when Drupal core drops support for PHP 7.3. Until then you have to follow your own coding standards.

Currently the coding standards are always apply to any version of Drupal and PHP. Though we have broken that rule at least once ( #2135291: [Policy, no patch] PHP 5.4 short array syntax coding standards for Drupal 8 β†’ ). Nowadays, I believe that approach is outdated because PHP development has accelerated a lot and new major PHP versions come every year.

Proposed resolution

Allow coding standards to depend on PHP version.
Develop those standards without waiting for Drupal core dropping support of previous PHP versions.

πŸ“Œ Task
Status

Closed: won't fix

Component

Coding Standards

Created by

πŸ‡·πŸ‡ΊRussia Chi

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.

  • πŸ‡ΊπŸ‡ΈUnited States dww

    We reviewed this in this week's coding standards meeting, and there was universal agreement that this shouldn't happen. πŸ˜‚

    @quietone: "I am thinking this is a won't fix."
    @catch: "Yeah we have rolling PHP version requirements, as does PHP itself, won't fix is good."
    @borisson_: "I agree, coding standards are a living thing, fixing them in time or per version of php seems like making it difficult. +1 to won't fix"
    @kingdutch: "Agreed. Coding standards should be for supported features which should work across PHP versions. The only dependency we have on PHP version is for feature introduction (like with Enum) but in that case older versions can ignore the part of the standard because they're not using the feature."

    Instead of commenting in Slack, I'll comment here: I also agree. πŸ˜† Won't fix it is...

    Thanks,
    -Derek

Production build 0.69.0 2024