You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Moodle's coding style does not actively state anything regarding the location of the opening brace when there are multiple implemnts but we previously conventioned the following:
class after_user_passed_mfa implements
\Psr\EventDispatcher\StoppableEventInterface {
However, PSR-12 states:
The extends and implements keywords MUST be declared on the same line as the class name.
The opening brace for the class MUST go on its own line; the closing brace for the class MUST go on the next line after the body.
Opening braces MUST be on their own line and MUST NOT be preceded or followed by a blank line.
Lists of implements and, in the case of interfaces, extends MAY be split across multiple lines, where each subsequent line is indented once. When doing so, the first item in the list MUST be on the next line, and there MUST be only one interface per line.
That is, the following is accepted:
class after_user_passed_mfa implements
\Psr\EventDispatcher\StoppableEventInterface
{
This is slightly conflated by the fact that PSR-12 requires that the opening brace for a class (and method) be on its own line, but in this case I do think that should require it be on its own line for multi-line implements as it is much easier to read when:
you have multiple interfaces implemented
you use traits
you have an undocumented method (allowed) in the beginning of the class
For example, in the following example where a single interface is implemented and the class use a trait, it's quite hard to spot easily where the class starts.
class after_user_passed_mfa implements
\Psr\EventDispatcher\StoppableEventInterface {
use \core\hook\stoppable_trait;
}
At the moment, using the PSR-12 style will give the message:
Moodle's coding style does not actively state anything regarding the location of the opening brace when there are multiple implemnts but we previously conventioned the following:
However, PSR-12 states:
That is, the following is accepted:
This is slightly conflated by the fact that PSR-12 requires that the opening brace for a class (and method) be on its own line, but in this case I do think that should require it be on its own line for multi-line implements as it is much easier to read when:
For example, in the following example where a single interface is implemented and the class use a trait, it's quite hard to spot easily where the class starts.
At the moment, using the PSR-12 style will give the message:
The text was updated successfully, but these errors were encountered: