Skip to content

Commit

Permalink
Converted double to single quotes in simple strings
Browse files Browse the repository at this point in the history
  • Loading branch information
norberttech committed Feb 4, 2018
1 parent 5da0bcb commit fb88c73
Show file tree
Hide file tree
Showing 66 changed files with 428 additions and 426 deletions.
3 changes: 2 additions & 1 deletion .php_cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ return PhpCsFixer\Config::create()
'array_syntax' => ['syntax' => 'short'],
'blank_line_after_opening_tag' => true,
'single_blank_line_before_namespace' => true,
'no_unused_imports' => true
'no_unused_imports' => true,
'single_quote' => true
])
->setFinder(
PhpCsFixer\Finder::create()
Expand Down
27 changes: 14 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@

[![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)

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

[Readme for master (3.0) version](https://github.com/coduo/php-matcher/tree/master/README.md)
[Readme for master (3.1) version](https://github.com/coduo/php-matcher/tree/master/README.md)
[Readme for 3.0 version](https://github.com/coduo/php-matcher/tree/3.0/README.md)
[Readme for 2.2 version](https://github.com/coduo/php-matcher/tree/2.2/README.md)
[Readme for 2.1 version](https://github.com/coduo/php-matcher/tree/2.1/README.md)
[Readme for 2.0 version](https://github.com/coduo/php-matcher/tree/2.0/README.md)
Expand Down Expand Up @@ -100,7 +102,7 @@ $factory = new SimpleFactory();
$matcher = $factory->createMatcher();

$matcher->match(1, 1);
$matcher->match('string', 'string')
$matcher->match('string', 'string');
```

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

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

```

Expand Down Expand Up @@ -188,12 +190,12 @@ use Coduo\PHPMatcher\Factory\SimpleFactory;
$factory = new SimpleFactory();
$matcher = $factory->createMatcher();

$matcher->match("@integer@", "@*@"),
$matcher->match("foobar", "@*@"),
$matcher->match(true, "@*@"),
$matcher->match(6.66, "@*@"),
$matcher->match(array("bar"), "@wildcard@"),
$matcher->match(new \stdClass, "@wildcard@"),
$matcher->match("@integer@", "@*@");
$matcher->match("foobar", "@*@");
$matcher->match(true, "@*@");
$matcher->match(6.66, "@*@");
$matcher->match(array("bar"), "@wildcard@");
$matcher->match(new \stdClass, "@wildcard@");
```

### Expression matching
Expand Down Expand Up @@ -279,7 +281,7 @@ $matcher->match(
'@boolean@',
'@double@'
)
)
);
```

### Json matching
Expand Down Expand Up @@ -313,8 +315,7 @@ $matcher->match(
}
]
}'
)

);
```

### Xml matching
Expand Down
4 changes: 2 additions & 2 deletions src/Exception/UnknownTypeException.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ class UnknownTypeException extends Exception

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

public function getType() : string
Expand Down
14 changes: 7 additions & 7 deletions src/Lexer.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ final class Lexer extends AbstractLexer
protected function getCatchablePatterns() : array
{
return [
"\\.?[a-zA-Z0-9_]+\\(", // expander name
"[a-zA-Z0-9.]*", // words
"\\-?[0-9]*\\.?[0-9]*", // numbers
'\\.?[a-zA-Z0-9_]+\\(', // expander name
'[a-zA-Z0-9.]*', // words
'\\-?[0-9]*\\.?[0-9]*', // numbers
"'(?:[^']|'')*'", // string between ' character
"\"(?:[^\"]|\"\")*\"", // string between " character,
"@[a-zA-Z0-9\\*]+@", // type pattern
'"(?:[^"]|"")*"', // string between " character,
'@[a-zA-Z0-9\\*]+@', // type pattern
];
}

Expand All @@ -42,7 +42,7 @@ protected function getCatchablePatterns() : array
protected function getNonCatchablePatterns() : array
{
return [
"\\s+",
'\\s+',
];
}

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

protected function isStringToken(string $value) : bool
{
return in_array(substr($value, 0, 1), ["\"", "'"]);
return in_array(substr($value, 0, 1), ['"', "'"]);
}

protected function isBooleanToken(string $value) : bool
Expand Down
8 changes: 4 additions & 4 deletions src/Matcher/ArrayMatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function match($value, $pattern) : bool
}

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

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

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

private function formatAccessPath($key) : string
{
return sprintf("[%s]", $key);
return sprintf('[%s]', $key);
}

private function formatFullPath(string $parentPath, string $path) : string
{
return sprintf("%s%s", $parentPath, $path);
return sprintf('%s%s', $parentPath, $path);
}

private function shouldSkippValueMatchingFor($lastPattern) : bool
Expand Down
2 changes: 1 addition & 1 deletion src/Matcher/BooleanMatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function __construct(Parser $parser)
public function match($value, $pattern) : bool
{
if (!is_bool($value)) {
$this->error = sprintf("%s \"%s\" is not a valid boolean.", gettype($value), new StringConverter($value));
$this->error = sprintf('%s "%s" is not a valid boolean.', gettype($value), new StringConverter($value));
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Matcher/DoubleMatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function __construct(Parser $parser)
public function match($value, $pattern) : bool
{
if (!is_double($value)) {
$this->error = sprintf("%s \"%s\" is not a valid double.", gettype($value), new StringConverter($value));
$this->error = sprintf('%s "%s" is not a valid double.', gettype($value), new StringConverter($value));
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Matcher/ExpressionMatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public function match($value, $pattern) : bool
$expressionResult = $language->evaluate($matches[1], ['value' => $value]);

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

return (bool) $expressionResult;
Expand Down
2 changes: 1 addition & 1 deletion src/Matcher/IntegerMatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function __construct(Parser $parser)
public function match($value, $pattern) : bool
{
if (!is_integer($value)) {
$this->error = sprintf("%s \"%s\" is not a valid integer.", gettype($value), new StringConverter($value));
$this->error = sprintf('%s "%s" is not a valid integer.', gettype($value), new StringConverter($value));
return false;
}

Expand Down
4 changes: 2 additions & 2 deletions src/Matcher/JsonMatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ public function match($value, $pattern) : bool
}

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

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

Expand Down
4 changes: 2 additions & 2 deletions src/Matcher/NullMatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@

final class NullMatcher extends Matcher
{
const MATCH_PATTERN = "/^@null@$/";
const MATCH_PATTERN = '/^@null@$/';

/**
* {@inheritDoc}
*/
public function match($value, $pattern) : bool
{
if (null !== $value) {
$this->error = sprintf("%s \"%s\" does not match null.", gettype($value), new StringConverter($value));
$this->error = sprintf('%s "%s" does not match null.', gettype($value), new StringConverter($value));
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Matcher/NumberMatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function __construct(Parser $parser)
public function match($value, $pattern) : bool
{
if (!is_numeric($value)) {
$this->error = sprintf("%s \"%s\" is not a valid number.", gettype($value), new StringConverter($value));
$this->error = sprintf('%s "%s" is not a valid number.', gettype($value), new StringConverter($value));
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Matcher/Pattern/Expander/Contains.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function __construct(string $string, $ignoreCase = false)
public function match($value) : bool
{
if (!is_string($value)) {
$this->error = sprintf("Contains expander require \"string\", got \"%s\".", new StringConverter($value));
$this->error = sprintf('Contains expander require "string", got "%s".', new StringConverter($value));
return false;
}

Expand Down
4 changes: 2 additions & 2 deletions src/Matcher/Pattern/Expander/Count.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ public function __construct(int $value)
public function match($value) :bool
{
if (!is_array($value)) {
$this->error = sprintf("Count expander require \"array\", got \"%s\".", new StringConverter($value));
$this->error = sprintf('Count expander require "array", got "%s".', new StringConverter($value));
return false;
}

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

Expand Down
4 changes: 2 additions & 2 deletions src/Matcher/Pattern/Expander/EndsWith.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ final class EndsWith implements PatternExpander
public function __construct(string $stringEnding, bool $ignoreCase = false)
{
if (!is_string($stringEnding)) {
throw new \InvalidArgumentException("String ending must be a valid string.");
throw new \InvalidArgumentException('String ending must be a valid string.');
}

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

Expand Down
6 changes: 3 additions & 3 deletions src/Matcher/Pattern/Expander/GreaterThan.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ final class GreaterThan implements PatternExpander
public function __construct($boundary)
{
if (!is_float($boundary) && !is_int($boundary)) {
throw new \InvalidArgumentException(sprintf("Boundary value \"%s\" is not a valid number.", new StringConverter($boundary)));
throw new \InvalidArgumentException(sprintf('Boundary value "%s" is not a valid number.', new StringConverter($boundary)));
}

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

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

Expand Down
2 changes: 1 addition & 1 deletion src/Matcher/Pattern/Expander/InArray.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public static function is(string $name) : bool
public function match($value) : bool
{
if (!is_array($value)) {
$this->error = sprintf("InArray expander require \"array\", got \"%s\".", new StringConverter($value));
$this->error = sprintf('InArray expander require "array", got "%s".', new StringConverter($value));
return false;
}

Expand Down
4 changes: 2 additions & 2 deletions src/Matcher/Pattern/Expander/IsDateTime.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ public static function is(string $name) : bool
public function match($value) : bool
{
if (false === is_string($value)) {
$this->error = sprintf("IsDateTime expander require \"string\", got \"%s\".", new StringConverter($value));
$this->error = sprintf('IsDateTime expander require "string", got "%s".', new StringConverter($value));
return false;
}

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

Expand Down
4 changes: 2 additions & 2 deletions src/Matcher/Pattern/Expander/IsEmail.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ public static function is(string $name) : bool
public function match($value) : bool
{
if (false === is_string($value)) {
$this->error = sprintf("IsEmail expander require \"string\", got \"%s\".", new StringConverter($value));
$this->error = sprintf('IsEmail expander require "string", got "%s".', new StringConverter($value));
return false;
}

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

Expand Down
2 changes: 1 addition & 1 deletion src/Matcher/Pattern/Expander/IsEmpty.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public static function is(string $name) : bool
public function match($value) : bool
{
if (!empty($value)) {
$this->error = sprintf("Value %s is not empty.", new StringConverter($value));
$this->error = sprintf('Value %s is not empty.', new StringConverter($value));

return false;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Matcher/Pattern/Expander/IsNotEmpty.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public static function is(string $name) : bool
public function match($value) : bool
{
if (false === $value || (empty($value) && '0' != $value)) {
$this->error = sprintf("Value %s is not blank.", new StringConverter($value));
$this->error = sprintf('Value %s is not blank.', new StringConverter($value));
return false;
}

Expand Down
4 changes: 2 additions & 2 deletions src/Matcher/Pattern/Expander/IsUrl.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ public static function is(string $name) : bool
public function match($value) : bool
{
if (false === is_string($value)) {
$this->error = sprintf("IsUrl expander require \"string\", got \"%s\".", new StringConverter($value));
$this->error = sprintf('IsUrl expander require "string", got "%s".', new StringConverter($value));
return false;
}

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

Expand Down
Loading

0 comments on commit fb88c73

Please sign in to comment.