Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update minimum required php version to 7.2 #166

Merged
merged 3 commits into from
Aug 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ bin/
composer.lock
.DS_Store
.idea
.phpunit.result.cache
6 changes: 2 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ cache:

matrix:
include:
- php: 7.0
- php: 7.2
env: DEPENDENCIES='low'
- php: 7.1
- php: 7.2
- php: 7.3

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

script:
- ./bin/phpunit
- ./bin/php-cs-fixer fix -v --dry-run
- composer test
52 changes: 0 additions & 52 deletions CHANGELOG.md

This file was deleted.

20 changes: 10 additions & 10 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,22 @@
2. Clone the repo to local
3. Install dependencies: `composer update` (this assumes you have 'composer' aliased to wherever your composer.phar lives)
4. Run the tests. We only take pull requests with passing tests, and it's great to know that you have a clean slate:
`./bin/phpunit`
`composer test`

## Coding Standards
## Adding new features

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.
Pull requests with new features needs to be created against master branch.

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

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

## Adding new features

Pull requests with new features needs to be created against master branch.
In order to fix codding standards please exeecute:

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

## Patches and bugfixes

Expand Down
2 changes: 1 addition & 1 deletion LICENCE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2014-2018 Michal Dabrowski, Norbert Orzechowicz
Copyright (c) 2014-2019 Michal Dabrowski, Norbert Orzechowicz

Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
Expand Down
26 changes: 13 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ PHPMatcher::match($value = '{"foo": "bar"}', $pattern = '{"foo": "@string@"}');

It was built to simplify API's functional testing.

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


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

```


### Using Factory

```php
Expand Down Expand Up @@ -65,6 +64,7 @@ $matcher->getError(); // returns null or error message
* ``@*@`` || ``@wildcard@``
* ``expr(expression)``
* ``@uuid@``
* ``@strig@||@integer@`` - string OR integer

### Available pattern expanders

