Skip to content

Commit c4917b1

Browse files
author
Norbert Orzechowicz
committed
Merge pull request #59 from norzechowicz/php7-support
Added php 7 support
2 parents fd87d91 + 0925fa5 commit c4917b1

31 files changed

+62
-264
lines changed

.travis.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,8 @@ matrix:
88
- php: 5.4
99
- php: 5.5
1010
- php: 5.6
11+
- php: 7.0
1112
- php: hhvm
12-
allow_failures:
13-
- env: DEPENDENCIES='low'
1413

1514
before_install:
1615
- composer self-update
@@ -21,4 +20,4 @@ install:
2120
- if [ "$DEPENDENCIES" == "low" ]; then composer update --prefer-lowest; fi;
2221

2322
script:
24-
- ./bin/phpunit --coverage-text
23+
- ./bin/phpunit

composer.json

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,28 +16,27 @@
1616
"require": {
1717
"php": ">=5.3.0",
1818
"ext-filter": "*",
19-
"coduo/php-to-string": "~1.0",
20-
"symfony/property-access": "~2.3",
21-
"symfony/expression-language": "~2.4",
19+
"coduo/php-to-string": "^2",
20+
"symfony/property-access": "^2.3|^3.0",
21+
"symfony/expression-language": "^2.3|^3.0",
2222
"doctrine/lexer": "1.0.*",
23-
"openlss/lib-array2xml": "0.0.9"
23+
"openlss/lib-array2xml": "0.0.10"
2424
},
2525
"require-dev": {
26-
"phpunit/phpunit": "3.7.*"
26+
"phpunit/phpunit": "^4.8"
2727
},
2828
"autoload": {
2929
"psr-0": {
3030
"Coduo\\PHPMatcher": "src/",
3131
"Coduo\\PHPMatcher\\Tests": "tests/"
32-
},
33-
"files": ["match.php"]
32+
}
3433
},
3534
"config": {
3635
"bin-dir": "bin"
3736
},
3837
"extra": {
3938
"branch-alias": {
40-
"dev-master": "1.2-dev"
39+
"dev-master": "2.1-dev"
4140
}
4241
}
4342
}

match.php

Lines changed: 0 additions & 35 deletions
This file was deleted.

phpunit.xml.dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
bootstrap="tests/bootstrap.php"
1212
>
1313
<testsuites>
14-
<testsuite name="Json Matcher Test Suite">
14+
<testsuite name="PHP Matcher Test Suite">
1515
<directory>./tests/</directory>
1616
</testsuite>
1717
</testsuites>

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

0 commit comments

Comments
 (0)