public function setType($type) { $this->type = Type::parse($type); }
public function testAdditionalFieldInheritedBySubclasses() { $this->handlerRegistry->registerHandler(Direction::DIRECTION_SERIALIZATION, 'Kcs\\Serializer\\Tests\\Fixtures\\Author::links', function (VisitorInterface $visitor, Author $author, Type $type, Context $context) { return $visitor->visitArray(['details' => 'http://foo.bar/details/' . $author->getName(), 'comments' => 'http://foo.bar/details/' . $author->getName() . '/comments'], Type::parse('array<string,string>'), $context); }); $list = new AuthorList(); $list->add(new AuthorChild('Foo')); $list->add(new AuthorChild('Bar')); $this->assertEquals($this->getContent('object_subclass_with_additional_field'), $this->serialize($list)); }