squizlabs / PHP_CodeSniffer

PHP_CodeSniffer tokenizes PHP files and detects violations of a defined set of coding standards.
BSD 3-Clause "New" or "Revised" License
10.66k stars 1.48k forks source link

PSR1.Methods.CamelCapsMethodName property to allowe some exceptions #2343

Open praad opened 5 years ago

praad commented 5 years ago

Hello, Is there any property to allow some special function names against PSR1.Methods.CamelCapsMethodName sniff?

Our framework has some underscored function names can not be changed so some exceptions would be quite good like this:

`

<rule ref="PSR1.Methods.CamelCapsMethodName">
    <properties>
        <property name="exceptions" value="on_start, ..." />
    </properties>
</rule>`
mwgamble commented 5 years ago

You should use phpcs:ignore or phpcs:disable comments inside the relevant files to disable the lints specifically for the relevant methods. You can find out more about this in the project's wiki: https://github.com/squizlabs/PHP_CodeSniffer/wiki/Advanced-Usage#ignoring-parts-of-a-file

gsherwood commented 5 years ago

Sorry, I missed this one. The ignore comments are the only way of doing this right now. The sniff does not support a list of exceptions.