/** * Wraps the given Descriptor inside a Collection Descriptor of type array and returns that. * * @param DescriptorAbstract $descriptor * * @return CollectionDescriptor */ protected function convertToArrayDescriptor($descriptor) { $arrayDescriptor = new CollectionDescriptor('array'); $arrayDescriptor->setTypes(array($descriptor)); $arrayDescriptor->setKeyTypes(array('mixed')); return $arrayDescriptor; }
/** * @covers phpDocumentor\Descriptor\Type\CollectionDescriptor::__toString */ public function testRetrieveCollectionNotationFromObjectWithoutKeys() { $this->fixture->setTypes(array(new FloatDescriptor(), new IntegerDescriptor())); $this->assertSame('array<float|integer>', (string) $this->fixture); }
/** * Renders the view representation for an array or collection. * * @param CollectionDescriptor $value * @param string $presentation * * @return string */ protected function renderTypeCollection($value, $presentation) { $baseType = $this->render($value->getBaseType(), $presentation); $keyTypes = $this->render($value->getKeyTypes(), $presentation); $types = $this->render($value->getTypes(), $presentation); $arguments = array(); if ($keyTypes) { $arguments[] = implode('|', $keyTypes); } $arguments[] = implode('|', $types); if ($value->getName() == 'array' && count($value->getKeyTypes()) == 0) { $typeString = count($types) > 1 ? '(' . reset($arguments) . ')' : reset($arguments); $collection = $typeString . '[]'; } else { $collection = ($baseType ?: $value->getName()) . '<' . implode(',', $arguments) . '>'; } return $collection; }