-
Task
-
Resolution: Unresolved
-
Low
-
None
See https://www.php-fig.org/psr/psr-12/#example
See our current policy: https://moodledev.io/general/development/policies/codingstyle#namespaces
Examples of incorrect class importing
|
|
<?php
|
|
use mod_porridge\local\equipment\spoon, mod_porridge\local\equipment\bowl; // Multiple classes per line.
|
This is pretty vague, in that it doesn't adequately address how to import multiple classes from the same namespace grouped by brackets, e.g.:
use mod_porridge\local\equipment\{spoon, bowl};
|
This came from a discussion with dobedobedoh, hence creating this policy issue to explicitly allow such import declarations of multiple classes from common namespace as per PSR-12
Voting options
The following options are suggested for voting. Note class aliasing should remain allowed for all options. Proposal is to allow only for those classes in the same namespace (open to discussion)
Please refer to the PSR extended coding style document
Option A
Allow the following in new code:
use foo\bar\baz\{
|
a as bazA,
|
b,
|
c,
|
};
|
Option B
Allow the following in new code:
use foo\bar\baz\{a as bazA, b, c};
|
Option C
Allow both A) or B)
Option D (status quo)
Do not allow A) or B)