diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 9a7f363dc..9f212844d 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -23,6 +23,7 @@ jobs: - "8.2" - "8.3" - "8.4" + - "8.5" steps: - name: Checkout diff --git a/library/Exceptions/NestedValidationException.php b/library/Exceptions/NestedValidationException.php index 74fe7689d..4ec37ec54 100644 --- a/library/Exceptions/NestedValidationException.php +++ b/library/Exceptions/NestedValidationException.php @@ -113,7 +113,7 @@ public function getIterator(): SplObjectStorage $lastDepth = $currentDepth; $lastDepthOriginal = $currentDepthOriginal; - $childrenExceptions->attach($childException, $currentDepth); + $childrenExceptions->offsetSet($childException, $currentDepth); } return $childrenExceptions; diff --git a/library/Factory.php b/library/Factory.php index 1799eb607..015872dc0 100644 --- a/library/Factory.php +++ b/library/Factory.php @@ -246,8 +246,6 @@ private function extractPropertiesValues(Validatable $validatable, ReflectionCla { $values = []; foreach ($reflection->getProperties() as $property) { - $property->setAccessible(true); - $propertyValue = $property->getValue($validatable); if ($propertyValue === null) { continue; diff --git a/phpunit.xml.dist b/phpunit.xml.dist index d0c517214..a18a1bb87 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -4,6 +4,7 @@ bootstrap="vendor/autoload.php" backupGlobals="false" backupStaticAttributes="false" + convertDeprecationsToExceptions="true" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" diff --git a/tests/unit/Rules/EmailTest.php b/tests/unit/Rules/EmailTest.php index 6f2fbedab..69ad713cb 100644 --- a/tests/unit/Rules/EmailTest.php +++ b/tests/unit/Rules/EmailTest.php @@ -99,7 +99,6 @@ private static function sut(): Email $rule = new Email(); $reflection = new ReflectionProperty(Email::class, 'validator'); - $reflection->setAccessible(true); $reflection->setValue($rule, null); return $rule; diff --git a/tests/unit/Rules/FactorTest.php b/tests/unit/Rules/FactorTest.php index 78a1c37fd..cc5f02ad6 100644 --- a/tests/unit/Rules/FactorTest.php +++ b/tests/unit/Rules/FactorTest.php @@ -18,6 +18,7 @@ use function uniqid; use const PHP_INT_MAX; +use const PHP_VERSION_ID; /** * @group rule @@ -31,6 +32,32 @@ */ final class FactorTest extends RuleTestCase { + /** + * Some edge cases emit E_DEPRECATED on PHP >= 8.5. + * + * @test + * + * @dataProvider providerForInvalidInputEdgeCases + */ + public function shouldFailOnInvalidInputEdgeCases(Factor $rule, mixed $input): void + { + if (PHP_VERSION_ID >= 80500) { + $this->markTestSkipped('This test emits E_DEPRECATED on PHP >= 8.5'); + } + + self::assertInvalidInput($rule, $input); + } + + /** + * @return array + */ + public static function providerForInvalidInputEdgeCases(): array + { + return [ + 'mt_rand is not factor PHP_INT_MAX + 1' => [new Factor(mt_rand()), PHP_INT_MAX + 1], + ]; + } + /** * {@inheritDoc} */ @@ -93,7 +120,6 @@ public static function providerForInvalidInput(): array 'mt_rand is not factor 1.5' => [new Factor(mt_rand()), 1.5], 'mt_rand is not factor -0.5' => [new Factor(mt_rand()), -0.5], 'mt_rand is not factor -1.5' => [new Factor(mt_rand()), -1.5], - 'mt_rand is not factor PHP_INT_MAX + 1' => [new Factor(mt_rand()), PHP_INT_MAX + 1], 'mt_rand is not factor calc' => [new Factor(mt_rand()), mt_rand(1, mt_getrandmax() - 1) / mt_getrandmax()], 'mt_rand is not factor -calc' => [ new Factor(mt_rand()),