tolerant-php-parser
tolerant-php-parser copied to clipboard
PHPStan Level 3
:wave: in Phpactor one of the most common types of error is accessing a member on NULL on TP parser nodes. So I thought I'd try and increase the type coverage.
This PR:
- Updates PHPStan to level 3.
- Fixes type hints (avoiding refactoring code).
- Adds PHPStan as a dev dependency (it ships as a PHAR now, so no conflicts).
- Removes the overridden public
opeandproperty on the children ofUnaryExpression
As a follow up question is it worth ditching Travis and adding PHPStan to the main GHA workflow?
We should be able to get to PHPStan level 5 pretty easy (30 errors) but level 6 is 368 errors :sweat_smile:
Rebased my changes on main after making them on master...
Updated
And yeah, if we can get all the same stuff into github actions that exists in Travis, I would like to get rid of Travis.
This should be rebased against main now that other changes were merged yesterday, to re-run tests/analysis steps. Optionally, It'd be useful to also squash changes (https://git-scm.com/book/en/v2/Git-Tools-Rewriting-History Squashing Commits) either here or when maintainers merge this in the web ui
Other than not being rebased, all of the changes here should be safe to release, though I'd rather release 0.1.2 first if you expect merging this to delay the process of publishing a release - 0.1.2 is getting rather large
Removes the overridden public
operandproperty on the children ofUnaryExpression
Looks correct and the property is still declared on the subclasses. Double checking: This is confirmed by the fact that tests continue to pass, so CHILD_NAMES obviously still refers to properties that exist.
Updated and squashed
------ ----------------------------------------------------------------------
Line Parser.php
------ ----------------------------------------------------------------------
3544 Property
Microsoft\PhpParser\Node\Statement\NamespaceDefinition::$name
(Microsoft\PhpParser\Node\QualifiedName|null) does not accept
Microsoft\PhpParser\MissingToken.
3579 Property Microsoft\PhpParser\Node\NamespaceUseClause::$namespaceName
(Microsoft\PhpParser\Node\QualifiedName) does not accept
Microsoft\PhpParser\MissingToken.
Property declarations should say MissingToken now?
Property declarations should say MissingToken now?
seems like it:
https://github.com/dantleech/tolerant-php-parser/blob/9bcf16fb6da32c6d504d9e1e5b0dcfe0762efdd5/src/Parser.php#L3544
updated
FTR I've created a PR on my repo against this branch for level 4: https://github.com/dantleech/tolerant-php-parser/pull/1 although probably best to merge this first before reviewing.
appologetic ping cc @roblourens
...
Sorry @dantleech. Will take a look ASAP
No pressure :) thanks.