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

InnerFunctionsSniff should flag functions defined inside closures #3806

Closed Daimona closed 1 year ago

Daimona commented 1 year ago

InnerFunctionsSniff detects functions defined inside other functions, but not inside closures, meaning it won't report any violations for the following snippet:

$myFunc = function () {
    function test(): int {
        return 54;
    }
};

For consistency, this should be treated the same as:

function myFunc() {
    function test(): int {
        return 54;
    }
}
jrfnl commented 9 months ago

FYI: the fix for this issue is included in today's PHP_CodeSniffer 3.8.0 release.

As per #3932, development on PHP_CodeSniffer will continue in the PHPCSStandards/PHP_CodeSniffer repository. If you want to stay informed, you may want to start "watching" that repo (or watching releases from that repo).