예제 #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
파일: MultipleType.php 프로젝트: stof/jane
 /**
  * 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
파일: ObjectType.php 프로젝트: stof/jane
 /**
  * (@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
파일: ArrayType.php 프로젝트: stof/jane
 public function __construct($object, Type $itemType, $type = 'array')
 {
     parent::__construct($object, $type);
     $this->itemType = $itemType;
 }