/** * Get php doc for parameter * * @param Type $type * * @return Doc */ protected function createPropertyDoc(Type $type) { return new Doc(sprintf(<<<EOD /** * @var %s */ EOD , $type->__toString())); }
/** * Add a type * * @param Type $type * * @return $this */ public function addType(Type $type) { if ($type instanceof MultipleType) { foreach ($type->getTypes() as $subType) { $this->types[] = $subType; } return $this; } $this->types[] = $type; return $this; }
/** * Return doc for set method. * * @param $name * @param Type $type * * @return Doc */ protected function createSetterDoc($name, Type $type) { return new Doc(sprintf(<<<EOD /** * @param %s %s * * @return self */ EOD , $type->__toString(), '$' . $this->getNaming()->getPropertyName($name))); }
/** * (@inheritDoc} */ public function createConditionStatement(Expr $input) { $conditionStatement = parent::createConditionStatement($input); foreach ($this->discriminants as $key => $values) { $issetCondition = new Expr\FuncCall(new Name('isset'), [new Arg(new Expr\PropertyFetch($input, sprintf("{'%s'}", $key)))]); $logicalOr = null; if ($values !== null) { foreach ($values as $value) { if ($logicalOr === null) { $logicalOr = new Expr\BinaryOp\Equal(new Expr\PropertyFetch($input, sprintf("{'%s'}", $key)), new Scalar\String_($value)); } else { $logicalOr = new Expr\BinaryOp\LogicalOr($logicalOr, new Expr\BinaryOp\Equal(new Expr\PropertyFetch($input, sprintf("{'%s'}", $key)), new Scalar\String_($value))); } } } if ($logicalOr !== null) { $conditionStatement = new Expr\BinaryOp\LogicalAnd($conditionStatement, new Expr\BinaryOp\LogicalAnd($issetCondition, $logicalOr)); } else { $conditionStatement = new Expr\BinaryOp\LogicalAnd($conditionStatement, $issetCondition); } } return $conditionStatement; }
public function __construct($object, array $types = array()) { parent::__construct($object, 'mixed'); $this->types = $types; }
private function isOptionalObjectType(Type $nullType, Type $objectType) { return 'null' === $nullType->getName() && $objectType instanceof ObjectType; }
public function __construct($object, Type $itemType, $type = 'array') { parent::__construct($object, $type); $this->itemType = $itemType; }