Skip to content

Commit e33853d

Browse files
committed
Added php 7 support
1 parent fd87d91 commit e33853d

28 files changed

+55
-214
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ matrix:
88
- php: 5.4
99
- php: 5.5
1010
- php: 5.6
11+
- php: 7.0
1112
- php: hhvm
1213
allow_failures:
1314
- env: DEPENDENCIES='low'

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"require": {
1717
"php": ">=5.3.0",
1818
"ext-filter": "*",
19-
"coduo/php-to-string": "~1.0",
19+
"coduo/php-to-string": "~2.0",
2020
"symfony/property-access": "~2.3",
2121
"symfony/expression-language": "~2.4",
2222
"doctrine/lexer": "1.0.*",
@@ -37,7 +37,7 @@
3737
},
3838
"extra": {
3939
"branch-alias": {
40-
"dev-master": "1.2-dev"
40+
"dev-master": "2.1-dev"
4141
}
4242
}
4343
}

src/Coduo/PHPMatcher/Matcher/ArrayMatcher.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace Coduo\PHPMatcher\Matcher;
44

55
use Coduo\PHPMatcher\Parser;
6-
use Coduo\ToString\String;
6+
use Coduo\ToString\StringConverter;
77
use Symfony\Component\PropertyAccess\PropertyAccess;
88
use Symfony\Component\PropertyAccess\PropertyAccessor;
99

