src/NodeVisitors/AnonymousClassReplacer.php
protected function getAnonymousClassHookIndex(array $statements)
    {
        $hookIndex = false;

        foreach ($statements as $index => $statement) {
            if (!$statement instanceof Declare_ &&
                !$statement instanceof Use_ &&
                !$statement instanceof Namespace_) {
                $hookIndex = $index;
            }
        }

        if ($hookIndex === false) {
            throw InvalidPhpCode::noValidLocationFoundToInsertClasses();
        }

        return $hookIndex;
    }
protected function getAnonymousClassHookIndex(array $statements)
    {
        $hookIndex = false;

        foreach ($statements as $index => $statement) {
            if (!$statement instanceof Declare_ &&
                !$statement instanceof Use_ &&
                !$statement instanceof Namespace_) {
                $hookIndex = $index;
            }
        }

        if ($hookIndex === false) {
            throw InvalidPhpCode::noValidLocationFoundToInsertClasses();
        }

        return $hookIndex;
    }
protected function getAnonymousClassHookIndex ( array $ statements ) { $ hookIndex = false ; foreach ( $ statements as $ index => $ statement ) { if ( ! $ statement instanceof Declare_ && ! $ statement instanceof Use_ && ! $ statement instanceof Namespace_ ) { $ hookIndex = $ index ; } } if ( $ hookIndex === false ) { throw InvalidPhpCode :: noValidLocationFoundToInsertClasses ( ) ; } return $ hookIndex ; }
Find the index of the first statement that is not a declare, use or namespace statement.

@param array $statements

@return int

@throws \Spatie\Php7to5\Exceptions\InvalidPhpCode
Find the index of the first statement that is not a declare use or namespace statement .