Пример #1
0
 /**
  * @covers Object_AbstractDelegator::offsetGet
  */
 public function testOffsetGet()
 {
     $this->object->append('For_Test');
     $this->object->append(new stdClass());
     $this->assertEquals(1, count($this->object->get_delegates()));
     $this->assertEquals(1, count($this->object->get_classes()));
     $this->assertInstanceOf('For_Test', $this->object->offsetGet(0));
     $this->assertInstanceOf('stdClass', $this->object->offsetGet(1));
     $this->assertEquals(2, count($this->object->get_delegates()));
     $this->assertEquals(0, count($this->object->get_classes()));
 }
Пример #2
0
 /**
  * Возвращает зарегистрированный объект по индексу
  *
  * Возвращает либо объект по запрошенному индексу из родительского класса,
  * либо, если родитель вернул null, то элемент массива $fallback
  * с запрошенным индексом.
  *
  * @param null|int|string $index
  *
  * @throws Core_MissingIndexedPropertyException Если запрошенный элемент отсутствует.
  *
  * @return object
  */
 public function offsetGet($index)
 {
     $from_parent = parent::offsetGet($index);
     if (!empty($from_parent)) {
         return $from_parent;
     }
     if ($this->fallback instanceof self) {
         return $this->fallback[$index];
     }
     throw new Core_MissingIndexedPropertyException($index);
 }