6498a1b0910d7b66695213a41685b76e409d3d62
[GitHub/WoltLab/WCF.git] /
1 <?php
2
3 declare(strict_types=1);
4
5 namespace CuyZ\Valinor\Mapper\Object\Exception;
6
7 use CuyZ\Valinor\Definition\FunctionDefinition;
8 use CuyZ\Valinor\Type\Types\UnresolvableType;
9 use LogicException;
10
11 /** @internal */
12 final class InvalidConstructorReturnType extends LogicException
13 {
14 public function __construct(FunctionDefinition $function)
15 {
16 $returnType = $function->returnType();
17
18 if ($returnType instanceof UnresolvableType) {
19 $message = $returnType->getMessage();
20 $previous = $returnType;
21 } else {
22 $message = "Invalid return type `{$returnType->toString()}` for constructor `{$function->signature()}`, it must be a valid class name.";
23 $previous = null;
24 }
25
26 parent::__construct($message, 1659446121, $previous);
27 }
28 }