Skip to content
This repository has been archived by the owner on Nov 21, 2019. It is now read-only.

Commit

Permalink
Prefer single-quoted strings (#31)
Browse files Browse the repository at this point in the history
* Prefer single-quoted strings

* Update quotes
  • Loading branch information
thewilkybarkid authored Nov 15, 2018
1 parent dfd523a commit 0bba285
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/Libero/ruleset.xml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@
</rule>
<rule ref="Squiz.Classes.ClassFileName"/>
<rule ref="Squiz.PHP.InnerFunctions"/>
<rule ref="Squiz.Strings.DoubleQuoteUsage">
<exclude name="Squiz.Strings.DoubleQuoteUsage.ContainsVar"/>
</rule>
<rule ref="Squiz.WhiteSpace.CastSpacing"/>
<rule ref="Squiz.WhiteSpace.ObjectOperatorSpacing">
<properties>
Expand Down
2 changes: 1 addition & 1 deletion tests/RulesetTests.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public function cases() : iterable
if (empty($parts['contents'])) {
throw new LogicException("Couldn't find contents in {$file->getRelativePathname()}");
} elseif (empty(select_keys($parts, $keys))) {
throw new LogicException("Expected one of ".implode(', ', $keys)." in {$file->getRelativePathname()}");
throw new LogicException('Expected one of '.implode(', ', $keys)." in {$file->getRelativePathname()}");
}

try {
Expand Down
23 changes: 23 additions & 0 deletions tests/cases/php/string-quotes
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---DESCRIPTION---
Double quotes must not be used for strings unless required
---CONTENTS---
<?php

declare(strict_types=1);

$foo = "bar";
$baz = "qux {$quux}";
$quuz = "'";
$corge = "\n";

---FIXED---
<?php

declare(strict_types=1);

$foo = 'bar';
$baz = "qux {$quux}";
$quuz = "'";
$corge = "\n";

---

0 comments on commit 0bba285

Please sign in to comment.