Skip to content

Conversation

maryo
Copy link
Contributor

@maryo maryo commented May 25, 2025

Given this code

private int $property;


/**
 * Description
 */

public function method(): void
{
}

The sniff deleted the docblock entirely because there is (quite unexpected, still a valid docblock though) newline after it.

Also, there could be some extra comments like this:

private int $property;

// Extra comment

/**
 * Description
 */
public function method(): void
{
}

I'm not sure what the ideal solution would be here. I changed it so that the extra comment is considered part of the method.

But there could even be some unexpected code (it would be probably invalid though) which should not get deleted either. In such case, i disabled the fix and just report it as an error.

@maryo maryo force-pushed the class-member-spacing-stop-deleting-code branch from 6f4683d to 299b229 Compare May 25, 2025 15:53
@maryo maryo changed the title SlevomatCodingStandard.Classes.ClassMemberSpacing: Stop deleting code SlevomatCodingStandard.Classes.ClassMemberSpacing: Prevent deleting code May 25, 2025
@maryo maryo force-pushed the class-member-spacing-stop-deleting-code branch 3 times, most recently from 72664cd to 7465e39 Compare May 27, 2025 12:11
@kukulich
Copy link
Contributor

kukulich commented Jun 7, 2025

Thanks.

@kukulich kukulich force-pushed the class-member-spacing-stop-deleting-code branch from 7465e39 to e58a90b Compare June 7, 2025 07:05
@kukulich kukulich merged commit 999d563 into slevomat:master Jun 7, 2025
35 checks passed
@kukulich kukulich added the Bug label Jun 7, 2025
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.

2 participants