fix: work around l12 breaking change (#43)

* fix: work around l12 breaking change

* build: fix testing job to switch properly

* build: provide proper versions that support laravel version switching

these only to allow switching without problems. The main tooling chain will be using the latest versions.
This commit is contained in:
Mazen Touati
2026-01-24 02:09:27 +01:00
committed by GitHub
parent 6cff0e9ebd
commit 562b02d207
3 changed files with 17 additions and 9 deletions

View File

@@ -63,7 +63,7 @@ jobs:
- name: Install dependencies
if: needs.changes.outputs.php == 'true'
run: |
composer switch l:${{ matrix.laravel }} -- -- --no-interaction --no-progress --ansi
composer switch:l${{ matrix.laravel }} -- -- --no-interaction --no-progress --ansi
composer dump-autoload --optimize
- name: Execute tests with coverage

View File

@@ -27,7 +27,7 @@
"spatie/laravel-package-tools": "^1.16"
},
"require-dev": {
"brianium/paratest": "^7.0||^7.8",
"brianium/paratest": "^7.0 || ^8.0",
"larastan/larastan": "^2.9||^3.0",
"laravel/pint": "^1.14",
"nunomaduro/collision": "^8.1||^7.10",
@@ -35,7 +35,7 @@
"phpstan/extension-installer": "^1.3||^2.0",
"phpstan/phpstan-deprecation-rules": "^1.1||^2.0",
"phpunit/phpunit": "^10.1||^11.5.3",
"rector/rector": "^2.2",
"rector/rector": "^1.2 || ^2.2",
"spatie/laravel-data": "^4.18"
},
"autoload": {

View File

@@ -10,22 +10,30 @@ class DumpAndDieResponse extends Response
{
public const DUMP_AND_DIE_STATUS_CODE = 999;
public function __construct($response)
{
parent::__construct($response);
$this->preDecodeBody((string) $this->response->getBody());
}
public function getStatusCode(): int
{
return self::DUMP_AND_DIE_STATUS_CODE;
}
/**
* @return array<string, string|array<array-key, mixed>>
*/
public function json($key = null, $default = null): array
private function preDecodeBody(string $body): void
{
// Normally, we would overwrite the `->json` method. But there was a breaking change to the method in L12.48.
// If we overwrite the new `->json` and conform its new signature, we lose support for earlier versions.
// Instead, we need to pre-decode the body so that when calling ->json() it will use the below array.
[
'source' => $source,
'dumps' => $dumps,
] = resolve(VarDumpParser::class)->parse($this->response->getBody())->toArray();
] = resolve(VarDumpParser::class)->parse($body)->toArray();
return [
$this->decoded = [
'id' => Str::uuid()->toString(),
'timestamp' => now()->format('Y-m-d H:i:s'),
'source' => $source,