/**
  * 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;
 }
Esempio n. 2
0
 /**
  * @dataProvider isDataTypeArrayProvider
  */
 public function testIsDataTypeArray($data_type, $is_array)
 {
     $this->expectVarAnnotation($data_type);
     $this->assertSame($is_array, $this->property->isDataTypeArray());
 }