Agreed! When does *more* than one space (aside from newlines) ever make
sense? i hope these details get resolved...
-jlt
On Sunday, 22 April 2018 20:08:00 UTC-4, Greg Sherwood wrote:
>
> Hi,
>
> I'm working on the PSR-12 standard for PHP_CodeSniffer. I have a question
> about this section:
>
> 6. Operators
>> All binary and ternary (but not unary) operators MUST be preceded and
>> followed by at least one space. This includes all arithmetic, comparison,
>> assignment, bitwise, logical (excluding ! which is unary), string
>> concatenation, type operators, trait operators (insteadof and as), and the
>> single pipe operator (e.g. ExceptionType1 | ExceptionType2 $e).
>
>
> I think it is pretty clear that operators can be surrounded by however
> many spaces and newlines that the developer wants, and I've coded a check
> to enforce this, but it seems like it would lead to inconsistent code. So I
> just wanted to check and make sure the following code snippet should be
> considered valid under PSR-12:
>
> <?php
>> if ($a === $b) {
>> $foo = $bar ?? $a ?? $b;
>> } elseif ($a > $b) {
>> $variable = $foo ? 'foo' : 'bar';
>> }
>
>
> I'm obviously exaggerating the spacing, but the main thing I'm getting at
> is that it seems like code can have different padding on either side of an
> operator, and different padding can be used throughout the file, as long as
> some form of padding is used (at least 1 space). This seems to go against
> what a coding standard is trying to achieve, which is a level of
> consistency throughout the source code of a project.
>
> If this is not the intention, I'd suggest standardising on a rule that
> says that operators must be surrounded by exactly 1 space OR a newline. If
> a newline is being used, no further checks are performed i.e., the
> developer can use as many spaces as they want for indentation as long as
> they remain inside the rest of PSR_12's rules.
>
> Thanks
>
--
You received this message because you are subscribed to the Google Groups "PHP
Framework Interoperability Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/php-fig/6ea3c2e7-2f2b-4c86-9535-8b10319b40e4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.