title: PHP Spatie DTOs with sub arrays
body: <p>I'm trying to implement an endpoint for the <a href="https://docs.audd.io/streams/" rel="nofollow noreferrer">Audd audio detection API</a> (callback with a result), using <a href="https://packagist.org/packages/spatie/data-transfer-object" rel="nofollow noreferrer">Spatie's Data Transfer Object package</a> for PHP. For this, I have a <code>PlayDTO</code>, which has a <code>PlayResultDTO</code> attribute, which in turn should have an array of <code>PlayTrackDTO</code>s as a sub-attribute:</p>
  <pre><code>// PlayDTO.php
  namespace App\DTO\Play;
  use Spatie\DataTransferObject\DataTransferObject;
  
  class PlayDTO extends DataTransferObject
  {
      public string $status;
      public PlayResultDTO $result;
  }
  
  //PlayResultDTO.php
  namespace App\DTO\Play;
  use Spatie\DataTransferObject\DataTransferObject;
  class PlayResultDTO extends DataTransferObject
  {
      public int $radio_id;
      public string $timestamp;
      public int $play_length;
      /** @var PlayTrackDTO[] */
      #[CastWith(ArrayCaster::class, itemType: PlayTrackDTO::class)]
      public array $results;
  }
  
  // PlayTrackDTO.php
  namespace App\DTO\Play;
  use Spatie\DataTransferObject\DataTransferObject;
  class PlayTrackDTO extends DataTransferObject
  {
      public string $artist;
      public string $title;
      public string $album;
      public string $release_date;
      public string $label;
      public int $score;
      public string $song_link;
  }
  </code></pre>
  <p>When I pass a valid array of data to my <code>PlayDTO</code> constructor, in the newly instaitated <code>PlayDTO</code> class, <code>$result</code> correctly has type <code>PlayResultDTO</code>, but in that <code>$result</code> it's <code>$results</code> attribute is just a simple array of keyed-arrays, when it should be an array of <code>PlayTrackDTO</code> objects.</p>
  <p>As far as I can see I followed the guide correctly. I have the most up to date version of the package installed, as well as using PHP8. Would anyone have any suggestions? Thanks</p>