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.
Comments
Comment #2
drunken monkeyI don’t think this correctly reflects our current workflow. As I see it, standards that depend on the PHP version are already possible. We just don’t get new standards for PHP 7 because we don’t really get any new standards at all. (Apparently, the last time we added a new standard was 2 years 8 months ago.)
The process, once again, just doesn’t seem to work very well.
Comment #3
dwwWe 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