The Drupal.Formatting.SpaceUnaryOperator.IncDecRight sniffer can cause syntax error.
Checking a php file with the following content will result in this validation error for the two lines using post increment and post decrement: "A unary operator statement must not be followed by a single space"
<?php
namespace Test;
/**
* Class Test.
*/
class Test {
private $prop = 0;
/**
* Test constructor.
*/
public function __construct() {
$this->prop++;
$this->prop--;
--$this->prop;
++$this->prop;
}
}
It's even worse, that the fixer "fixes" these violations by removing the ; and the new line character after.
Running the fixer results this file:
<?php
namespace Test;
/**
* Class Test.
*/
class Test {
private $prop = 0;
/**
* Test constructor.
*/
public function __construct() {
$this->prop++$this->prop--$this->prop;
++$this->prop;
}
}
Comments
Comment #2
smatyas commentedComment #4
klausiCommitted a fix, thanks for reporting!
Comment #5
smatyas commentedThanks for the fix @klausi just one question: doesn't this repo use auto-update for the packagest package? It seems to be out of sync. The current version for 8.x-2.x shows the hash 363f5ab269b0f93e4f3ffbb2e369b055a017b2bd from 2015-11-08 21:22 UTC - https://packagist.org/packages/drupal/coder#dev-8.x-2.x
git status sais there are 14 commits since (including this one):
vendor/drupal/coder (8.x-2.x) $ git status
On branch 8.x-2.x
Your branch is behind 'origin/8.x-2.x' by 14 commits, and can be fast-forwarded.