Closed staabm closed 6 months ago
@kukulich it looks like it doesn't improve mutations. I guess phpdoc-types are not useful for that (and only native types are taken into account?)
Phpdoc types are considered: need to likely checked in more depth 🤔
Thanks for trying though!
@staabm
I think this can work:
$startLine = $node->getStartLine()
if ($startLine !== -1) {
$this->startLine = $startLine;
}
No assert
-> no mutation and no mutant :) Psalm/Phpstan should be happy too thanks to your change in PhpParser.
The current solution probably does not work because if ($node->hasAttribute('startLine')) {
does not tell Psalm that $node->getStartLine()
is only positive-int. That's why the assert
is not reported by Psalm as useless.
Thank you. I will give your idea a try tomorrow
(Btw: the php-parser PR was merged)
the psalm error is a bug, reported in https://github.com/vimeo/psalm/issues/10826
It looks it's very complicated to kill one mutant 😄
It looks it's very complicated to kill one mutant 😄
hehe - agree, its a lot of change. but I feel the code is easier to read after the PR.
I feel the code is easier to read after the PR.
I agree :)
@Ocramius mutants will be killed on the next php-parser release. I think its good to go.
Thanks @staabm!
Btw: notice the reduction in mutations: that really says a lot whenever we refactor :)
lets see how https://github.com/nikic/PHP-Parser/pull/985 affects mutations
refs https://github.com/Roave/BetterReflection/issues/1382