tolerant-php-parser icon indicating copy to clipboard operation
tolerant-php-parser copied to clipboard

PHPStan Level 3

Open dantleech opened this issue 3 years ago • 9 comments
trafficstars

: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 opeand property on the children of UnaryExpression

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:

dantleech avatar Sep 22 '22 16:09 dantleech

Rebased my changes on main after making them on master...

dantleech avatar Sep 22 '22 18:09 dantleech

Updated

dantleech avatar Sep 23 '22 08:09 dantleech

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.

roblourens avatar Sep 25 '22 02:09 roblourens

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 operand property on the children of UnaryExpression

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.

TysonAndre avatar Sep 25 '22 13:09 TysonAndre

Updated and squashed

dantleech avatar Sep 25 '22 17:09 dantleech

 ------ ---------------------------------------------------------------------- 
  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?

TysonAndre avatar Sep 25 '22 17:09 TysonAndre

Property declarations should say MissingToken now?

seems like it:

https://github.com/dantleech/tolerant-php-parser/blob/9bcf16fb6da32c6d504d9e1e5b0dcfe0762efdd5/src/Parser.php#L3544

updated

dantleech avatar Sep 25 '22 18:09 dantleech

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.

dantleech avatar Sep 28 '22 17:09 dantleech

appologetic ping cc @roblourens

dantleech avatar Oct 15 '22 08:10 dantleech

...

dantleech avatar Nov 11 '22 21:11 dantleech

Sorry @dantleech. Will take a look ASAP

roblourens avatar Nov 17 '22 17:11 roblourens

No pressure :) thanks.

dantleech avatar Nov 17 '22 17:11 dantleech