Expand Down Expand Up @@ -321,10 +321,10 @@ $matcher->match(
'{
"users":[
{
"firstName": @string@,
"lastName": @string@,
"firstName": "@string@",
"lastName": "@string@",
"created": "@[email protected]()",
"roles": @array@,
"roles": "@array@",
"position": "@[email protected]()"
}
]
Expand Down Expand Up @@ -372,12 +372,12 @@ $matcher->match(
'{
"users":[
{
"firstName": @string@,
"lastName": @string@,
"firstName": "@string@",
"lastName": "@string@",
"created": "@[email protected]()",
"roles": [
"ROLE_USER",
@...@
"@...@"
],
"attributes": {
"isAdmin": @boolean@,
Expand Down Expand Up @@ -465,17 +465,17 @@ Feature: Listing user toys
"""
[
{
"id": @string@,
"id": "@string@",
"name": "Barbie",
"_links: "@*@"
},
{
"id": @string@,
"id": "@string@",
"name": "GI Joe",
"_links": "@*@"
},
{
"id": @string@,
"id": "@string@",
"name": "Optimus Prime",
"_links": "@*@"
}
Expand Down
12 changes: 0 additions & 12 deletions UPGRADE.md

This file was deleted.

17 changes: 13 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
}
],
"require": {
"php": ">=7.0.0",
"php": ">=7.2",
"ext-filter": "*",
"ext-json": "*",
"coduo/php-to-string": "^2",
Expand All @@ -25,7 +25,7 @@
"openlss/lib-array2xml": "^1.0"
},
"require-dev": {
"phpunit/phpunit": "^6.0|^7.0",
"phpunit/phpunit": "^7.0|^8.0",
"friendsofphp/php-cs-fixer": "^2.4"
},
"autoload": {
Expand All @@ -39,11 +39,20 @@
}
},
"config": {
"bin-dir": "bin"
"sort-packages": true
},
"scripts": {
"cs:php:fix": [
"php-cs-fixer fix --using-cache=no"
],
"test" : [
"phpunit",
"php-cs-fixer fix -v --dry-run"
]
},
"extra": {
"branch-alias": {
"dev-master": "3.3-dev"
"dev-master": "4.0-dev"
}
}
}
2 changes: 1 addition & 1 deletion src/Matcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function match($value, $pattern) : bool
/**
* @return null|string
*/
public function getError()
public function getError() : ?string
{
return $this->matcher->getError();
}
Expand Down
4 changes: 2 additions & 2 deletions src/Matcher/Matcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ abstract class Matcher implements ValueMatcher
/**
* @inheritdoc
*/
public function getError()
public function getError() : ?string
{
return $this->error;
}
Expand All @@ -28,7 +28,7 @@ public function match($value, $pattern) : bool
return false;
}

public function clearError()
public function clearError() : void
{
$this->error = null;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Matcher/ValueMatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ public function canMatch($pattern) : bool;
*
* @return null|string
*/
public function getError();
public function getError() :?string;

/**
* Clear last error
*/
public function clearError();
public function clearError() : void;
}
2 changes: 1 addition & 1 deletion src/PHPUnit/PHPMatcherAssertions.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

trait PHPMatcherAssertions
{
protected function assertMatchesPattern($pattern, $value, string $message = '')
protected function assertMatchesPattern($pattern, $value, string $message = '') : void
{
TestCase::assertThat($value, self::matchesPattern($pattern), $message);
}
Expand Down
2 changes: 1 addition & 1 deletion src/PHPUnit/PHPMatcherConstraint.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ private function createMatcher() : Matcher
/**
* {@inheritdoc}
*/
protected function fail($other, $description, ComparisonFailure $comparisonFailure = null): void
protected function fail($other, $description, ComparisonFailure $comparisonFailure = null) : void
{
if (null === $comparisonFailure
&& \is_string($other)
Expand Down
18 changes: 6 additions & 12 deletions src/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ private function getPattern() : AST\Pattern
return $pattern;
}

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

/**
* Try to get next expander, return null if there is no expander left
*
* @return AST\Expander|null
*/
private function getNextExpanderNode()
private function getNextExpanderNode() : ?AST\Expander
{
if ($this->endOfPattern()) {
return ;
return null;
}

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

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

/**
* Add arguments to expander
*
* @param AST\Expander $expander
*/
private function addArgumentValues(AST\Expander $expander)
{
Expand All @@ -148,8 +144,6 @@ private function addArgumentValues(AST\Expander $expander)

/**
* Try to get next argument. Return false if there are no arguments left before ")"
*
* @return null|mixed
*/
private function getNextArgumentValue()
{
Expand Down Expand Up @@ -249,7 +243,7 @@ private function isNextCloseParenthesis() : bool
* @param string $expected
* @throws PatternException
*/
private function unexpectedSyntaxError(array $unexpectedToken, string $expected = null)
private function unexpectedSyntaxError(array $unexpectedToken, string $expected = null) : void
{
$tokenPos = (isset($unexpectedToken['position'])) ? $unexpectedToken['position'] : '-1';
$message = \sprintf('line 0, col %d: Error: ', $tokenPos);
Expand All @@ -263,7 +257,7 @@ private function unexpectedSyntaxError(array $unexpectedToken, string $expected
* @param string $expected
* @throws PatternException
*/
private function unexpectedEndOfString(string $expected = null)
private function unexpectedEndOfString(string $expected = null) : void
{
$tokenPos = (isset($this->lexer->token['position'])) ? $this->lexer->token['position'] + \strlen((string) $this->lexer->token['value']) : '-1';
$message = \sprintf('line 0, col %d: Error: ', $tokenPos);
Expand Down
2 changes: 1 addition & 1 deletion tests/Matcher/ArrayMatcherTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class ArrayMatcherTest extends TestCase
*/
private $matcher;

public function setUp()
public function setUp() : void
{
$parser = new Parser(new Lexer(), new Parser\ExpanderInitializer());
$this->matcher = new Matcher\ArrayMatcher(
Expand Down
2 changes: 1 addition & 1 deletion tests/Matcher/BooleanMatcherTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class BooleanMatcherTest extends TestCase
*/
private $matcher;

public function setUp()
public function setUp() : void
{
$this->matcher = new BooleanMatcher(new Parser(new Lexer(), new Parser\ExpanderInitializer()));
}
Expand Down
Loading