0 follower

Final Class Yiisoft\Hydrator\AttributeHandling\Exception\UnexpectedAttributeException

InheritanceYiisoft\Hydrator\AttributeHandling\Exception\UnexpectedAttributeException » InvalidArgumentException

Thrown when an attribute isn't of the expected class. Used in data and parameter attribute handlers.

Method Details

Hide inherited methods

__construct() public method

public mixed __construct ( string $expectedClassName, object $actualObject, integer $code 0, Throwable|null $previous null )
$expectedClassName string

Expected class name of an attribute.

$actualObject object

An actual given object that's not an instance of $expectedClassName.

$code integer

The exception code.

$previous Throwable|null

The previous throwable used for the exception chaining.

                public function __construct(
    string $expectedClassName,
    object $actualObject,
    int $code = 0,
    ?Throwable $previous = null,
) {
    parent::__construct(
        sprintf(
            'Expected "%s", but "%s" given.',
            $expectedClassName,
            $actualObject::class
        ),
        $code,
        $previous,
    );
}