Skip to content
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

Request coverage reports with command line args #1375

Conversation

sanmai
Copy link
Member

@sanmai sanmai commented Oct 26, 2020

This PR:

What left to do with #1283:

  • There has to be a test with new schema.
  • New-style coverage "whitelist" adder has to be dealt with (addCoverageFilterWhitelistIfDoesNotExist).


$this->tmpDir = $tmpDir;
$this->jUnitFilePath = $jUnitFilePath;
}
Copy link
Member Author

@sanmai sanmai Oct 26, 2020

Choose a reason for hiding this comment

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

Extending constructors does not break the LSP.

@@ -52,7 +52,7 @@ public function build(string $configPath, string $extraOptions): array
'--configuration',
$configPath,
],
explode(' ', $extraOptions)
explode(' ', $extraOptions) // FIXME might break space-containing paths
Copy link
Member Author

@sanmai sanmai Oct 26, 2020

Choose a reason for hiding this comment

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

Not fixing this issue in this PR, long enough already.

array $phpExtraArgs,
bool $skipCoverage
): array {
if ($skipCoverage === false) {
Copy link
Member

Choose a reason for hiding this comment

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

question: is it any better than !$skiptCoverage? Found a couple of places and all ones from you. I mean we usually use !$condition with booleans, probably worth unifying

Copy link
Member Author

Choose a reason for hiding this comment

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

For one, !$condition is messy, it might trigger on a null. For another, use === is more generic to all types, more uniform. What do you think?

Is there a fixer for !$bool?

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 was very hesitant about === if you remember, and I'm still not exactly on board with the arguments I've seen back then. True, it can be ugly when comparing strings and numbers, for example, but the real reason I'm using === everywhere effectively out of habit now because it prevents unnecessary and avoidable BC breaks.

It is not like someone would extend the very this class, but if this happens, identical comparison gets us prepared. For example, if you were using !$condition and someone extending extending this class decides put a different falsy value here, you can't really change it to something else without a BC break. Say, you want to give a null special meaning? Well, you can't, because null is falsy. On the contrary, if you use $condition === false, you're protected from said BC breaks. Add any nulls anytime you want! That's the reason. Makes sense?

Copy link
Member

Choose a reason for hiding this comment

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

makes sense

I know the reason why it looks weird for me, because I've been using phpstan with strict rules for 2 years on my job, and it's impossible to use non-boolean comparison there.

Look at this code with strict rules:

$null = rand(0, 1) === 0 ? null : true;
		
if (!$null) {
			
}

error: Only booleans are allowed in a negated boolean, true|null given.. So if it's nullable - makes sense to use === true, but when it's bool only - it's safe to use just !$null here.

Regarding your example, I guess it's impossible to do it: https://phpstan.org/r/b07764ac-22c8-4c06-ad83-a19ba9e09381 - we can pass only booleans to the parent (original) method.

Anyway, it's not critical, we can leave it. Just not usual usage for me, that's why I asked.

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure. It's nice to have PHPStan warn you about improper negation, but it's a liability nevertheless. E.g. where negation can be improper, === is always safe to use.

@sanmai sanmai merged commit 0db4bce into infection:master Oct 26, 2020
PHPUnit 9.3 compatibility automation moved this from In progress to Done Oct 26, 2020
@sanmai sanmai deleted the pr/2020-10/request-coverage-with-command-line-args branch October 26, 2020 22:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

None yet

2 participants