spatie / laravel-data

Powerful data objects for Laravel
https://spatie.be/docs/laravel-data/
MIT License
1.28k stars 209 forks source link

If extends is Dto, not Data, DataVarDumperCaster error occurs #833

Closed jskorlol closed 2 months ago

jskorlol commented 3 months ago

✏️ Describe the bug If extends is Dto and not Data, a DataVarDumperCaster error occurs.

The contents cannot be checked with dump or dd.

↪️ To Reproduce


    class BaseData extends Dto
    {
        public function __construct(
            public int $age,
        ) {
        }
    }

   $BaseData = new BaseData(age: 1);
   dd($BaseData);

✅ Expected behavior

Spatie\LaravelData\Support\VarDumper\DataVarDumperCaster::castDataObject(): Argument #1 ($data) must be of type Spatie\LaravelData\Contracts\TransformableData, App\Services\Transaction\Data\TransactionData given, called in /var/www/vendor/symfony/var-dumper/Cloner/AbstractCloner.php on line 370

🖥️ Versions

Laravel: 11 Laravel Data: 4.7.2 PHP: 8.3

rust17 commented 2 months ago

Hi @jskorlol. To help us better understand the problem, could you please provide more details? Specifically, it would be helpful to know:

  1. The exact steps to reproduce the issue.
  2. The expected behavior versus the actual behavior.
rubenvanassche commented 2 months ago

This should be fixed with the next version.