Skip to content

SlevomatCodingStandard.Classes.ClassMemberSpacing: Prevent deleting code #1756

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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 2 times, most recently from 9e529bb to 72664cd Compare May 27, 2025 11:51
@maryo maryo force-pushed the class-member-spacing-stop-deleting-code branch from 72664cd to 7465e39 Compare May 27, 2025 12:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant