Skip to content

Commit fb88c73

Browse files
committed
Converted double to single quotes in simple strings
1 parent 5da0bcb commit fb88c73

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+428
-426
lines changed

.php_cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ return PhpCsFixer\Config::create()
66
'array_syntax' => ['syntax' => 'short'],
77
'blank_line_after_opening_tag' => true,
88
'single_blank_line_before_namespace' => true,
9-
'no_unused_imports' => true
9+
'no_unused_imports' => true,
10+
'single_quote' => true
1011
])
1112
->setFinder(
1213
PhpCsFixer\Finder::create()

README.md

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@
44

55
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/coduo/php-matcher/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/coduo/php-matcher/?branch=master)
66

7-
* [![Build Status](https://travis-ci.org/coduo/php-matcher.svg)](https://travis-ci.org/coduo/php-matcher) - master (3.0.*)
7+
* [![Build Status](https://travis-ci.org/coduo/php-matcher.svg)](https://travis-ci.org/coduo/php-matcher) - master (3.1.*)
8+
* [![Build Status](https://travis-ci.org/coduo/php-matcher.svg?branch=3.0)](https://travis-ci.org/coduo/php-matcher) - 3.0.*
89
* [![Build Status](https://travis-ci.org/coduo/php-matcher.svg?branch=2.2)](https://travis-ci.org/coduo/php-matcher) - 2.2.*
910
* [![Build Status](https://travis-ci.org/coduo/php-matcher.svg?branch=2.1)](https://travis-ci.org/coduo/php-matcher) - 2.1.*
1011
* [![Build Status](https://travis-ci.org/coduo/php-matcher.svg?branch=2.0)](https://travis-ci.org/coduo/php-matcher) - 2.0.*
1112

12-
[Readme for master (3.0) version](https://github.com/coduo/php-matcher/tree/master/README.md)
13+
[Readme for master (3.1) version](https://github.com/coduo/php-matcher/tree/master/README.md)
14+
[Readme for 3.0 version](https://github.com/coduo/php-matcher/tree/3.0/README.md)
1315
[Readme for 2.2 version](https://github.com/coduo/php-matcher/tree/2.2/README.md)
1416
[Readme for 2.1 version](https://github.com/coduo/php-matcher/tree/2.1/README.md)
1517
[Readme for 2.0 version](https://github.com/coduo/php-matcher/tree/2.0/README.md)
@@ -100,7 +102,7 @@ $factory = new SimpleFactory();
100102
$matcher = $factory->createMatcher();
101103

102104
$matcher->match(1, 1);
103-
$matcher->match('string', 'string')
105+
$matcher->match('string', 'string');
104106
```
105107

106108
### String matching
@@ -114,7 +116,7 @@ $factory = new SimpleFactory();
114116
$matcher = $factory->createMatcher();
115117

116118
$matcher->match('Norbert', '@string@');
117-
$matcher->match("lorem ipsum dolor", "@[email protected]('lorem').contains('ipsum').endsWith('dolor')")
119+
$matcher->match("lorem ipsum dolor", "@[email protected]('lorem').contains('ipsum').endsWith('dolor')");
118120

119121
```
120122

@@ -188,12 +190,12 @@ use Coduo\PHPMatcher\Factory\SimpleFactory;
188190
$factory = new SimpleFactory();
189191
$matcher = $factory->createMatcher();
190192

191-
$matcher->match("@integer@", "@*@"),
192-
$matcher->match("foobar", "@*@"),
193-
$matcher->match(true, "@*@"),
194-
$matcher->match(6.66, "@*@"),
195-
$matcher->match(array("bar"), "@wildcard@"),
196-
$matcher->match(new \stdClass, "@wildcard@"),
193+
$matcher->match("@integer@", "@*@");
194+
$matcher->match("foobar", "@*@");
195+
$matcher->match(true, "@*@");
196+
$matcher->match(6.66, "@*@");
197+
$matcher->match(array("bar"), "@wildcard@");
198+
$matcher->match(new \stdClass, "@wildcard@");
197199
```
198200

199201
### Expression matching
@@ -279,7 +281,7 @@ $matcher->match(
279281
'@boolean@',
280282
'@double@'
281283
)
282-
)
284+
);
283285
```
284286

285287
### Json matching
@@ -313,8 +315,7 @@ $matcher->match(
313315
}
314316
]
315317
}'
316-
)
317-
318+
);
318319
```
319320

320321
### Xml matching

src/Exception/UnknownTypeException.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ class UnknownTypeException extends Exception
1010

1111
public function __construct(string $type)
1212
{
13-
$this->type = "@" . $type . "@";
14-
parent::__construct(sprintf("Type pattern \"%s\" is not supported.", $this->type), 0, null);
13+
$this->type = '@' . $type . '@';
14+
parent::__construct(sprintf('Type pattern "%s" is not supported.', $this->type), 0, null);
1515
}
1616

1717
public function getType() : string

src/Lexer.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@ final class Lexer extends AbstractLexer
2727
protected function getCatchablePatterns() : array
2828
{
2929
return [
30-
"\\.?[a-zA-Z0-9_]+\\(", // expander name
31-
"[a-zA-Z0-9.]*", // words
32-
"\\-?[0-9]*\\.?[0-9]*", // numbers
30+
'\\.?[a-zA-Z0-9_]+\\(', // expander name
31+
'[a-zA-Z0-9.]*', // words
32+
'\\-?[0-9]*\\.?[0-9]*', // numbers
3333
"'(?:[^']|'')*'", // string between ' character
34-
"\"(?:[^\"]|\"\")*\"", // string between " character,
35-
"@[a-zA-Z0-9\\*]+@", // type pattern
34+
'"(?:[^"]|"")*"', // string between " character,
35+
'@[a-zA-Z0-9\\*]+@', // type pattern
3636
];
3737
}
3838

@@ -42,7 +42,7 @@ protected function getCatchablePatterns() : array
4242
protected function getNonCatchablePatterns() : array
4343
{
4444
return [
45-
"\\s+",
45+
'\\s+',
4646
];
4747
}
4848

@@ -107,7 +107,7 @@ protected function getType(&$value) : int
107107

108108
protected function isStringToken(string $value) : bool
109109
{
110-
return in_array(substr($value, 0, 1), ["\"", "'"]);
110+
return in_array(substr($value, 0, 1), ['"', "'"]);
111111
}
112112

113113
protected function isBooleanToken(string $value) : bool

src/Matcher/ArrayMatcher.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public function match($value, $pattern) : bool
3535
}
3636

3737
if (!is_array($value)) {
38-
$this->error = sprintf("%s \"%s\" is not a valid array.", gettype($value), new StringConverter($value));
38+
$this->error = sprintf('%s "%s" is not a valid array.', gettype($value), new StringConverter($value));
3939
return false;
4040
}
4141

@@ -64,7 +64,7 @@ private function isArrayPattern($pattern) : bool
6464
return $this->parser->hasValidSyntax($pattern) && $this->parser->parse($pattern)->is(self::PATTERN);
6565
}
6666

67-
private function iterateMatch(array $values, array $patterns, string $parentPath = "") : bool
67+
private function iterateMatch(array $values, array $patterns, string $parentPath = '') : bool
6868
{
6969
$pattern = null;
7070
foreach ($values as $key => $value) {
@@ -222,12 +222,12 @@ private function setMissingElementInError(string $place, string $path)
222222

223223
private function formatAccessPath($key) : string
224224
{
225-
return sprintf("[%s]", $key);
225+
return sprintf('[%s]', $key);
226226
}
227227

228228
private function formatFullPath(string $parentPath, string $path) : string
229229
{
230-
return sprintf("%s%s", $parentPath, $path);
230+
return sprintf('%s%s', $parentPath, $path);
231231
}
232232

233233
private function shouldSkippValueMatchingFor($lastPattern) : bool

src/Matcher/BooleanMatcher.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public function __construct(Parser $parser)
2121
public function match($value, $pattern) : bool
2222
{
2323
if (!is_bool($value)) {
24-
$this->error = sprintf("%s \"%s\" is not a valid boolean.", gettype($value), new StringConverter($value));
24+
$this->error = sprintf('%s "%s" is not a valid boolean.', gettype($value), new StringConverter($value));
2525
return false;
2626
}
2727

src/Matcher/DoubleMatcher.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public function __construct(Parser $parser)
2121
public function match($value, $pattern) : bool
2222
{
2323
if (!is_double($value)) {
24-
$this->error = sprintf("%s \"%s\" is not a valid double.", gettype($value), new StringConverter($value));
24+
$this->error = sprintf('%s "%s" is not a valid double.', gettype($value), new StringConverter($value));
2525
return false;
2626
}
2727

src/Matcher/ExpressionMatcher.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public function match($value, $pattern) : bool
1818
$expressionResult = $language->evaluate($matches[1], ['value' => $value]);
1919

2020
if (!$expressionResult) {
21-
$this->error = sprintf("\"%s\" expression fails for value \"%s\".", $pattern, new StringConverter($value));
21+
$this->error = sprintf('"%s" expression fails for value "%s".', $pattern, new StringConverter($value));
2222
}
2323

2424
return (bool) $expressionResult;

src/Matcher/IntegerMatcher.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public function __construct(Parser $parser)
2121
public function match($value, $pattern) : bool
2222
{
2323
if (!is_integer($value)) {
24-
$this->error = sprintf("%s \"%s\" is not a valid integer.", gettype($value), new StringConverter($value));
24+
$this->error = sprintf('%s "%s" is not a valid integer.', gettype($value), new StringConverter($value));
2525
return false;
2626
}
2727

src/Matcher/JsonMatcher.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ public function match($value, $pattern) : bool
2222
}
2323

2424
if (!Json::isValid($value)) {
25-
$this->error = sprintf("Invalid given JSON of value. %s", $this->getErrorMessage());
25+
$this->error = sprintf('Invalid given JSON of value. %s', $this->getErrorMessage());
2626
return false;
2727
}
2828

2929
if (!Json::isValidPattern($pattern)) {
30-
$this->error = sprintf("Invalid given JSON of pattern. %s", $this->getErrorMessage());
30+
$this->error = sprintf('Invalid given JSON of pattern. %s', $this->getErrorMessage());
3131
return false;
3232
}
3333

src/Matcher/NullMatcher.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@
88

99
final class NullMatcher extends Matcher
1010
{
11-
const MATCH_PATTERN = "/^@null@$/";
11+
const MATCH_PATTERN = '/^@null@$/';
1212

1313
/**
1414
* {@inheritDoc}
1515
*/
1616
public function match($value, $pattern) : bool
1717
{
1818
if (null !== $value) {
19-
$this->error = sprintf("%s \"%s\" does not match null.", gettype($value), new StringConverter($value));
19+
$this->error = sprintf('%s "%s" does not match null.', gettype($value), new StringConverter($value));
2020
return false;
2121
}
2222

src/Matcher/NumberMatcher.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public function __construct(Parser $parser)
2121
public function match($value, $pattern) : bool
2222
{
2323
if (!is_numeric($value)) {
24-
$this->error = sprintf("%s \"%s\" is not a valid number.", gettype($value), new StringConverter($value));
24+
$this->error = sprintf('%s "%s" is not a valid number.', gettype($value), new StringConverter($value));
2525
return false;
2626
}
2727

src/Matcher/Pattern/Expander/Contains.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function __construct(string $string, $ignoreCase = false)
4343
public function match($value) : bool
4444
{
4545
if (!is_string($value)) {
46-
$this->error = sprintf("Contains expander require \"string\", got \"%s\".", new StringConverter($value));
46+
$this->error = sprintf('Contains expander require "string", got "%s".', new StringConverter($value));
4747
return false;
4848
}
4949

src/Matcher/Pattern/Expander/Count.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@ public function __construct(int $value)
2828
public function match($value) :bool
2929
{
3030
if (!is_array($value)) {
31-
$this->error = sprintf("Count expander require \"array\", got \"%s\".", new StringConverter($value));
31+
$this->error = sprintf('Count expander require "array", got "%s".', new StringConverter($value));
3232
return false;
3333
}
3434

3535
if (count($value) !== $this->value) {
36-
$this->error = sprintf("Expected count of %s is %s.", new StringConverter($value), new StringConverter($this->value));
36+
$this->error = sprintf('Expected count of %s is %s.', new StringConverter($value), new StringConverter($this->value));
3737
return false;
3838
}
3939

src/Matcher/Pattern/Expander/EndsWith.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ final class EndsWith implements PatternExpander
2020
public function __construct(string $stringEnding, bool $ignoreCase = false)
2121
{
2222
if (!is_string($stringEnding)) {
23-
throw new \InvalidArgumentException("String ending must be a valid string.");
23+
throw new \InvalidArgumentException('String ending must be a valid string.');
2424
}
2525

2626
$this->stringEnding = $stringEnding;
@@ -35,7 +35,7 @@ public static function is(string $name) : bool
3535
public function match($value) : bool
3636
{
3737
if (!is_string($value)) {
38-
$this->error = sprintf("EndsWith expander require \"string\", got \"%s\".", new StringConverter($value));
38+
$this->error = sprintf('EndsWith expander require "string", got "%s".', new StringConverter($value));
3939
return false;
4040
}
4141

src/Matcher/Pattern/Expander/GreaterThan.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ final class GreaterThan implements PatternExpander
1818
public function __construct($boundary)
1919
{
2020
if (!is_float($boundary) && !is_int($boundary)) {
21-
throw new \InvalidArgumentException(sprintf("Boundary value \"%s\" is not a valid number.", new StringConverter($boundary)));
21+
throw new \InvalidArgumentException(sprintf('Boundary value "%s" is not a valid number.', new StringConverter($boundary)));
2222
}
2323

2424
$this->boundary = $boundary;
@@ -32,12 +32,12 @@ public static function is(string $name) : bool
3232
public function match($value) : bool
3333
{
3434
if (!is_float($value) && !is_int($value) && !is_numeric($value)) {
35-
$this->error = sprintf("Value \"%s\" is not a valid number.", new StringConverter($value));
35+
$this->error = sprintf('Value "%s" is not a valid number.', new StringConverter($value));
3636
return false;
3737
}
3838

3939
if ($value <= $this->boundary) {
40-
$this->error = sprintf("Value \"%s\" is not greater than \"%s\".", new StringConverter($value), new StringConverter($this->boundary));
40+
$this->error = sprintf('Value "%s" is not greater than "%s".', new StringConverter($value), new StringConverter($this->boundary));
4141
return false;
4242
}
4343

src/Matcher/Pattern/Expander/InArray.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public static function is(string $name) : bool
2828
public function match($value) : bool
2929
{
3030
if (!is_array($value)) {
31-
$this->error = sprintf("InArray expander require \"array\", got \"%s\".", new StringConverter($value));
31+
$this->error = sprintf('InArray expander require "array", got "%s".', new StringConverter($value));
3232
return false;
3333
}
3434

src/Matcher/Pattern/Expander/IsDateTime.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ public static function is(string $name) : bool
2121
public function match($value) : bool
2222
{
2323
if (false === is_string($value)) {
24-
$this->error = sprintf("IsDateTime expander require \"string\", got \"%s\".", new StringConverter($value));
24+
$this->error = sprintf('IsDateTime expander require "string", got "%s".', new StringConverter($value));
2525
return false;
2626
}
2727

2828
if (false === $this->matchValue($value)) {
29-
$this->error = sprintf("string \"%s\" is not a valid date.", $value);
29+
$this->error = sprintf('string "%s" is not a valid date.', $value);
3030
return false;
3131
}
3232

src/Matcher/Pattern/Expander/IsEmail.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ public static function is(string $name) : bool
2121
public function match($value) : bool
2222
{
2323
if (false === is_string($value)) {
24-
$this->error = sprintf("IsEmail expander require \"string\", got \"%s\".", new StringConverter($value));
24+
$this->error = sprintf('IsEmail expander require "string", got "%s".', new StringConverter($value));
2525
return false;
2626
}
2727

2828
if (false === $this->matchValue($value)) {
29-
$this->error = sprintf("string \"%s\" is not a valid e-mail address.", $value);
29+
$this->error = sprintf('string "%s" is not a valid e-mail address.', $value);
3030
return false;
3131
}
3232

src/Matcher/Pattern/Expander/IsEmpty.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public static function is(string $name) : bool
2121
public function match($value) : bool
2222
{
2323
if (!empty($value)) {
24-
$this->error = sprintf("Value %s is not empty.", new StringConverter($value));
24+
$this->error = sprintf('Value %s is not empty.', new StringConverter($value));
2525

2626
return false;
2727
}

src/Matcher/Pattern/Expander/IsNotEmpty.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public static function is(string $name) : bool
2121
public function match($value) : bool
2222
{
2323
if (false === $value || (empty($value) && '0' != $value)) {
24-
$this->error = sprintf("Value %s is not blank.", new StringConverter($value));
24+
$this->error = sprintf('Value %s is not blank.', new StringConverter($value));
2525
return false;
2626
}
2727

src/Matcher/Pattern/Expander/IsUrl.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ public static function is(string $name) : bool
2121
public function match($value) : bool
2222
{
2323
if (false === is_string($value)) {
24-
$this->error = sprintf("IsUrl expander require \"string\", got \"%s\".", new StringConverter($value));
24+
$this->error = sprintf('IsUrl expander require "string", got "%s".', new StringConverter($value));
2525
return false;
2626
}
2727

2828
if (false === $this->matchValue($value)) {
29-
$this->error = sprintf("string \"%s\" is not a valid URL.", $value);
29+
$this->error = sprintf('string "%s" is not a valid URL.', $value);
3030
return false;
3131
}
3232

0 commit comments

Comments
 (0)