10000 Fix phpstan when using simple-phpunit by johnstevenson · Pull Request #128 · composer/xdebug-handler · GitHub
[go: up one dir, main page]

Skip to content

Fix phpstan when using simple-phpunit #128

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 1 commit into from
Apr 9, 2021

Conversation

johnstevenson
Copy link
Member
@johnstevenson johnstevenson commented Apr 9, 2021

PHPStan cannot find PHPUnit classes when simple-phpunit is being used because they are not in the autoloader. This fix ensures that PHPUnit is installed in vendor/bin/.phpunit and autoloads the classes.

It uses the vendor/bin/.phpunit/phpunit directory that simple-phpunit creates with a symlink from the installed phpunit folder. However this won't work on Windows, where you (generally) need to be an admin to create symlinks: symfony/symfony#40754

@johnstevenson johnstevenson merged commit e7c5ea8 into composer:main Apr 9, 2021
@johnstevenson johnstevenson deleted the phpstan branch April 9, 2021 16:46
@@ -36,7 +36,7 @@
}
},
"scripts": {
"test": "SYMFONY_PHPUNIT_REMOVE_RETURN_TYPEHINT=1 vendor/bin/simple-phpunit",
"test": "vendor/bin/simple-phpunit",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't that needed for you to run the tests on latest phpunit? Like when using PHP 8 IIRC I needed this.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I refactored the tests in #102 to work with PHPUnit8 and got round the type-hinted methods by replacing them with @before. @beforeClass etc annotated methods. So there is no need for SYMFONY_PHPUNIT_REMOVE_RETURN_TYPEHINT.

The tests run fine in PHP-8: https://github.com/composer/xdebug-handler/runs/2309173611?check_suite_focus=true

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, interesting workaround :)

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
0