Repository: InsertKoinIO/koin
File: projects/compose/koin-compose/src/commonMain/kotlin/org/koin/compose/KoinApplication.kt (Kotlin)

Code before:
fun currentKoinScope(): Scope = currentComposer.run {
    try {
        val currentScope = consume(LocalKoinScopeContext).getValue()
        if (currentScope.closed) consume(LocalKoinScopeContext).resetValue() ?: error("Can't get Koin scope. Scope '$currentScope' is closed")
        else currentScope
    } catch (e: Exception) {
        consume(LocalKoinScopeContext).resetValue()
            ?: error("Can't get Koin scope due to error: $e")
    }
}

/**
 * Start a new Koin Application context and setup Compose context
 * if Koin's Default Context is already set, throw an error
 *
 * @param application - Koin Application declaration lambda
 * @param content - following compose function
 *
 * @throws org.koin.core.error.KoinApplicationAlreadyStartedException
 *
 * @author Arnaud Giuliani
 */
@Deprecated(
    message = "Use KoinApplication(config: KoinConfiguration) with koinConfiguration { } instead of KoinAppDeclaration lambda",
    replaceWith = ReplaceWith(
        "KoinApplication(config = koinConfiguration(application), content = content)",
        "org.koin.dsl.koinConfiguration"
    ),
    level = DeprecationLevel.WARNING
)
@OptIn(KoinInternalApi::class)
@Composable
fun KoinApplication(
    application: KoinAppDeclaration,
    content: @Composable () -> Unit
) {
    val koin = rememberKoinApplication(application)
    CompositionLocalProvider(
        LocalKoinApplicationContext provides ComposeContextWrapper(koin) { getDefaultKoinContext() },
        LocalKoinScopeContext provides ComposeContextWrapper(koin.scopeRegistry.rootScope) { getDefaultRootScope() },
        content = content
    )
}

/**
 * Start a new Koin Application context and setup Compose context.
 *
 * This is the unified entry point for Koin in Compose applications (Android, iOS, Desktop, Web).
 * Automatically configures:
 * - Android: injects applicationContext and sets up androidLogger
 * - Other platforms: sets up printLogger

Review comment (suggestion):
The ReplaceWith suggestion uses `config` as the parameter name, but the new unified `KoinApplication` function uses `configuration` as the parameter name. This mismatch will cause compilation errors if users apply the suggested replacement.

Change `config = koinConfiguration(application)` to `configuration = koinConfiguration(application)` in the ReplaceWith.
```suggestion
        "KoinApplication(configuration = koinConfiguration(application), content = content)",
```

Code after:
fun currentKoinScope(): Scope = currentComposer.run {
    try {
        val currentScope = consume(LocalKoinScopeContext).getValue()
        if (currentScope.closed) consume(LocalKoinScopeContext).resetValue() ?: error("Can't get Koin scope. Scope '$currentScope' is closed")
        else currentScope
    } catch (e: Exception) {
        consume(LocalKoinScopeContext).resetValue()
            ?: error("Can't get Koin scope due to error: $e")
    }
}

/**
 * Start a new Koin Application context and setup Compose context
 * if Koin's Default Context is already set, throw an error
 *
 * @param application - Koin Application declaration lambda
 * @param content - following compose function
 *
 * @throws org.koin.core.error.KoinApplicationAlreadyStartedException
 *
 * @author Arnaud Giuliani
 */
@Deprecated(
    message = "Use KoinApplication(config: KoinConfiguration) with koinConfiguration { } instead of KoinAppDeclaration lambda",
    replaceWith = ReplaceWith(
        "KoinApplication(configuration = koinConfiguration(application), content = content)",
        "org.koin.dsl.koinConfiguration"
    ),
    level = DeprecationLevel.WARNING
)
@OptIn(KoinInternalApi::class)
@Composable
fun KoinApplication(
    application: KoinAppDeclaration,
    content: @Composable () -> Unit
) {
    val koin = rememberKoinApplication(application)
    CompositionLocalProvider(
        LocalKoinApplicationContext provides ComposeContextWrapper(koin) { getDefaultKoinContext() },
        LocalKoinScopeContext provides ComposeContextWrapper(koin.scopeRegistry.rootScope) { getDefaultRootScope() },
        content = content
    )
}

/**
 * Start a new Koin Application context and setup Compose context.
 *
 * This is the unified entry point for Koin in Compose applications (Android, iOS, Desktop, Web).
 * Automatically configures:
 * - Android: injects applicationContext and sets up androidLogger
 * - Other platforms: sets up printLogger