PER explicitly requires a single space around the => symbol in two sections:
Section 7.1 (Short Closures):
The => symbol MUST be preceded and succeeded by a space.
Section 4.9 (Property Hooks):
There MUST be a single space on either side of the => symbol.
The same operator is used in other constructs, but as far as I could check the spec does not state the spacing around it explicitly for them. Arrays (section 11), match (section 5.2) and foreach (section 5.5) only show a single space in their examples. There might be other places where => is used, but I haven't checked them all.
Is there a reason the rule is stated only for short closures and property hooks that I'm missing, or would it make sense to state it as a general rule so that it applies consistently to every use of =>? If there is a reason not to create a general rule, should it be added to the array, match and foreach sections?
PER explicitly requires a single space around the
=>symbol in two sections:Section 7.1 (Short Closures):
Section 4.9 (Property Hooks):
The same operator is used in other constructs, but as far as I could check the spec does not state the spacing around it explicitly for them. Arrays (section 11),
match(section 5.2) andforeach(section 5.5) only show a single space in their examples. There might be other places where=>is used, but I haven't checked them all.Is there a reason the rule is stated only for short closures and property hooks that I'm missing, or would it make sense to state it as a general rule so that it applies consistently to every use of
=>? If there is a reason not to create a general rule, should it be added to thearray,matchandforeachsections?