Skip to content

[Bug]: Silent exit 255 when a Data subclass overrides from() with a narrower return type (no error shown) #1583

@cieplik206

Description

@cieplik206

What Happened

Environment

  • PHP: 8.4.x (reproducible on 8.2+)
  • Laravel: 12.x
  • Pest: 4.1.6
  • spatie/laravel-data: 4.x
  • OS: macOS (also reproducible in CI Ubuntu)
  • Runner: php artisan test (Pest driver) and ./vendor/bin/pest

Expected behavior
Pest should surface the PHP fatal error (signature incompatibility) in the console output, so it’s clear why the process failed.

Actual behavior
The process exits with code 255 and prints no error/stack trace when invoked via php artisan test (and sometimes via pest),
making it hard to diagnose. The only way to see the fatal is to require the class directly (php -r "require 'vendor/autoload.php';
class_exists('\App\Data\DemoShippingData');"), which then shows:

Fatal error: Declaration of App\Data\DemoShippingData::from(...) must be compatible with Spatie\LaravelData\Data::from(...):
static

How to Reproduce

Minimal reproduction

  1. Fresh Laravel + Pest install.
  2. Add a single class that extends Spatie Data and overrides from with a non‑compatible return type:

// app/Data/DemoShippingData.php

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions