public function &__get($key)
{
if (array_key_exists($key, $this->_data)) {
return $this->_data[$key];
}
if (array_key_exists($key, $this->_given)) {
$scope = static::current();
$scope->{$key} = $this->_given[$key]($scope);
return $scope->__get($key);
}
if ($this->_parent !== null) {
return $this->_parent->__get($key);
}
if (in_array($key, static::$blacklist)) {
if ($key === 'expect') {
throw new Exception("You can't use expect() inside of describe()");
}
}
throw new Exception("Undefined variable `{$key}`.");
}
/** * Getter. * * @param string $key The name of the variable. * @return mixed The value of the variable. */ public function &__get($key) { if (array_key_exists($key, $this->_data)) { return $this->_data[$key]; } if (array_key_exists($key, $this->_given)) { $scope = static::current(); $scope->{$key} = $this->_given[$key]($scope); return $scope->__get($key); } if ($this->_parent !== null) { return $this->_parent->__get($key); } if (in_array($key, static::$blacklist)) { if ($key === 'expect') { throw new Exception("You can't use expect() inside of describe()"); } } throw new Exception("Undefined variable `{$key}`."); }