/** * Find the element list. * * @return NodeElement[] * @throws ElementException In case no array/collection given and multiple elements found. */ public function findAll() { $elements = array(); foreach ($this->getSelectors() as $selector) { $elements = array_merge($elements, $this->searchContext->findAll('se', $selector)); } $element_count = count($elements); if ($element_count > 1 && !$this->property->isDataTypeArray() && !$this->property->isDataTypeCollection()) { throw new ElementException(sprintf('The "%s" used on "%s" property expects finding 1 element, but %s elements were found.', $this->property->getRawDataType(), $this->property, $element_count), ElementException::TYPE_MULTIPLE_ELEMENTS_FOUND); } return $elements; }
/** * @dataProvider isDataTypeCollectionProvider */ public function testIsDataTypeCollection($data_type, $is_collection) { $this->expectVarAnnotation($data_type); $this->assertSame($is_collection, $this->property->isDataTypeCollection()); }