Skip to content

Commit af948f0

Browse files
authored
Update minimum required php version to 7.2 (#166)
* Updated project to php 7.2 * Travis & readme cleanups
1 parent 26f53fc commit af948f0

37 files changed

+129
-209
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ bin/
33
composer.lock
44
.DS_Store
55
.idea
6+
.phpunit.result.cache

.travis.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@ cache:
66

77
matrix:
88
include:
9-
- php: 7.0
9+
- php: 7.2
1010
env: DEPENDENCIES='low'
11-
- php: 7.1
1211
- php: 7.2
1312
- php: 7.3
1413

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

2322
script:
24-
- ./bin/phpunit
25-
- ./bin/php-cs-fixer fix -v --dry-run
23+
- composer test

CHANGELOG.md

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

CONTRIBUTING.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,22 @@
66
2. Clone the repo to local
77
3. Install dependencies: `composer update` (this assumes you have 'composer' aliased to wherever your composer.phar lives)
88
4. Run the tests. We only take pull requests with passing tests, and it's great to know that you have a clean slate:
9-
`./bin/phpunit`
9+
`composer test`
1010

11-
## Coding Standards
11+
## Adding new features
1212

13-
Try use similar coding standards to what you see in the project to keep things clear to the contributors. If you're unsure, it's always a safe bet to fall-back to the PSR standards.
13+
Pull requests with new features needs to be created against master branch.
1414

15-
[PSR-1: Basic Coding Standard](http://www.php-fig.org/psr/psr-1/)
15+
If new feature require BC Break please note that in your PR comment, it will added in next major version.
16+
New features that does not have any BC Breaks are going to be added in next minor version.
1617

17-
[PSR-2: Coding Style Guide](http://www.php-fig.org/psr/psr-2/)
18+
## Codding standards
1819

19-
## Adding new features
20-
21-
Pull requests with new features needs to be created against master branch.
20+
In order to fix codding standards please exeecute:
2221

23-
If new feature require BC Breake please note that in your PR comment, it will added in next major version.
24-
New features that does not have any BC Breakes are going to be added in next minor version.
22+
```
23+
composer cs:php:fix
24+
```
2525

2626
## Patches and bugfixes
2727

LICENCE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2014-2018 Michal Dabrowski, Norbert Orzechowicz
1+
Copyright (c) 2014-2019 Michal Dabrowski, Norbert Orzechowicz
22

33
Permission is hereby granted, free of charge, to any person
44
obtaining a copy of this software and associated documentation

README.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ PHPMatcher::match($value = '{"foo": "bar"}', $pattern = '{"foo": "@string@"}');
88

99
It was built to simplify API's functional testing.
1010

11-
* [![Build Status](https://travis-ci.org/coduo/php-matcher.svg)](https://travis-ci.org/coduo/php-matcher) - [3.3 (master) README](https://github.com/coduo/php-matcher/tree/master/README.md)
12-
* [![Build Status](https://travis-ci.org/coduo/php-matcher.svg?branch=3.2)](https://travis-ci.org/coduo/php-matcher) - [3.2.* README](https://github.com/coduo/php-matcher/tree/3.2/README.md)
13-
* [![Build Status](https://travis-ci.org/coduo/php-matcher.svg?branch=3.1)](https://travis-ci.org/coduo/php-matcher) - [3.1.* README](https://github.com/coduo/php-matcher/tree/3.1/README.md)
11+
* [![Build Status](https://travis-ci.org/coduo/php-matcher.svg)](https://travis-ci.org/coduo/php-matcher) - [4.0 (master) README](https://github.com/coduo/php-matcher/tree/master/README.md) PHP >= 7.2
12+
* [![Build Status](https://travis-ci.org/coduo/php-matcher.svg?branch=3.2)](https://travis-ci.org/coduo/php-matcher) - [3.2.* README](https://github.com/coduo/php-matcher/tree/3.2/README.md) PHP >= 7.0
13+
* [![Build Status](https://travis-ci.org/coduo/php-matcher.svg?branch=3.1)](https://travis-ci.org/coduo/php-matcher) - [3.1.* README](https://github.com/coduo/php-matcher/tree/3.1/README.md) PHP >= 7.0
1414

1515

1616
## Installation
@@ -36,7 +36,6 @@ if (!PHPMatcher::match("lorem ipsum dolor", "@string@", $error)) {
3636

3737
```
3838

39-
4039
### Using Factory
4140

4241
```php
@@ -65,6 +64,7 @@ $matcher->getError(); // returns null or error message
6564
* ``@*@`` || ``@wildcard@``
6665
* ``expr(expression)``
6766
* ``@uuid@``
67+
* ``@strig@||@integer@`` - string OR integer
6868

6969
### Available pattern expanders
7070

@@ -321,10 +321,10 @@ $matcher->match(
321321
'{
322322
"users":[
323323
{
324-
"firstName": @string@,
325-
"lastName": @string@,
324+
"firstName": "@string@",
325+
"lastName": "@string@",
326326
"created": "@string@.isDateTime()",
327-
"roles": @array@,
327+
"roles": "@array@",
328328
"position": "@string@.optional()"
329329
}
330330
]
@@ -372,12 +372,12 @@ $matcher->match(
372372
'{
373373
"users":[
374374
{
375-
"firstName": @string@,
376-
"lastName": @string@,
375+
"firstName": "@string@",
376+
"lastName": "@string@",
377377
"created": "@string@.isDateTime()",
378378
"roles": [
379379
"ROLE_USER",
380-
@...@
380+
"@...@"
381381
],
382382
"attributes": {
383383
"isAdmin": @boolean@,
@@ -465,17 +465,17 @@ Feature: Listing user toys
465465
"""
466466
[
467467
{
468-
"id": @string@,
468+
"id": "@string@",
469469
"name": "Barbie",
470470
"_links: "@*@"
471471
},
472472
{
473-
"id": @string@,
473+
"id": "@string@",
474474
"name": "GI Joe",
475475
"_links": "@*@"
476476
},
477477
{
478-
"id": @string@,
478+
"id": "@string@",
479479
"name": "Optimus Prime",
480480
"_links": "@*@"
481481
}

UPGRADE.md

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

composer.json

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
}
1616
],
1717
"require": {
18-
"php": ">=7.0.0",
18+
"php": ">=7.2",
1919
"ext-filter": "*",
2020
"ext-json": "*",
2121
"coduo/php-to-string": "^2",
@@ -25,7 +25,7 @@
2525
"openlss/lib-array2xml": "^1.0"
2626
},
2727
"require-dev": {
28-
"phpunit/phpunit": "^6.0|^7.0",
28+
"phpunit/phpunit": "^7.0|^8.0",
2929
"friendsofphp/php-cs-fixer": "^2.4"
3030
},
3131
"autoload": {
@@ -39,11 +39,20 @@
3939
}
4040
},
4141
"config": {
42-
"bin-dir": "bin"
42+
"sort-packages": true
43+
},
44+
"scripts": {
45+
"cs:php:fix": [
46+
"php-cs-fixer fix --using-cache=no"
47+
],
48+
"test" : [
49+
"phpunit",
50+
"php-cs-fixer fix -v --dry-run"
51+
]
4352
},
4453
"extra": {
4554
"branch-alias": {
46-
"dev-master": "3.3-dev"
55+
"dev-master": "4.0-dev"
4756
}
4857
}
4958
}

src/Matcher.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public function match($value, $pattern) : bool
2929
/**
3030
* @return null|string
3131
*/
32-
public function getError()
32+
public function getError() : ?string
3333
{
3434
return $this->matcher->getError();
3535
}

src/Matcher/Matcher.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ abstract class Matcher implements ValueMatcher
1111
/**
1212
* @inheritdoc
1313
*/
14-
public function getError()
14+
public function getError() : ?string
1515
{
1616
return $this->error;
1717
}
@@ -28,7 +28,7 @@ public function match($value, $pattern) : bool
2828
return false;
2929
}
3030

31-
public function clearError()
31+
public function clearError() : void
3232
{
3333
$this->error = null;
3434
}

src/Matcher/ValueMatcher.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ public function canMatch($pattern) : bool;
2121
*
2222
* @return null|string
2323
*/
24-
public function getError();
24+
public function getError() :?string;
2525

2626
/**
2727
* Clear last error
2828
*/
29-
public function clearError();
29+
public function clearError() : void;
3030
}

src/PHPUnit/PHPMatcherAssertions.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
trait PHPMatcherAssertions
1010
{
11-
protected function assertMatchesPattern($pattern, $value, string $message = '')
11+
protected function assertMatchesPattern($pattern, $value, string $message = '') : void
1212
{
1313
TestCase::assertThat($value, self::matchesPattern($pattern), $message);
1414
}

src/PHPUnit/PHPMatcherConstraint.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ private function createMatcher() : Matcher
5757
/**
5858
* {@inheritdoc}
5959
*/
60-
protected function fail($other, $description, ComparisonFailure $comparisonFailure = null): void
60+
protected function fail($other, $description, ComparisonFailure $comparisonFailure = null) : void
6161
{
6262
if (null === $comparisonFailure
6363
&& \is_string($other)

src/Parser.php

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ private function getPattern() : AST\Pattern
7676
return $pattern;
7777
}
7878

79-
private function addExpanderNodes(AST\Pattern $pattern)
79+
private function addExpanderNodes(AST\Pattern $pattern) : void
8080
{
8181
while (($expander = $this->getNextExpanderNode()) !== null) {
8282
$pattern->addExpander($expander);
@@ -85,13 +85,11 @@ private function addExpanderNodes(AST\Pattern $pattern)
8585

8686
/**
8787
* Try to get next expander, return null if there is no expander left
88-
*
89-
* @return AST\Expander|null
9088
*/
91-
private function getNextExpanderNode()
89+
private function getNextExpanderNode() : ?AST\Expander
9290
{
9391
if ($this->endOfPattern()) {
94-
return ;
92+
return null;
9593
}
9694

9795
$expander = new AST\Expander($this->getExpanderName());
@@ -113,7 +111,7 @@ private function getNextExpanderNode()
113111
return $expander;
114112
}
115113

116-
private function getExpanderName()
114+
private function getExpanderName() : string
117115
{
118116
if ($this->lexer->lookahead['type'] !== Lexer::T_EXPANDER_NAME) {
119117
$this->unexpectedSyntaxError($this->lexer->lookahead, '.expanderName(args) definition');
@@ -126,8 +124,6 @@ private function getExpanderName()
126124

127125
/**
128126
* Add arguments to expander
129-
*
130-
* @param AST\Expander $expander
131127
*/
132128
private function addArgumentValues(AST\Expander $expander)
133129
{
@@ -148,8 +144,6 @@ private function addArgumentValues(AST\Expander $expander)
148144

149145
/**
150146
* Try to get next argument. Return false if there are no arguments left before ")"
151-
*
152-
* @return null|mixed
153147
*/
154148
private function getNextArgumentValue()
155149
{
@@ -249,7 +243,7 @@ private function isNextCloseParenthesis() : bool
249243
* @param string $expected
250244
* @throws PatternException
251245
*/
252-
private function unexpectedSyntaxError(array $unexpectedToken, string $expected = null)
246+
private function unexpectedSyntaxError(array $unexpectedToken, string $expected = null) : void
253247
{
254248
$tokenPos = (isset($unexpectedToken['position'])) ? $unexpectedToken['position'] : '-1';
255249
$message = \sprintf('line 0, col %d: Error: ', $tokenPos);
@@ -263,7 +257,7 @@ private function unexpectedSyntaxError(array $unexpectedToken, string $expected
263257
* @param string $expected
264258
* @throws PatternException
265259
*/
266-
private function unexpectedEndOfString(string $expected = null)
260+
private function unexpectedEndOfString(string $expected = null) : void
267261
{
268262
$tokenPos = (isset($this->lexer->token['position'])) ? $this->lexer->token['position'] + \strlen((string) $this->lexer->token['value']) : '-1';
269263
$message = \sprintf('line 0, col %d: Error: ', $tokenPos);

tests/Matcher/ArrayMatcherTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class ArrayMatcherTest extends TestCase
1616
*/
1717
private $matcher;
1818

19-
public function setUp()
19+
public function setUp() : void
2020
{
2121
$parser = new Parser(new Lexer(), new Parser\ExpanderInitializer());
2222
$this->matcher = new Matcher\ArrayMatcher(

tests/Matcher/BooleanMatcherTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class BooleanMatcherTest extends TestCase
1616
*/
1717
private $matcher;
1818

19-
public function setUp()
19+
public function setUp() : void
2020
{
2121
$this->matcher = new BooleanMatcher(new Parser(new Lexer(), new Parser\ExpanderInitializer()));
2222
}

0 commit comments

Comments
 (0)