/** * {@inheritdoc} * * @param Type $class * @param string $name * @return Type */ public function getType(Type $class, $name) { $reflectionObject = new ReflectionClass($class->toString()); if (!$reflectionObject->hasProperty($name)) { return Type::fromString(null); } $reflectionProperty = $reflectionObject->getProperty($name); $contextFactory = new ContextFactory(); $context = $contextFactory->createFromReflector($reflectionProperty); $phpdoc = new DocBlock($reflectionProperty, $this->convertToDocBlockContext($context)); /** @var VarTag[] $vars */ $vars = $phpdoc->getTagsByName('var'); if (count($vars) === 0) { return Type::fromString(null); } return Type::fromString($vars[0]->getType()); }
/** * Turn an object graph into another object graph * * @param mixed $value * @param string $type * @return mixed */ public function map($value, $type) { $this->visitor->visitType(Type::fromString($type)); $this->navigator->accept($this->navigator, $this->visitor, $value); return $this->visitor->getResult(); }