getDeclarationName($stackPtr); $className = $phpcsFile->getDeclarationName($currScope); $errorData = [$className . '::' . $methodName]; // Ignore magic methods if (preg_match('/^__(' . implode('|', $this->_magicMethods) . ')$/', $methodName)) { return; } $methodProps = $phpcsFile->getMethodProperties($stackPtr); if ($methodProps['scope_specified'] === false) { // Let another sniffer take care of that return; } $isPublic = $methodProps['scope'] === 'public'; if ($isPublic === true && $methodName[0] === '_') { $error = 'Public method name "%s" must not be prefixed with underscore'; $phpcsFile->addError($error, $stackPtr, 'PublicWithUnderscore', $errorData); return; } } /** * {@inheritDoc} */ protected function processTokenOutsideScope(File $phpcsFile, $stackPtr) { } }