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
3 changes: 3 additions & 0 deletions src/Libero/ruleset.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<exclude name="PSR2.Namespaces.UseDeclaration.SpaceAfterLastUse"/>
</rule>

<rule ref="Generic.Formatting.SpaceAfterCast"/>
<rule ref="Generic.PHP.BacktickOperator"/>
<rule ref="Generic.PHP.LowerCaseType"/>
<rule ref="PEAR.WhiteSpace.ObjectOperatorIndent"/>
Expand Down Expand Up @@ -42,6 +43,7 @@
<rule ref="SlevomatCodingStandard.Namespaces.UseDoesNotStartWithBackslash"/>
<rule ref="SlevomatCodingStandard.Namespaces.UseFromSameNamespace"/>
<rule ref="SlevomatCodingStandard.Namespaces.UseSpacing"/>
<rule ref="SlevomatCodingStandard.PHP.TypeCast"/>
<rule ref="SlevomatCodingStandard.TypeHints.DeclareStrictTypes">
<properties>
<property name="newlinesCountAfterDeclare" value="2"/>
Expand All @@ -58,6 +60,7 @@
</rule>
<rule ref="Squiz.Classes.ClassFileName"/>
<rule ref="Squiz.PHP.InnerFunctions"/>
<rule ref="Squiz.WhiteSpace.CastSpacing"/>
<rule ref="Squiz.WhiteSpace.ObjectOperatorSpacing">
<properties>
<property name="ignoreNewlines" value="true"/>
Expand Down
21 changes: 21 additions & 0 deletions tests/cases/php/type-cast-long
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---DESCRIPTION---
Shorthand cast operators must be used
---CONTENTS---
<?php

declare(strict_types=1);

$foo = (boolean) $foo;
$bar = (integer) $bar;
$baz = (double) $baz;

---FIXED---
<?php

declare(strict_types=1);

$foo = (bool) $foo;
$bar = (int) $bar;
$baz = (float) $baz;

---
25 changes: 25 additions & 0 deletions tests/cases/whitespace/type-cast
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---DESCRIPTION---
Single space after type casting and none inside
---CONTENTS---
<?php

declare(strict_types=1);

$foo = (bool)$foo;
$bar = ( int ) $bar;
$baz = ( float)
$baz;
$qux = (bool)(int) (float)
(string)$qux;

---FIXED---
<?php

declare(strict_types=1);

$foo = (bool) $foo;
$bar = (int) $bar;
$baz = (float) $baz;
$qux = (bool) (int) (float) (string) $qux;

---