West/Sniffs/Functions/GlobalFunctionSniff.php
public function process(File $phpcsFile, $stackPtr)
    {
        $tokens = $phpcsFile->getTokens();

        if (empty($tokens[$stackPtr]['conditions']) === true) {
            $functionName = $phpcsFile->getDeclarationName($stackPtr);
            if ($functionName === null) {
                return;
            }

            // Special exception for __autoload as it needs to be global.
            if ($functionName !== '__autoload') {
                $error = 'Global function "%s" is not allowed';
                $data  = [$functionName];
                $phpcsFile->addError($error, $stackPtr, 'Found', $data);
            }
        }
    }
public function process(File $phpcsFile, $stackPtr)
    {
        $tokens = $phpcsFile->getTokens();

        if (empty($tokens[$stackPtr]['conditions']) === true) {
            $functionName = $phpcsFile->getDeclarationName($stackPtr);
            if ($functionName === null) {
                return;
            }

            // Special exception for __autoload as it needs to be global.
            if ($functionName !== '__autoload') {
                $error = 'Global function "%s" is not allowed';
                $data  = [$functionName];
                $phpcsFile->addError($error, $stackPtr, 'Found', $data);
            }
        }
    }
public function process ( File $ phpcsFile , $ stackPtr ) { $ tokens = $ phpcsFile -> getTokens ( ) ; if ( empty ( $ tokens [ $ stackPtr ] [ 'conditions' ] ) === true ) { $ functionName = $ phpcsFile -> getDeclarationName ( $ stackPtr ) ; if ( $ functionName === null ) { return ; } // Special exception for __autoload as it needs to be global. if ( $ functionName !== '__autoload' ) { $ error = 'Global function "%s" is not allowed' ; $ data = [ $ functionName ] ; $ phpcsFile -> addError ( $ error , $ stackPtr , 'Found' , $ data ) ; } } }
{@inheritdoc}
{