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

SuperfluousTraitNaming is ignoring phpcsSuppress annotation #1720

Open
utdrmac opened this issue Jan 8, 2025 · 1 comment
Open

SuperfluousTraitNaming is ignoring phpcsSuppress annotation #1720

utdrmac opened this issue Jan 8, 2025 · 1 comment

Comments

@utdrmac
Copy link

utdrmac commented Jan 8, 2025

How do I correctly suppress this? CakePHP requires traits to have the suffix 'Trait' so I want to ignore this.

<?php
declare(strict_types=1);

namespace App\Model\Table;

/**
 * This trait naming pattern follows CakePHP conventions, so ignore PHPCS warning
 *
 * @phpcsSuppress SlevomatCodingStandard.Classes.SuperfluousTraitNaming.SuperfluousSuffix
 */
trait VariablesTableTrait
{
}
$ vendor/squizlabs/php_codesniffer/bin/phpcs -s src/Model/Table/VariablesTableTrait.php

FILE: /app/src/Model/Table/VariablesTableTrait.php
--------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------------------------------------------
 11 | ERROR | Superfluous suffix "Trait". (SlevomatCodingStandard.Classes.SuperfluousTraitNaming.SuperfluousSuffix)
--------------------------------------------------------------------------------------------------------------------
@utdrmac
Copy link
Author

utdrmac commented Jan 8, 2025

It seems the syntax has changed. This worked:

<?php
declare(strict_types=1);

namespace App\Model\Table;

/**
 * This trait naming pattern follows CakePHP conventions, so ignore PHPCS warning
 *
 * phpcs:disable SlevomatCodingStandard.Classes.SuperfluousTraitNaming.SuperfluousSuffix
 */
trait VariablesTableTrait
{
}

Please update the README and other examples that still use @phpcsSuppress as this no longer seems to be the correct syntax. https://github.com/squizlabs/PHP_CodeSniffer/wiki/Advanced-Usage#ignoring-parts-of-a-file

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

No branches or pull requests

1 participant