diff --git a/src/Init.php b/src/Init.php
index 504f76de690dc0853dd3ee8e33433b32049e563d..5b0a8694404a3175b6c3c0c6da2d12d1f7ffb85c 100644
--- a/src/Init.php
+++ b/src/Init.php
@@ -48,13 +48,18 @@ final class Init {
 		}
 	}
 
-	public function boot() {
+	/**
+	 * @param string|null $filename Filename of the booted plugin. May be null, if called from plugin's main file.
+	 */
+	public function boot( string? $filename = null ) {
 		if ( self::$bootable === false ) {
 			return;
 		}
 
-		$backtrace = \debug_backtrace( \DEBUG_BACKTRACE_IGNORE_ARGS, 1 );
-		$filename  = $backtrace[0]['file'];
+		if ( $filename === null ) {
+			$backtrace = \debug_backtrace( \DEBUG_BACKTRACE_IGNORE_ARGS, 1 );
+			$filename  = $backtrace[0]['file'];
+		}
 
 		$extensions = new ExtensionsSet(
 			new BuiltinExtension(),