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
Raising the PHPStan level to 6 #10159
Comments
You might want to consider using The rules that might help with this daunting task of typing are in the TypeDeclaration section:
Good luck! |
Ah I wasn't aware it did type inference too, thanks, will definitely try that before wasting anyone's time doing it by hand :) |
Hm yeah so I tried rector and the output is just way too wild and inaccurate to be useful, I end up having to double check everything and undo so much that it's really not saving any time IMO. I'm sure it's great at doing other things and it may well help later to convert docblocks to real types once we support php 7.2+. So back to the OP plan :) |
Sorry that it didn't work, I haven't had a chance to test it but I was hoping it could be useful. Good luck then! |
Well, Rector might help for next steps (adding type info in methods) once the properties have types. The main issue today is that all types are missing. |
@stof do you mean PHP 7.4 style types properties? Because that's a long way out.. As for var annotations as i wrote in the op i did spend time typing all properties throughout the codebase, which should be enough for static analysis and tools like rector. But it seems to do too much magic with other things which isn't desirable IMO. Maybe I'll try to run it again only with one or two very specific rules. |
@Seldaek no, I'm not talking about PHP 7.4 typed properties here, just about property types from any source. |
Working on src/Composer/Command |
Working on DependencyResolver .. |
@imme-emosol make sure you rebase on latest |
Maybe it could be handy to make an extra checkbox to indicate if a namespace has been merged? Nevermind, that is what those icons are for :s |
Well, when the PR is referenced, github shows whether it is merged or no (the icon is different). And we cannot have multiple checkboxes per item in a GFM task list. |
I'll have a go on some of the tests |
I'll work on |
I'll try fixing the Command test. |
As I see the Fixtures and IO tests has no errors and can be marked as done. |
Happy to take a look at |
BTW for everyone working on tests, if you see dataProvider methods which PHPStan complains about, I'd say instead of adding types feel free to rename them to @megubyte all yours, I marked them claimed now. |
I'll take a go on Mock test |
I'll grap Platform and Plugin tests as well |
I'll work on |
I'll go for |
Alright we are done here, level 6 is now enabled! Many many thanks to everyone involved here writing and reviewing PRs, that was a great help! Now only 770 errors left to level 7 |
Seldaek commentedOct 14, 2021
•
edited
I have laid down the ground work for reaching level 6 by typing all class properties and interface methods throughout the codebase, which should already help ensure that types are correct when they get added/copied to getters and such.
I definitely could use help though in reaching level 6, because it's a ton of work left (1465 errors for
src/
, 400 errors fortests/
).If you are interested in helping, here is how to go about it:
Setup a Composer environment first if you haven't
git clone https://github.com/composer/composer
cd composer && wget https://getcomposer.org/composer.phar && php composer.phar install
Setup the env for PHPStan-usage
This requires PHP 7.4 (it won't run with php8 currently due to reasons, don't try to make it do that)
php7.4 composer.phar phpstan-setup
to get phpstan installed in the project - make sure you have a composer.phar or some global composer install to run this command with, you can't run phpstan-setup with bin/composer as it replaces parts of the vendor dir and it'll break the installRunning PHPStan
phpstan/config.neon
php7.4 vendor/bin/phpstan analyse --configuration=phpstan/config.neon src/Composer/Package/
Keep in mind
mixed
or something equally vague, leave it for someone else to fill the gap later, because reviewing the whole code to find inappropriate mixed-usage is going to be near impossible.Thanks in advance to any volunteer :)
Status
Pick one that's not checked, and claim below in comments please.
Downloader
#10193Package
#10210Package/Dumper
#10198Package/Loader
#10206Package/Version
#10199Plugin
#10194Util
#10190Config
tests #10234EventDispatcher
tests #10235Package
tests #10245Question
tests #10219Repository
tests #10227Script
tests #10220Util
tests #10228The text was updated successfully, but these errors were encountered: