8000 Fix PHP 8.1 return type deprecation errors by cedric-anne · Pull Request #865 · atoum/atoum · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fix PHP 8.1 return type deprecation errors #865

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

Merged
merged 2 commits into from
Oct 10, 2021
Merged

Fix PHP 8.1 return type deprecation errors #865

merged 2 commits into from
Oct 10, 2021

Conversation

cedric-anne
Copy link
Member
@cedric-anne cedric-anne commented Oct 4, 2021

Fixes ArrayAccess, Countable and IteratorAggregate implementations.

It removes the fluent logic on ArrayAccess implementations, so it may introduce BC breaks.

@cedric-anne cedric-anne marked this pull request as ready for review October 4, 2021 14:21
@cedric-anne
Copy link
Member Author

@Grummfy

I think my first proposal is not correct, as it may break classes that extends modified classes. Indeed, their method signature may differ and it will result in a fatal error.

I propose to use the #[\ReturnTypeWillChange] everywhere in the 4.x version of atoum, and switch to valid return types later, on atoum 5.x. Do you agree with that ?

@Grummfy
Copy link
Member
Grummfy commented Oct 6, 2021

Honestly, it's why I need time to check it ;)

Using a two steps process, could indeed be the right path to make it properly done.

If you see some other element to break feel free to prepare it for a V5 ;)

@cedric-anne cedric-anne changed the title PHP 8.1 return types compatibility Fix PHP 8.1 return type deprecation errors Oct 7, 2021
@cedric-anne
Copy link
Member Author

I've updated this PR to prevent BR breaks.

Explicit return types will be required for PHP 9.0 compatibility, so it can be done later :).

trasher
trasher previously approved these changes Oct 8, 2021
@villfa
Copy link
Contributor
villfa commented Oct 9, 2021

Hi @cedric-anne,
There is also an implementation of OuterIterator here: https://github.com/atoum/atoum/blob/master/classes/iterators/recursives/atoum/source.php
I think it's related to the seg fault in 8.1.

@cedric-anne
Copy link
Member Author

Hi @villfa

I think all of them are fixed now.

I executed this simple script in atoum roor dir to detect them:

spl_autoload_register(
    function ($class) {
        if (!preg_match('/^atoum\\\\/', $class)) {
            return;
        }
        include 'classes/' . implode('/', explode('\\', preg_replace('/^atoum\\\\atoum\\\\/', '', $class))) . '.php';
    }
);

$dir_iterator = new RecursiveIteratorIterator(
    new RecursiveDirectoryIterator(__DIR__ . '/classes'),
    RecursiveIteratorIterator::SELF_FIRST
);
foreach ($dir_iterator as $file) {
    if ($file->getExtension() !== 'php') {
        continue;
    }
    require_once $file->getRealPath();
}

@cedric-anne
Copy link
Member Author

I think it's related to the seg fault in 8.1.

Segfault is still present :/.

@Grummfy Grummfy modified the milestone: 5.0.0 Oct 10, 2021
@Grummfy Grummfy merged commit 47eacf9 into atoum:master Oct 10, 2021
@cedric-anne cedric-anne deleted the fix/php-8.1-return-types branch October 11, 2021 13:11
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.

4 participants
0