Skip to content
This repository has been archived by the owner on Nov 1, 2022. It is now read-only.

Commit

Permalink
Improve type error message
Browse files Browse the repository at this point in the history
  • Loading branch information
brendt committed Oct 4, 2019
1 parent 585a7ed commit 68277f8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Expand Up @@ -2,6 +2,10 @@

All notable changes to `data-transfer-object` will be documented in this file

## 1.9.1 - 2019-10-03

- Improve type error message

## 1.9.0 - 2019-08-30

- Add DataTransferObjectCollection::items()
Expand Down
4 changes: 3 additions & 1 deletion src/DataTransferObjectError.php
Expand Up @@ -31,7 +31,9 @@ public static function invalidType(Property $property, $value): DataTransferObje

$expectedTypes = implode(', ', $property->getTypes());

return new self("Invalid type: expected {$property->getFqn()} to be of type {$expectedTypes}, instead got value `{$value}`.");
$currentType = gettype($value);

return new self("Invalid type: expected {$property->getFqn()} to be of type {$expectedTypes}, instead got value `{$value}` ({$currentType}).");
}

public static function uninitialized(Property $property): DataTransferObjectError
Expand Down

0 comments on commit 68277f8

Please sign in to comment.