From PSR-12: https://github.com/php-fig/fig-standards/blob/master/proposed/extended-coding-style-guide.md#41-extends-and-implements
class ClassName extends ParentClass implements
\ArrayAccess,
\Countable,
\Serializable
{
// constants, properties, methods
}
vs
class ClassName
extends ParentClass
implements \ArrayAccess, \Countable, \Serializable
{
// constants, properties, methods
}
In php __ONLY__ one class maybe extends. Vote welcome.
Lists of implements and 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.
Funny that PSR-12 speaks of "lists of extends" when there can be only one. I'd opt for the first style as because both styles look fine but the first seems to be preferred by PSR-12.
Should we consider preferring option 1 but breaking to option 2 if we hit the line length limit?
Sounds good! That would probably mean that the "worst case" looks like this, right?
class ClassNameLoooooooooooooooooooooooooooooooooong
extends ParentClassLoooooooooooooooooooooooooooooooooong
implements
\ArrayAccessLooooooooooooooooooong,
\CountableLooooooooooooooooooong,
\SerializableLooooooooooooooooooong
{
// constants, properties, methods
}
@mgrip @czosel how about open issue for https://github.com/php-fig/fig-standards about this. I am confused about this. Because extends class may have very long value and PSR-12 output is ugly
@mgrip also i agree maybe better by default 1. If line over limit use 2 :+1:
Not fixed fully
Most helpful comment
Sounds good! That would probably mean that the "worst case" looks like this, right?