/** * @param PropertyDefinition $property * @return string[] */ protected function resolvePropertyTypes(PropertyDefinition $property) { $types = []; $type = $property->getType(); if ($type instanceof ArrayType) { $types[] = $this->getPhpDocArrayType($type); if ($property->hasDefaultValue() && $property->getDefaultValue() instanceof ArrayType) { return $types; } } else { $types[] = $property->getType()->getPhpTypeName(); } if ($property->hasDefaultValue()) { $types[] = $property->getDefaultValue()->getPhpTypeName(); } else { $types[] = 'null'; } return array_unique($types); }
/** * @param PropertyDefinition $property * @return $this */ public function addProperty(PropertyDefinition $property) { if (method_exists($this, 'addClassNameUse')) { foreach ([$property->getDefaultValue(), $property->getType()] as $type) { if (true === $type instanceof ObjectType) { /** @var $type ObjectType */ $this->addClassNameUse($type->getClassName()); } } } $key = $property->getName()->toLowerCamelCase(); $this->properties[$key] = $property; return $this; }