/** * @param string $name * @param array $attributes * @return ContextInterface * @throws \Exception */ public function start($name, array $attributes = array()) { $this->initialize(); if ($this->definition->isArray()) { $prototype = $this->definition->getPrototype(); $keyName = $this->definition->getKeyName(); if ($keyName && isset($attributes[$keyName])) { $this->key = $attributes[$keyName]; } else { $this->key = $this->index; $this->index++; } if (!isset($this->collection[$this->key])) { $this->collection[$this->key] = $prototype->create($this->origin); } $this->definition->settleKey($this->collection[$this->key], $this->key); return new DefinitionContext($this->collection[$this->key], $prototype); } if ($this->definition->isObject() && $this->definition->hasProperty($name)) { return new DefinitionContext($this->object, $this->definition->getProperty($name)); } return new NullContext(); }
public function testAddProperty() { $definition = new Definition(); $definition->addProperty('foo', $this->getDefinitionMock()); $this->assertTrue($definition->hasProperty('foo')); }