mirror of
https://github.com/Respect/Validation.git
synced 2024-05-17 21:56:40 +02:00
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:
parent
a65980ca45
commit
f53b77a186
5
.github/workflows/continuous-integration.yml
vendored
5
.github/workflows/continuous-integration.yml
vendored
|
@ -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
|
||||
|
|
|
@ -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"
|
||||
},
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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}
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue