Skip to content

Commit

Permalink
Do not Type-Check twice
Browse files Browse the repository at this point in the history
  • Loading branch information
Dgame committed Jul 18, 2021
1 parent 4bdcba4 commit 8cf537b
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/DataTransferValue.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,17 @@ private function tryResolvingIntoObject(): void
*/
private function validate(): void
{
$typeChecked = false;
foreach ($this->property->getAttributes(Validation::class, ReflectionAttribute::IS_INSTANCEOF) as $attribute) {
/** @var Validation $validation */
$validation = $attribute->newInstance();
$validation->validate($this->value);

$typeChecked = $typeChecked || $validation instanceof Type;
}

if ($typeChecked) {
return;
}

$type = $this->property->getType();
Expand Down

0 comments on commit 8cf537b

Please sign in to comment.