Пример #1
0
    /**
     * 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()));
    }
Пример #2
0
 /**
  * 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;
 }
Пример #3
0
    /**
     * 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)));
    }
Пример #4
0
 /**
  * (@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;
 }
Пример #5
0
 public function __construct($object, array $types = array())
 {
     parent::__construct($object, 'mixed');
     $this->types = $types;
 }
Пример #6
0
 private function isOptionalObjectType(Type $nullType, Type $objectType)
 {
     return 'null' === $nullType->getName() && $objectType instanceof ObjectType;
 }
Пример #7
0
 public function __construct($object, Type $itemType, $type = 'array')
 {
     parent::__construct($object, $type);
     $this->itemType = $itemType;
 }