/** * Resolves the value of this definition, according to the current scope. * * This method is for internal use by the Container. * * @param Container $container * * @return mixed */ public function get(Container $container) { if ($this->scope === null) { $this->scope = $this->getDefaultScope(); } return $this->scope->get($this, $container); }
/** * When the api call results in RestException this method * will be called to return the error message * * @param RestException $exception exception that has reasons for failure * * @return array */ public function message(RestException $exception) { //TODO: check Defaults::language and change result accordingly $r = array('error' => array('code' => $exception->getCode(), 'message' => $exception->getErrorMessage()) + $exception->getDetails()); if (!Scope::get('Restler')->getProductionMode() && self::$includeDebugInfo) { $r += array('debug' => array('source' => $exception->getSource(), 'stages' => $exception->getStages())); } return $r; }
/** * Returns data visible from current scope. * * @param string $key * @param mixed $default * * @return mixed */ public function get($key, $default = null) { if (array_key_exists($key, $this->data)) { return $this->data[$key]; } if (null === $this->parent) { return $default; } return $this->parent->get($key, $default); }
/** * @expectedException RuntimeException */ public function testSetVariablePassByRef() { $scope = new Scope(); $scope->set('test', 4); $scope->passByRef('test', false); $scope->call(function (&$test) { $test = 10; }); $scope->assertEquals($scope->get('test'), 4); }