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;
    }