Skip to content
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

Example class throws E_DEPRECATED warning in PHP 8.1 #6291

Closed
fabacino opened this issue Dec 14, 2021 · 2 comments · Fixed by #6298
Closed

Example class throws E_DEPRECATED warning in PHP 8.1 #6291

fabacino opened this issue Dec 14, 2021 · 2 comments · Fixed by #6298

Comments

@fabacino
Copy link
Contributor

fabacino commented Dec 14, 2021

What are you trying to achieve?

Running a test using the Codeception\Example class with PHP 8.1

What do you get instead?

❯ vendor/bin/codecept run
Codeception PHP Testing Framework v4.1.23
Powered by PHPUnit 9.5.10 by Sebastian Bergmann and contributors.

Fatal error: During inheritance of ArrayAccess: Uncaught PHPUnit\Framework\Exception: Return type of
Codeception\Example::offsetExists($offset) should either be compatible with ArrayAccess::offsetExists(
mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress
the notice at vendor/codeception/codeception/src/Codeception/Example.php:27

/home/www/http/vendor/composer/ClassLoader.php:571
/home/www/http/vendor/composer/ClassLoader.php:428
 in /home/www/http/vendor/codeception/codeception/src/Codeception/Example.php on line 6

Adding the #[\ReturnTypeWillChange] attribute to the offsetExists method fixes the issue. The same error appears for the other interface methods in Example as well. I can PR if appreciated.

Related issue: #6288

Details

  • Codeception version: 4.1.23
  • PHP Version: 8.1
  • Operating System: Linux
  • Installation type: Composer
@Naktibalda
Copy link
Member

Not compatible is a bit harsh, it throws E_DEPRECATED in PHP 8.1

You must have some setting enabled that converts deprecation messages to exceptions.

Please raise PR.

@fabacino fabacino changed the title Example class not compatible with PHP 8.1 Example class throws E_DEPRECATED warning in PHP 8.1 Dec 20, 2021
@fabacino
Copy link
Contributor Author

That's true, no offense meant. I've rephrased the title.

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 a pull request may close this issue.

2 participants