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

PHP Fatal error setUp() #79

Closed
LocalHeroPro opened this issue Oct 10, 2022 · 6 comments
Closed

PHP Fatal error setUp() #79

LocalHeroPro opened this issue Oct 10, 2022 · 6 comments

Comments

@LocalHeroPro
Copy link

LocalHeroPro commented Oct 10, 2022

Steps to reproduce:

$ php -dxdebug.mode=coverage ./vendor/phpunit/phpunit/phpunit 

Testing started at 21:32 ...
PHP Fatal error:  Declaration of Hamcrest\Core\CombinableMatcherTest::setUp() must be compatible with PHPUnit\Framework\TestCase::setUp(): void in /var/www/html/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Core/CombinableMatcherTest.php on line 10

Fatal error: Declaration of Hamcrest\Core\CombinableMatcherTest::setUp() must be compatible with PHPUnit\Framework\TestCase::setUp(): void in /var/www/html/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Core/CombinableMatcherTest.php on line 10

Process finished with exit code 255

hamcrest/hamcrest-php: v2.0.1
PHPUnit: 9.5.25
Xdebug v3.1.5
PHP: 8.1.10

@aik099
Copy link
Member

aik099 commented Oct 12, 2022

To fix this we need to rename all setUp methods into setUpTest methods and annotate them with @before annotation.

If there are tearDown methods, then they must be renamed into tearDownTest methods and annotated with @after annotation.

PRs are welcome. I'm not sure though if PHPUnit 9.x is used in the GitHub Actions workflow.

@LocalHeroPro
Copy link
Author

Wouldn't be all to add only : void after setUp() method?

@aik099
Copy link
Member

aik099 commented Oct 12, 2022

Wouldn't be all to add only : void after setUp() method?

That won't work in PHP 5.x, which we support.


The PHPUnit changes public method signatures quite often (almost every major release). We can't keep up with that.

Using an annotation-based approach ensures, that the test suite will be compatible with every future major PHPUnit release.

@LocalHeroPro
Copy link
Author

Maybe the way is to create separate branch for EOL versions of PHP and for present one. In that way we have newest features in new one branch and ald ones for obsolete/abandoned ones.

@aik099
Copy link
Member

aik099 commented Oct 17, 2022

@LocalHeroPro , Thanks for the suggestions, I'll take this into consideration. For now please do as explained in the #79 (comment) comment.

@aik099
Copy link
Member

aik099 commented Dec 6, 2024

Fixed in #82 .

@aik099 aik099 closed this as completed Dec 6, 2024
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

No branches or pull requests

2 participants