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 1 commit
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.LowerCaseType"/>
<rule ref="PEAR.WhiteSpace.ObjectOperatorIndent"/>
<rule ref="SlevomatCodingStandard.Classes.ClassConstantVisibility">
Expand Down Expand Up @@ -40,6 +41,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 @@ -54,6 +56,7 @@
</properties>
</rule>
<rule ref="Squiz.Classes.ClassFileName"/>
<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;

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

declare(strict_types=1);

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

---FIXED---
<?php

declare(strict_types=1);

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

---