protected function ensureCanDefine(Stmt $stmt, $scopeType = self::CLASS_TYPE)
    {
        $name = $this->getFullyQualifiedName($stmt->name);

        // check for name collisions
        $errorType = null;
        if ($this->classExists($name)) {
            $errorType = self::CLASS_TYPE;
        } elseif ($this->interfaceExists($name)) {
            $errorType = self::INTERFACE_TYPE;
        } elseif ($this->traitExists($name)) {
            $errorType = self::TRAIT_TYPE;
        }

        if ($errorType !== null) {
            throw $this->createError(\sprintf('%s named %s already exists', \ucfirst($errorType), $name), $stmt);
        }

        // Store creation for the rest of this code snippet so we can find local
        // issue too
        $this->currentScope[\strtolower($name)] = $scopeType;
    }
protected function ensureCanDefine(Stmt $stmt, $scopeType = self::CLASS_TYPE)
    {
        $name = $this->getFullyQualifiedName($stmt->name);

        // check for name collisions
        $errorType = null;
        if ($this->classExists($name)) {
            $errorType = self::CLASS_TYPE;
        } elseif ($this->interfaceExists($name)) {
            $errorType = self::INTERFACE_TYPE;
        } elseif ($this->traitExists($name)) {
            $errorType = self::TRAIT_TYPE;
        }

        if ($errorType !== null) {
            throw $this->createError(\sprintf('%s named %s already exists', \ucfirst($errorType), $name), $stmt);
        }

        // Store creation for the rest of this code snippet so we can find local
        // issue too
        $this->currentScope[\strtolower($name)] = $scopeType;
    }
protected function ensureCanDefine ( Stmt $ stmt , $ scopeType = self :: CLASS_TYPE ) { $ name = $ this -> getFullyQualifiedName ( $ stmt -> name ) ; // check for name collisions $ errorType = null ; if ( $ this -> classExists ( $ name ) ) { $ errorType = self :: CLASS_TYPE ; } elseif ( $ this -> interfaceExists ( $ name ) ) { $ errorType = self :: INTERFACE_TYPE ; } elseif ( $ this -> traitExists ( $ name ) ) { $ errorType = self :: TRAIT_TYPE ; } if ( $ errorType !== null ) { throw $ this -> createError ( \ sprintf ( '%s named %s already exists' , \ ucfirst ( $ errorType ) , $ name ) , $ stmt ) ; } // Store creation for the rest of this code snippet so we can find local // issue too $ this -> currentScope [ \ strtolower ( $ name ) ] = $ scopeType ; }
Ensure that no class, interface or trait name collides with a new definition.

@throws FatalErrorException

@param Stmt   $stmt
@param string $scopeType
Ensure that no class interface or trait name collides with a new definition .