diff --git a/composer.json b/composer.json index da9c04f7..305be29f 100644 --- a/composer.json +++ b/composer.json @@ -37,8 +37,8 @@ "assetic/framework": "^3.2.3", "doctrine/dbal": "^3.0", "enshrined/svg-sanitize": "~1.0", - "laravel/framework": "^12.30.1", - "laravel/tinker": "^2.8.1", + "laravel/framework": "^12.30.1|^13.0", + "laravel/tinker": "^2.8.1|^3.0", "league/commonmark": "^2.10.2", "league/csv": "~9.1", "nesbot/carbon": "^3.0", @@ -58,13 +58,14 @@ "meyfa/phpunit-assert-gd": "^4.2", "mockery/mockery": "^1.6|^2.0", "dms/phpunit-arraysubset-asserts": "dev-add-phpunit-11-support", - "orchestra/testbench": "^10.0", + "orchestra/testbench": "^10.0|^11.0", "larastan/larastan": "^3.6.0" }, "repositories": [ { "type": "vcs", - "url": "https://github.com/pieterocp/phpunit-arraysubset-asserts" + "url": "https://github.com/pieterocp/phpunit-arraysubset-asserts", + "no-api": true } ], "suggest": { diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 15e13044..a53ba4eb 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -850,7 +850,7 @@ parameters: path: src/Support/Testing/Fakes/MailFake.php - - message: '#^Parameter \#2 \$data \(array\) of method Winter\\Storm\\Support\\Testing\\Fakes\\MailFake\:\:queue\(\) should be compatible with parameter \$queue \(string\|null\) of method Illuminate\\Support\\Testing\\Fakes\\MailFake\:\:queue\(\)$#' + message: '#^Parameter \#2 \$data \(array\) of method Winter\\Storm\\Support\\Testing\\Fakes\\MailFake\:\:queue\(\) should be compatible with parameter \$queue \((BackedEnum\|)?string\|null\) of method Illuminate\\Support\\Testing\\Fakes\\MailFake\:\:queue\(\)$#' identifier: method.childParameterType path: src/Support/Testing/Fakes/MailFake.php diff --git a/src/Database/Traits/ArraySource.php b/src/Database/Traits/ArraySource.php index 1c9e09fe..690e1c6e 100644 --- a/src/Database/Traits/ArraySource.php +++ b/src/Database/Traits/ArraySource.php @@ -29,7 +29,7 @@ trait ArraySource /** * Connection. to the SQLite datasource. */ - protected static \Illuminate\Database\Connection $arraySourceConnection; + protected static ?\Illuminate\Database\Connection $arraySourceConnection = null; /** * Boots the ArraySource trait. @@ -40,6 +40,17 @@ public static function bootArraySource(): void throw new ApplicationException('You must enable the SQLite PDO driver to use the ArraySource trait'); } + static::$arraySourceConnection = null; + } + + /** + * Creates the temporary SQLite datasource for this model. + * + * Laravel 13 throws a LogicException when a model is instantiated while it is booting, so this runs the first + * time the connection is resolved instead of in `bootArraySource()`. + */ + protected static function arraySourceBootConnection(): void + { $instance = new static; static::arraySourceSetDbConnection( @@ -79,6 +90,10 @@ public function getRecords() */ public static function resolveConnection($connection = null) { + if (static::$arraySourceConnection === null) { + static::arraySourceBootConnection(); + } + return static::$arraySourceConnection; }