-
-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: detect invalid constructor handle type
An exception will now be thrown when a constructor is registered for an invalid type: something other than a class.
- Loading branch information
Showing
3 changed files
with
43 additions
and
1 deletion.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
src/Mapper/Object/Exception/InvalidClassConstructorType.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace CuyZ\Valinor\Mapper\Object\Exception; | ||
|
||
use CuyZ\Valinor\Definition\FunctionDefinition; | ||
use CuyZ\Valinor\Type\Type; | ||
use RuntimeException; | ||
|
||
/** @internal */ | ||
final class InvalidClassConstructorType extends RuntimeException | ||
{ | ||
public function __construct(FunctionDefinition $function, Type $type) | ||
{ | ||
parent::__construct( | ||
"Invalid type `{$type->toString()}` handled by constructor `{$function->signature()}`. It must be a valid class name.", | ||
1659446121 | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters