TypeHinted example


    public function testIsWritableForReferenceChainIssue($object$path$value)
    {
        $this->assertEquals($value$this->propertyAccessor->isWritable($object$path));
    }

    public function testThrowTypeError()
    {
        $this->expectException(InvalidArgumentException::class);
        $this->expectExceptionMessage('Expected argument of type "DateTimeImmutable", "string" given at property path "date"');
        $object = new TypeHinted();

        $this->propertyAccessor->setValue($object, 'date', 'This is a string, \DateTimeImmutable expected.');
    }

    public function testThrowTypeErrorWithNullArgument()
    {
        $this->expectException(InvalidArgumentException::class);
        $this->expectExceptionMessage('Expected argument of type "DateTimeImmutable", "null" given');
        $object = new TypeHinted();

        $this->propertyAccessor->setValue($object, 'date', null);
    }
Home | Imprint | This part of the site doesn't use cookies.