Пример #1
0
 /**
  * Replaces/sets a global object with an instance replacement of the class.
  *
  * The $GLOBALS state will be reset at the next `FunctionMocker::tearDown` call.
  *
  * @param  string $globalHandle The key the value is associated to in the $GLOBALS array.
  * @param  string $functionName A `Class::method` format string
  * @param  mixed $returnValue The return value or callback, see `replace` method.
  *
  * @return mixed               The object that's been set in the $GLOBALS array.
  */
 public static function replaceGlobal($globalHandle, $functionName, $returnValue = null)
 {
     \Arg::_($globalHandle, 'Global var key')->is_string();
     self::backupGlobal($globalHandle);
     $replacement = FunctionMocker::_replace($functionName, $returnValue);
     $GLOBALS[$globalHandle] = $replacement;
     return $replacement;
 }