SlevomatCodingStandard\Sniffs\Namespaces\UseOnlyWhitelistedNamespacesSniff::process PHP Method

process() public method

public process ( PHP_CodeSniffer_File $phpcsFile, integer $usePointer )
$phpcsFile PHP_CodeSniffer_File
$usePointer integer
    public function process(PHP_CodeSniffer_File $phpcsFile, $usePointer)
    {
        if (UseStatementHelper::isAnonymousFunctionUse($phpcsFile, $usePointer) || UseStatementHelper::isTraitUse($phpcsFile, $usePointer)) {
            return;
        }
        $className = UseStatementHelper::getFullyQualifiedTypeNameFromUse($phpcsFile, $usePointer);
        if ($this->allowUseFromRootNamespace && !NamespaceHelper::isQualifiedName($className)) {
            return;
        }
        foreach ($this->getNamespacesRequiredToUse() as $namespace) {
            if (NamespaceHelper::isTypeInNamespace($className, $namespace)) {
                return;
            }
        }
        $phpcsFile->addError(sprintf('Type %s should not be used, but referenced via a fully qualified name', $className), $usePointer, self::CODE_NON_FULLY_QUALIFIED);
    }
UseOnlyWhitelistedNamespacesSniff