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

fix: PhpUnitTestClassRequiresCoversFixer - attribute detection when class is readonly #8042

Conversation

kubawerlos
Copy link
Contributor

Follow up to #8016

@coveralls
Copy link

coveralls commented May 24, 2024

Coverage Status

coverage: 95.648%. remained the same
when pulling 53d642c on 6b7562617765726c6f73:fix_PhpUnitTestClassRequiresCoversFixer
into efa07e3 on PHP-CS-Fixer:master.

@kubawerlos kubawerlos enabled auto-merge (squash) May 24, 2024 20:09
Copy link
Member

@Wirone Wirone left a comment

Choose a reason for hiding this comment

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

We really need that modifier rewinding logic extracted somewhere, as this is spread across the codebase in several places now.

@Wirone Wirone force-pushed the fix_PhpUnitTestClassRequiresCoversFixer branch from 88a78d4 to 53d642c Compare May 26, 2024 07:39
@kubawerlos kubawerlos merged commit 9dee44e into PHP-CS-Fixer:master May 26, 2024
28 checks passed
@kubawerlos kubawerlos deleted the fix_PhpUnitTestClassRequiresCoversFixer branch May 26, 2024 08:13
@Wirone
Copy link
Member

Wirone commented May 26, 2024

Thanks @kubawerlos 🍻

@@ -153,13 +153,20 @@ private static function isPreventedByAttribute(Tokens $tokens, int $index, array
return false;
}

$attributeIndex = $tokens->getPrevMeaningfulToken($index);
if (!$tokens[$attributeIndex]->isGivenKind(CT::T_ATTRIBUTE_CLOSE)) {
$modifiers = [T_FINAL];
Copy link
Member

Choose a reason for hiding this comment

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

potentially we can reuse bit of getDocBlockIndex , where we jump directly before any final/readonly/...` to expected docblock place.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants