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

        $variableFunction = $phpcsFile->findNext(
            T_WHITESPACE,
            $stackPtr + 1,
            null,
            true,
            null,
            true
        );

        if ($variableFunction === false) {
            return;
        }

        $token = $tokens[$variableFunction];
        if ($token['type'] === 'T_VARIABLE') {
            $error   = 'Use of the "public" variable "%s" is forbidden';
            $varName = str_replace('$', '', $token['content']);
            $data    = [$varName];

            $phpcsFile->addError($error, $stackPtr, 'NotAllowed', $data);
        }
    }
public function process(File $phpcsFile, $stackPtr)
    {
        $tokens = $phpcsFile->getTokens();

        $variableFunction = $phpcsFile->findNext(
            T_WHITESPACE,
            $stackPtr + 1,
            null,
            true,
            null,
            true
        );

        if ($variableFunction === false) {
            return;
        }

        $token = $tokens[$variableFunction];
        if ($token['type'] === 'T_VARIABLE') {
            $error   = 'Use of the "public" variable "%s" is forbidden';
            $varName = str_replace('$', '', $token['content']);
            $data    = [$varName];

            $phpcsFile->addError($error, $stackPtr, 'NotAllowed', $data);
        }
    }
{@inheritdoc}