Skip to content
This repository was archived by the owner on Nov 21, 2019. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/Libero/ruleset.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
<rule ref="SlevomatCodingStandard.Classes.SuperfluousAbstractClassNaming"/>
<rule ref="SlevomatCodingStandard.Classes.SuperfluousExceptionNaming"/>
<rule ref="SlevomatCodingStandard.Classes.SuperfluousInterfaceNaming"/>
<rule ref="SlevomatCodingStandard.ControlStructures.LanguageConstructWithParentheses"/>
<rule ref="SlevomatCodingStandard.ControlStructures.NewWithParentheses"/>
<rule ref="SlevomatCodingStandard.ControlStructures.RequireNullCoalesceOperator"/>
<rule ref="SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses"/>
<rule ref="SlevomatCodingStandard.Namespaces.ReferenceUsedNamesOnly">
Expand All @@ -47,6 +49,11 @@
<rule ref="SlevomatCodingStandard.Operators.RequireCombinedAssignmentOperator"/>
<rule ref="SlevomatCodingStandard.PHP.ShortList"/>
<rule ref="SlevomatCodingStandard.PHP.TypeCast"/>
<rule ref="SlevomatCodingStandard.PHP.UselessParentheses">
<properties>
<property name="ignoreComplexTernaryConditions" value="true"/>
</properties>
</rule>
<rule ref="SlevomatCodingStandard.TypeHints.DeclareStrictTypes">
<properties>
<property name="newlinesCountAfterDeclare" value="2"/>
Expand Down
43 changes: 43 additions & 0 deletions tests/cases/php/parentheses
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
---DESCRIPTION---
Language constructs must be used without parentheses
---CONTENTS---
<?php

declare(strict_types=1);

require('foo.php');

echo('bar');

foreach ([] as $value) {
break (1);
}

$baz = function () {
yield('baz');
return('qux');
};

die();

---FIXED---
<?php

declare(strict_types=1);

require 'foo.php';

echo 'bar';

foreach ([] as $value) {
break 1;
}

$baz = function () {
yield 'baz';
return 'qux';
};

die;

---
17 changes: 17 additions & 0 deletions tests/cases/php/parentheses-new
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---DESCRIPTION---
New instances must use parentheses
---CONTENTS---
<?php

declare(strict_types=1);

new Foo;

---FIXED---
<?php

declare(strict_types=1);

new Foo();

---
35 changes: 35 additions & 0 deletions tests/cases/php/parentheses-useless
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---DESCRIPTION---
Parentheses must not be used unnecessarily
---CONTENTS---
<?php

declare(strict_types=1);

$foo = ('bar');
$baz = ($qux !== null) ? true : false;
$quux = ($quuz) ? 1 : 0;
$corge = (true || false) ? 0 : 1;

switch ($grault) {
case (true):
case (false):
return $garply / (100 + $waldo);
}

---FIXED---
<?php

declare(strict_types=1);

$foo = 'bar';
$baz = $qux !== null ? true : false;
$quux = $quuz ? 1 : 0;
$corge = (true || false) ? 0 : 1;

switch ($grault) {
case true:
case false:
return $garply / (100 + $waldo);
}

---