phpstan / phpstan

PHP Static Analysis Tool - discover bugs in your code without running it!
https://phpstan.org/
MIT License
12.82k stars 866 forks source link

Doubled file path passed to analyse causing all errors reported twice #7070

Open janedbal opened 2 years ago

janedbal commented 2 years ago

Bug report

As title states. Tested on 1.5.4

Code snippet that reproduces the problem

vendor/bin/phpstan analyse --debug src/Test.php src/Test.php 
Note: Using configuration file /app/phpstan.neon.
/app/src/Test.php
/app/src/Test.php
 ------ ------------------------------------------------------------------------------------------- 
  Line   Test.php                                                                                   
 ------ ------------------------------------------------------------------------------------------- 
  4      Property Foo::$foo type has no value type specified in iterable type array.                
         💡 See: https://phpstan.org/blog/solving-phpstan-no-value-type-specified-in-iterable-type  
  4      Property Foo::$foo type has no value type specified in iterable type array.                
         💡 See: https://phpstan.org/blog/solving-phpstan-no-value-type-specified-in-iterable-type  
 ------ -------------------------------------------------------------------------------------------

Expected output

Single error reported

mergeable[bot] commented 2 years ago

This bug report is missing a link to reproduction at phpstan.org/try.

It will most likely be closed after manual review.

ondrejmirtes commented 2 years ago

One could argue that it's your mistake to pass the same file twice :) Why are you doing that?

janedbal commented 2 years ago

Yeah, it is my mistake. No big reason, I just analysed tens of files and added one file twice by mistake.

I just think it would be better behavior if phpstan would do some uniqueness check. If you disagree, feel free to close this.

ondrejmirtes commented 2 years ago

Yes, FileFinder should definitely do it 😊 I was just worried you're not following this advice: https://phpstan.org/blog/why-you-should-always-analyse-whole-project