Skip to content

Conversation

@mpesari
Copy link
Contributor

@mpesari mpesari commented Nov 25, 2025

Hi! This fixes some E_DEPRECATED issues when running unit tests on PHP 8.5.

The fixed code doesn't exist anymore on branch main, so I'm not sure what the current status is with that.

Before

$ php8.5 vendor/bin/phpunit
...
PHP Deprecated:  Method ReflectionProperty::setAccessible() is deprecated since 8.5, as it has no effect in /home/mpesari/git/Respect/Validation/tests/unit/Rules/EmailTest.php on line 102
...
PHP Warning:  The float-string "11111111111111111111100000000000" is not representable as an int, cast occurred in /home/mpesari/git/Respect/Validation/library/Rules/Ip.php on line 109
...
PHP Deprecated:  Method ReflectionProperty::setAccessible() is deprecated since 8.5, as it has no effect in /home/mpesari/git/Respect/Validation/library/Factory.php on line 249
...
PHP Deprecated:  Method SplObjectStorage::attach() is deprecated since 8.5, use method SplObjectStorage::offsetSet() instead in /home/mpesari/git/Respect/Validation/library/Exceptions/NestedValidationException.php on line 116
...

After

$ php8.5 vendor/bin/phpunit
...
PHP Warning:  The float-string "11111111111111111111100000000000" is not representable as an int, cast occurred in /home/mpesari/git/Respect/Validation/library/Rules/Ip.php on line 109
...

I'm not sure if that last Warning is something that can be fixed easily, and it remains on the main branch.

Whoops, there's still another error:

There was 1 error:                                    
                                                                                                                                                                                                                        
1) Respect\Validation\Rules\FactorTest::shouldValidateInvalidInput with data set "mt_rand is not factor PHP_INT_MAX + 1" (Respect\Validation\Rules\Factor Object (...), 9.223372036854776E+18)
The float 9.223372036854776E+18 is not representable as an int, cast occurred
                                                                                                                                                                                                                        
/home/mpesari/git/Respect/Validation/library/Rules/Factor.php:50
/home/mpesari/git/Respect/Validation/tests/library/RuleTestCase.php:117                                                                                                                                                 
/home/mpesari/git/Respect/Validation/tests/library/RuleTestCase.php:80                

@alganet
Copy link
Member

alganet commented Nov 25, 2025

Hi! Thanks for contributing 🐼

It seems 8.5 got more strict with types, which is good.

The main branch is supposed to be 3.0, which is a big rewrite (I'm behind on following it as well!). It's taking a while, so maybe the 2.x branch will still have a release, and we should have 8.5 compat in mind.

What do you think of isolating the problematic assertion that made the test fail, and mark them as skipped tests? That way, your PR will have a clean build.

@mpesari
Copy link
Contributor Author

mpesari commented Dec 2, 2025

I added a skip for the failing test on PHP 8.5.

There are still other warnings that should probably be fixed, but they don't fail the tests (although I think they should, because PHPUnit is configured to convertWarningsToExceptions)

Looks like the uopz extension is fixed in https://github.com/krakjoe/uopz/commits/master/ but there's not a release compatible with PHP 8.5 yet in PECL.

According to shivammathur/setup-php docs it's possible to compile the extension from git...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants