Add support for PHP 8.0

We already supported PHP 8.0 as our constrains in the "composer.json"
file was ">=7.3", but we were not testing it before.

Because of that, I found a bug on "EndsWith" which is fixed now.

Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
This commit is contained in:
Henrique Moody 2020-08-27 19:49:27 +02:00
parent a65980ca45
commit f53b77a186
No known key found for this signature in database
GPG key ID: 221E9281655813A6
6 changed files with 26 additions and 7 deletions

View file

@ -21,6 +21,9 @@ jobs:
php-version:
- "7.3"
- "7.4"
include:
- php-version: "8.0"
composer-extra-arguments: --ignore-platform-reqs
steps:
- name: Checkout
@ -41,7 +44,7 @@ jobs:
sudo locale-gen --no-purge --lang ru_RU.UTF-8
- name: Install dependencies
run: composer install --prefer-dist
run: composer install --prefer-dist ${{ matrix.composer-extra-arguments }}
- name: Run unit tests
run: vendor/bin/phpunit --testsuite=unit

View file

@ -15,7 +15,7 @@
"sort-packages": true
},
"require": {
"php": ">=7.3",
"php": "^7.3 || ^8.0",
"respect/stringifier": "^0.2.0",
"symfony/polyfill-mbstring": "^1.2"
},

View file

@ -73,7 +73,7 @@ final class EndsWith extends AbstractRule
$encoding = (string) mb_detect_encoding($input);
$endPosition = mb_strlen($input, $encoding) - mb_strlen($this->endValue, $encoding);
return mb_strripos($input, $this->endValue, -1, $encoding) === $endPosition;
return mb_strripos($input, $this->endValue, 0, $encoding) === $endPosition;
}
/**

View file

@ -30,7 +30,7 @@ try {
}
try {
v::not(v::resourceType())->assert(xml_parser_create());
v::not(v::resourceType())->assert(tmpfile());
} catch (NestedValidationException $exception) {
echo $exception->getFullMessage() . PHP_EOL;
}
@ -39,4 +39,4 @@ try {
"test" must be a resource
`[resource] (stream)` must not be a resource
- `{ }` must be a resource
- `[resource] (xml)` must not be a resource
- `[resource] (stream)` must not be a resource

View file

@ -42,7 +42,7 @@ final class CallableTypeTest extends RuleTestCase
},
],
[$rule, 'trim'],
[$rule, __METHOD__],
[$rule, self::class . '::staticMethod'],
[$rule, [$this, __FUNCTION__]],
];
}
@ -62,4 +62,9 @@ final class CallableTypeTest extends RuleTestCase
[$rule, null],
];
}
public static function staticMethod(): void
{
// This is a static method example
}
}

View file

@ -40,10 +40,21 @@ final class ResourceTypeTest extends RuleTestCase
return [
[$rule, stream_context_create()],
[$rule, tmpfile()],
[$rule, xml_parser_create()],
];
}
/**
* @test
*
* @requires PHP < 8.0
*/
public function itShouldTestXmlResource(): void
{
$rule = new ResourceType();
self::assertValidInput($rule, xml_parser_create());
}
/**
* {@inheritDoc}
*/