@@ -41,7 +41,7 @@ public function __construct(ValueMatcher $propertyMatcher, Parser $parser)
4141
public function match($value, $pattern)
4242
{
4343
if (!is_array($value)) {
44-
$this->error = sprintf("%s \"%s\" is not a valid array.", gettype($value), new String($value));
44+
$this->error = sprintf("%s \"%s\" is not a valid array.", gettype($value), new StringConverter($value));
4545
return false;
4646
}
4747

src/Coduo/PHPMatcher/Matcher/BooleanMatcher.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace Coduo\PHPMatcher\Matcher;
44

5-
use Coduo\ToString\String;
5+
use Coduo\ToString\StringConverter;
66

77
class BooleanMatcher extends Matcher
88
{
@@ -14,7 +14,7 @@ class BooleanMatcher extends Matcher
1414
public function match($value, $pattern)
1515
{
1616
if (!is_bool($value)) {
17-
$this->error = sprintf("%s \"%s\" is not a valid boolean.", gettype($value), new String($value));
17+
$this->error = sprintf("%s \"%s\" is not a valid boolean.", gettype($value), new StringConverter($value));
1818
return false;
1919
}
2020

src/Coduo/PHPMatcher/Matcher/ChainMatcher.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace Coduo\PHPMatcher\Matcher;
44

5-
use Coduo\ToString\String;
5+
use Coduo\ToString\StringConverter;
66

77
class ChainMatcher extends Matcher
88
{
@@ -45,8 +45,8 @@ public function match($value, $pattern)
4545
if (!isset($this->error)) {
4646
$this->error = sprintf(
4747
'Any matcher from chain can\'t match value "%s" to pattern "%s"',
48-
new String($value),
49-
new String($pattern)
48+
new StringConverter($value),
49+
new StringConverter($pattern)
5050
);
5151
}
5252

src/Coduo/PHPMatcher/Matcher/DoubleMatcher.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace Coduo\PHPMatcher\Matcher;
44

55
use Coduo\PHPMatcher\Parser;
6-
use Coduo\ToString\String;
6+
use Coduo\ToString\StringConverter;
77

88
class DoubleMatcher extends Matcher
99
{
@@ -26,7 +26,7 @@ public function __construct(Parser $parser)
2626
public function match($value, $pattern)
2727
{
2828
if (!is_double($value)) {
29-
$this->error = sprintf("%s \"%s\" is not a valid double.", gettype($value), new String($value));
29+
$this->error = sprintf("%s \"%s\" is not a valid double.", gettype($value), new StringConverter($value));
3030
return false;
3131
}
3232

src/Coduo/PHPMatcher/Matcher/ExpressionMatcher.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace Coduo\PHPMatcher\Matcher;
44

5-
use Coduo\ToString\String;
5+
use Coduo\ToString\StringConverter;
66
use Symfony\Component\ExpressionLanguage\ExpressionLanguage;
77

88
class ExpressionMatcher extends Matcher
@@ -19,7 +19,7 @@ public function match($value, $pattern)
1919
$expressionResult = $language->evaluate($matches[1], array('value' => $value));
2020

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

2525
return (bool) $expressionResult;

src/Coduo/PHPMatcher/Matcher/IntegerMatcher.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace Coduo\PHPMatcher\Matcher;
44

55
use Coduo\PHPMatcher\Parser;
6-
use Coduo\ToString\String;
6+
use Coduo\ToString\StringConverter;
77

88
class IntegerMatcher extends Matcher
99
{
@@ -26,7 +26,7 @@ public function __construct(Parser $parser)
2626
public function match($value, $pattern)
2727
{
2828
if (!is_integer($value)) {
29-
$this->error = sprintf("%s \"%s\" is not a valid integer.", gettype($value), new String($value));
29+
$this->error = sprintf("%s \"%s\" is not a valid integer.", gettype($value), new StringConverter($value));
3030
return false;
3131
}
3232

src/Coduo/PHPMatcher/Matcher/NullMatcher.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace Coduo\PHPMatcher\Matcher;
44

5-
use Coduo\ToString\String;
5+
use Coduo\ToString\StringConverter;
66

77
class NullMatcher extends Matcher
88
{
@@ -14,7 +14,7 @@ class NullMatcher extends Matcher
1414
public function match($value, $pattern)
1515
{
1616
if (null !== $value) {
17-
$this->error = sprintf("%s \"%s\" does not match null.", gettype($value), new String($value));
17+
$this->error = sprintf("%s \"%s\" does not match null.", gettype($value), new StringConverter($value));
1818
return false;
1919
}
2020

src/Coduo/PHPMatcher/Matcher/NumberMatcher.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace Coduo\PHPMatcher\Matcher;
44

5-
use Coduo\ToString\String;
5+
use Coduo\ToString\StringConverter;
66

77
class NumberMatcher extends Matcher
88
{
@@ -14,7 +14,7 @@ class NumberMatcher extends Matcher
1414
public function match($value, $pattern)
1515
{
1616
if (!is_numeric($value)) {
17-
$this->error = sprintf("%s \"%s\" is not a valid number.", gettype($value), new String($value));
17+
$this->error = sprintf("%s \"%s\" is not a valid number.", gettype($value), new StringConverter($value));
1818
return false;
1919
}
2020

src/Coduo/PHPMatcher/Matcher/Pattern/Expander/Contains.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace Coduo\PHPMatcher\Matcher\Pattern\Expander;
44

55
use Coduo\PHPMatcher\Matcher\Pattern\PatternExpander;
6-
use Coduo\ToString\String;
6+
use Coduo\ToString\StringConverter;
77

88
class Contains implements PatternExpander
99
{
@@ -39,7 +39,7 @@ public function __construct($string, $ignoreCase = false)
3939
public function match($value)
4040
{
4141
if (!is_string($value)) {
42-
$this->error = sprintf("Contains expander require \"string\", got \"%s\".", new String($value));
42+
$this->error = sprintf("Contains expander require \"string\", got \"%s\".", new StringConverter($value));
4343
return false;
4444
}
4545

src/Coduo/PHPMatcher/Matcher/Pattern/Expander/EndsWith.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace Coduo\PHPMatcher\Matcher\Pattern\Expander;
44

55
use Coduo\PHPMatcher\Matcher\Pattern\PatternExpander;
6-
use Coduo\ToString\String;
6+
use Coduo\ToString\StringConverter;
77

88
class EndsWith implements PatternExpander
99
{
@@ -43,7 +43,7 @@ public function __construct($stringEnding, $ignoreCase = false)
4343
public function match($value)
4444
{
4545
if (!is_string($value)) {
46-
$this->error = sprintf("EndsWith expander require \"string\", got \"%s\".", new String($value));
46+
$this->error = sprintf("EndsWith expander require \"string\", got \"%s\".", new StringConverter($value));
4747
return false;
4848
}
4949

src/Coduo/PHPMatcher/Matcher/Pattern/Expander/GreaterThan.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace Coduo\PHPMatcher\Matcher\Pattern\Expander;
44

55
use Coduo\PHPMatcher\Matcher\Pattern\PatternExpander;
6-
use Coduo\ToString\String;
6+
use Coduo\ToString\StringConverter;
77

88
class GreaterThan implements PatternExpander
99
{
@@ -23,7 +23,7 @@ class GreaterThan implements PatternExpander
2323
public function __construct($boundary)
2424
{
2525
if (!is_float($boundary) && !is_integer($boundary) && !is_double($boundary)) {
26-
throw new \InvalidArgumentException(sprintf("Boundary value \"%s\" is not a valid number.", new String($boundary)));
26+
throw new \InvalidArgumentException(sprintf("Boundary value \"%s\" is not a valid number.", new StringConverter($boundary)));
2727
}
2828

2929
$this->boundary = $boundary;
@@ -36,12 +36,12 @@ public function __construct($boundary)
3636
public function match($value)
3737
{
3838
if (!is_float($value) && !is_integer($value) && !is_double($value) && !is_numeric($value)) {
39-
$this->error = sprintf("Value \"%s\" is not a valid number.", new String($value));
39+
$this->error = sprintf("Value \"%s\" is not a valid number.", new StringConverter($value));
4040
return false;
4141
}
4242

4343
if ($value <= $this->boundary) {
44-
$this->error = sprintf("Value \"%s\" is not greater than \"%s\".", new String($value), new String($this->boundary));
44+
$this->error = sprintf("Value \"%s\" is not greater than \"%s\".", new StringConverter($value), new StringConverter($this->boundary));
4545
return false;
4646
}
4747

src/Coduo/PHPMatcher/Matcher/Pattern/Expander/InArray.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace Coduo\PHPMatcher\Matcher\Pattern\Expander;
44

55
use Coduo\PHPMatcher\Matcher\Pattern\PatternExpander;
6-
use Coduo\ToString\String;
6+
use Coduo\ToString\StringConverter;
77

88
class InArray implements PatternExpander
99
{
@@ -32,12 +32,12 @@ public function __construct($value)
3232
public function match($value)
3333
{
3434
if (!is_array($value)) {
35-
$this->error = sprintf("InArray expander require \"array\", got \"%s\".", new String($value));
35+
$this->error = sprintf("InArray expander require \"array\", got \"%s\".", new StringConverter($value));
3636
return false;
3737
}
3838

3939
if (!in_array($this->value, $value, true)) {
40-
$this->error = sprintf("%s doesn't have \"%s\" element.", new String($value), new String($this->value));
40+
$this->error = sprintf("%s doesn't have \"%s\" element.", new StringConverter($value), new StringConverter($this->value));
4141
return false;
4242
}
4343

src/Coduo/PHPMatcher/Matcher/Pattern/Expander/IsDateTime.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace Coduo\PHPMatcher\Matcher\Pattern\Expander;
44

55
use Coduo\PHPMatcher\Matcher\Pattern\PatternExpander;
6-
use Coduo\ToString\String;
6+
use Coduo\ToString\StringConverter;
77

88
class IsDateTime implements PatternExpander
99
{
@@ -19,7 +19,7 @@ class IsDateTime implements PatternExpander
1919
public function match($value)
2020
{
2121
if (false === is_string($value)) {
22-
$this->error = sprintf("IsDateTime expander require \"string\", got \"%s\".", new String($value));
22+
$this->error = sprintf("IsDateTime expander require \"string\", got \"%s\".", new StringConverter($value));
2323
return false;
2424
}
2525

src/Coduo/PHPMatcher/Matcher/Pattern/Expander/IsEmail.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace Coduo\PHPMatcher\Matcher\Pattern\Expander;
44

55
use Coduo\PHPMatcher\Matcher\Pattern\PatternExpander;
6-
use Coduo\ToString\String;
6+
use Coduo\ToString\StringConverter;
77

88
class IsEmail implements PatternExpander
99
{
@@ -19,7 +19,7 @@ class IsEmail implements PatternExpander
1919
public function match($value)
2020
{
2121
if (false === is_string($value)) {
22-
$this->error = sprintf("IsEmail expander require \"string\", got \"%s\".", new String($value));
22+
$this->error = sprintf("IsEmail expander require \"string\", got \"%s\".", new StringConverter($value));
2323
return false;
2424
}
2525

src/Coduo/PHPMatcher/Matcher/Pattern/Expander/IsUrl.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace Coduo\PHPMatcher\Matcher\Pattern\Expander;
44

55
use Coduo\PHPMatcher\Matcher\Pattern\PatternExpander;
6-
use Coduo\ToString\String;
6+
use Coduo\ToString\StringConverter;
77

88
class IsUrl implements PatternExpander
99
{
@@ -19,7 +19,7 @@ class IsUrl implements PatternExpander
1919
public function match($value)
2020
{
2121
if (false === is_string($value)) {
22-
$this->error = sprintf("IsUrl expander require \"string\", got \"%s\".", new String($value));
22+
$this->error = sprintf("IsUrl expander require \"string\", got \"%s\".", new StringConverter($value));
2323
return false;
2424
}
2525

src/Coduo/PHPMatcher/Matcher/Pattern/Expander/LowerThan.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace Coduo\PHPMatcher\Matcher\Pattern\Expander;
44

55
use Coduo\PHPMatcher\Matcher\Pattern\PatternExpander;
6-
use Coduo\ToString\String;
6+
use Coduo\ToString\StringConverter;
77

88
class LowerThan implements PatternExpander
99
{
@@ -23,7 +23,7 @@ class LowerThan implements PatternExpander
2323
public function __construct($boundary)
2424
{
2525
if (!is_float($boundary) && !is_integer($boundary) && !is_double($boundary)) {
26-
throw new \InvalidArgumentException(sprintf("Boundary value \"%s\" is not a valid number.", new String($boundary)));
26+
throw new \InvalidArgumentException(sprintf("Boundary value \"%s\" is not a valid number.", new StringConverter($boundary)));
2727
}
2828

2929
$this->boundary = $boundary;
@@ -36,12 +36,12 @@ public function __construct($boundary)
3636
public function match($value)
3737
{
3838
if (!is_float($value) && !is_integer($value) && !is_double($value)) {
39-
$this->error = sprintf("Value \"%s\" is not a valid number.", new String($value));
39+
$this->error = sprintf("Value \"%s\" is not a valid number.", new StringConverter($value));
4040
return false;
4141
}
4242

4343
if ($value >= $this->boundary) {
44-
$this->error = sprintf("Value \"%s\" is not lower than \"%s\".", new String($value), new String($this->boundary));
44+
$this->error = sprintf("Value \"%s\" is not lower than \"%s\".", new StringConverter($value), new StringConverter($this->boundary));
4545
return false;
4646
}
4747

src/Coduo/PHPMatcher/Matcher/Pattern/Expander/NotEmpty.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace Coduo\PHPMatcher\Matcher\Pattern\Expander;
44

55
use Coduo\PHPMatcher\Matcher\Pattern\PatternExpander;
6-
use Coduo\ToString\String;
6+
use Coduo\ToString\StringConverter;
77

88
class NotEmpty implements PatternExpander
99
{
@@ -16,7 +16,7 @@ class NotEmpty implements PatternExpander
1616
public function match($value)
1717
{
1818
if (false === $value || (empty($value) && '0' != $value)) {
19-
$this->error = sprintf("Value %s is not blank.", new String($value));
19+
$this->error = sprintf("Value %s is not blank.", new StringConverter($value));
2020
return false;
2121
}
2222

src/Coduo/PHPMatcher/Matcher/Pattern/Expander/OneOf.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace Coduo\PHPMatcher\Matcher\Pattern\Expander;
44

55
use Coduo\PHPMatcher\Matcher\Pattern\PatternExpander;
6-
use Coduo\ToString\String;
6+
use Coduo\ToString\StringConverter;
77

88
class OneOf implements PatternExpander
99
{
@@ -40,7 +40,7 @@ public function match($value)
4040
}
4141
}
4242

43-
$this->error = sprintf("Any expander available in OneOf expander does not match \"%s\".", new String($value));
43+
$this->error = sprintf("Any expander available in OneOf expander does not match \"%s\".", new StringConverter($value));
4444
return false;
4545
}
4646

0 commit comments

Comments
 (0)