private function processClassToken(File $phpcsFile, $stackPtr)
    {
        $interfaces = PHPCSHelper::findImplementedInterfaceNames($phpcsFile, $stackPtr);

        if (\is_array($interfaces) === false || $interfaces === array()) {
            return;
        }

        $tokens       = $phpcsFile->getTokens();
        $checkMethods = false;

        if (isset($tokens[$stackPtr]['scope_closer'])) {
            $checkMethods = true;
            $scopeCloser  = $tokens[$stackPtr]['scope_closer'];
        }

        foreach ($interfaces as $interface) {
            $interface   = ltrim($interface, '\\');
            $interfaceLc = strtolower($interface);

            if (isset($this->newInterfaces[$interfaceLc]) === true) {
                $itemInfo = array(
                    'name'   => $interface,
                    'nameLc' => $interfaceLc,
                );
                $this->handleFeature($phpcsFile, $stackPtr, $itemInfo);
            }

            if ($checkMethods === true && isset($this->unsupportedMethods[$interfaceLc]) === true) {
                $nextFunc = $stackPtr;
                while (($nextFunc = $phpcsFile->findNext(\T_FUNCTION, ($nextFunc + 1), $scopeCloser)) !== false) {
                    $funcName   = $phpcsFile->getDeclarationName($nextFunc);
                    $funcNameLc = strtolower($funcName);
                    if ($funcNameLc === '') {
                        continue;
                    }

                    if (isset($this->unsupportedMethods[$interfaceLc][$funcNameLc]) === true) {
                        $error     = 'Classes that implement interface %s do not support the method %s(). See %s';
                        $errorCode = $this->stringToErrorCode($interface) . 'UnsupportedMethod';
                        $data      = array(
                            $interface,
                            $funcName,
                            $this->unsupportedMethods[$interfaceLc][$funcNameLc],
                        );

                        $phpcsFile->addError($error, $nextFunc, $errorCode, $data);
                    }
                }
            }
        }
    }
private function processClassToken(File $phpcsFile, $stackPtr)
    {
        $interfaces = PHPCSHelper::findImplementedInterfaceNames($phpcsFile, $stackPtr);

        if (\is_array($interfaces) === false || $interfaces === array()) {
            return;
        }

        $tokens       = $phpcsFile->getTokens();
        $checkMethods = false;

        if (isset($tokens[$stackPtr]['scope_closer'])) {
            $checkMethods = true;
            $scopeCloser  = $tokens[$stackPtr]['scope_closer'];
        }

        foreach ($interfaces as $interface) {
            $interface   = ltrim($interface, '\\');
            $interfaceLc = strtolower($interface);

            if (isset($this->newInterfaces[$interfaceLc]) === true) {
                $itemInfo = array(
                    'name'   => $interface,
                    'nameLc' => $interfaceLc,
                );
                $this->handleFeature($phpcsFile, $stackPtr, $itemInfo);
            }

            if ($checkMethods === true && isset($this->unsupportedMethods[$interfaceLc]) === true) {
                $nextFunc = $stackPtr;
                while (($nextFunc = $phpcsFile->findNext(\T_FUNCTION, ($nextFunc + 1), $scopeCloser)) !== false) {
                    $funcName   = $phpcsFile->getDeclarationName($nextFunc);
                    $funcNameLc = strtolower($funcName);
                    if ($funcNameLc === '') {
                        continue;
                    }

                    if (isset($this->unsupportedMethods[$interfaceLc][$funcNameLc]) === true) {
                        $error     = 'Classes that implement interface %s do not support the method %s(). See %s';
                        $errorCode = $this->stringToErrorCode($interface) . 'UnsupportedMethod';
                        $data      = array(
                            $interface,
                            $funcName,
                            $this->unsupportedMethods[$interfaceLc][$funcNameLc],
                        );

                        $phpcsFile->addError($error, $nextFunc, $errorCode, $data);
                    }
                }
            }
        }
    }
private function processClassToken ( File $ phpcsFile , $ stackPtr ) { $ interfaces = PHPCSHelper :: findImplementedInterfaceNames ( $ phpcsFile , $ stackPtr ) ; if ( \ is_array ( $ interfaces ) === false || $ interfaces === array ( ) ) { return ; } $ tokens = $ phpcsFile -> getTokens ( ) ; $ checkMethods = false ; if ( isset ( $ tokens [ $ stackPtr ] [ 'scope_closer' ] ) ) { $ checkMethods = true ; $ scopeCloser = $ tokens [ $ stackPtr ] [ 'scope_closer' ] ; } foreach ( $ interfaces as $ interface ) { $ interface = ltrim ( $ interface , '\\' ) ; $ interfaceLc = strtolower ( $ interface ) ; if ( isset ( $ this -> newInterfaces [ $ interfaceLc ] ) === true ) { $ itemInfo = array ( 'name' => $ interface , 'nameLc' => $ interfaceLc , ) ; $ this -> handleFeature ( $ phpcsFile , $ stackPtr , $ itemInfo ) ; } if ( $ checkMethods === true && isset ( $ this -> unsupportedMethods [ $ interfaceLc ] ) === true ) { $ nextFunc = $ stackPtr ; while ( ( $ nextFunc = $ phpcsFile -> findNext ( \ T_FUNCTION , ( $ nextFunc + 1 ) , $ scopeCloser ) ) !== false ) { $ funcName = $ phpcsFile -> getDeclarationName ( $ nextFunc ) ; $ funcNameLc = strtolower ( $ funcName ) ; if ( $ funcNameLc === '' ) { continue ; } if ( isset ( $ this -> unsupportedMethods [ $ interfaceLc ] [ $ funcNameLc ] ) === true ) { $ error = 'Classes that implement interface %s do not support the method %s(). See %s' ; $ errorCode = $ this -> stringToErrorCode ( $ interface ) . 'UnsupportedMethod' ; $ data = array ( $ interface , $ funcName , $ this -> unsupportedMethods [ $ interfaceLc ] [ $ funcNameLc ] , ) ; $ phpcsFile -> addError ( $ error , $ nextFunc , $ errorCode , $ data ) ; } } } } }
Processes this test for when a class token is encountered.

- Detect classes implementing the new interfaces.
- Detect classes implementing the new interfaces with unsupported functions.

@param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
@param int                   $stackPtr  The position of the current token in
the stack passed in $tokens.

@return void
Processes this test for when a class token is encountered .