public function testSetCurrencyCode()
 {
     $expectedResult = '£';
     $result = call_user_func(array('PHPExcel_Shared_String', 'setCurrencyCode'), $expectedResult);
     $result = call_user_func(array('PHPExcel_Shared_String', 'getCurrencyCode'));
     $this->assertEquals($expectedResult, $result);
 }
示例#2
0
 /**
  * feedForSmarty creates a HTML string to use with smarty assign method
  * based on $this->type by using RSSParser class
  *
  * @param string $type type of the "new"-information, i.e. cache, event, rating, etc
  * @param int $items number of feeditems to parse from feed (RSSParser)
  * @param string $url url of the feed to parse (RSSParser)
  * @param boolean $includetext ???following??? add table-tag?
  * @return string HTML string used for smarty assign method
  */
 public function feedForSmarty($type, $items = null, $url = null, $includetext = null)
 {
     // check type
     if (method_exists($this, strtolower($type) . 'Feed')) {
         return call_user_func(array($this, $type . 'Feed'), $items, $url, $includetext);
     }
 }
 public function build($args = array())
 {
     $options = $this->build_options($args);
     $this->fill_versions();
     $this->fill_types();
     if (isset($options['dependencies']) && $options['dependencies']) {
         $this->load_dependencies();
     }
     $this->check_extenders();
     foreach ($this->extenders as $key => $extender) {
         if ($inc_file = $this->installer_file($extender)) {
             include_once $inc_file;
             $class = $this->classify($extender['name']);
             $params = isset($extender['params']) ? $extender['params'] : array();
             call_user_func(array($class, 'install'), $this->package, $params);
         } else {
             $this->errors[] = 'Can\'t find extension "' . $extender['name'] . '" in extender directory';
             unset($this->extenders[$key]);
         }
     }
     $this->filename = self::tmp_path . basename($this->package->get_filename());
     $this->package->close();
     unset($this->config);
     unset($this->package);
 }
 /**
  * Evaluates negative match.
  *
  * @param string $name
  * @param mixed  $subject
  * @param array  $arguments
  *
  * @throws \PhpSpec\Exception\Example\FailureException
  * @return boolean
  */
 public function negativeMatch($name, $subject, array $arguments)
 {
     $checker = $this->getCheckerName($name);
     if (call_user_func($checker, $subject)) {
         throw new FailureException(sprintf('%s not expected to return %s, but it did.', $this->presenter->presentString(sprintf('%s(%s)', $checker, $this->presenter->presentValue($subject))), $this->presenter->presentValue(true)));
     }
 }
示例#5
0
 /**
  * @internal
  *
  * @param Oxygen_Http_Request     $request
  * @param Oxygen_Util_RequestData $requestData
  * @param string                  $className
  * @param string                  $method
  * @param array                   $actionParameters
  *
  * @return Oxygen_Http_Response
  * @throws Oxygen_Exception
  */
 public function handleRaw($request, $requestData, $className, $method, array $actionParameters)
 {
     $reflectionMethod = new ReflectionMethod($className, $method);
     $parameters = $reflectionMethod->getParameters();
     $arguments = array();
     foreach ($parameters as $parameter) {
         if (isset($actionParameters[$parameter->getName()])) {
             $arguments[] = $actionParameters[$parameter->getName()];
         } else {
             if (!$parameter->isOptional()) {
                 throw new Oxygen_Exception(Oxygen_Exception::ACTION_ARGUMENT_NOT_PROVIDED);
             }
             $arguments[] = $parameter->getDefaultValue();
         }
     }
     if (is_subclass_of($className, 'Oxygen_Container_ServiceLocatorAware')) {
         $instance = call_user_func(array($className, 'createFromContainer'), $this->container);
     } else {
         $instance = new $className();
     }
     $result = call_user_func_array(array($instance, $method), $arguments);
     if (is_array($result)) {
         $result = $this->convertResultToResponse($request, $requestData, $result);
     } elseif (!$result instanceof Oxygen_Http_Response) {
         throw new LogicException(sprintf('An action should return array or an instance of Oxygen_Http_Response; %s gotten.', gettype($result)));
     }
     return $result;
 }
示例#6
0
文件: Auth.php 项目: no22/gongo
 public function authenticate($app, $callback)
 {
     $isLoginUrl = $this->isLoginUrl($app);
     $isValid = $this->isValid($app);
     if (!$isValid) {
         if (!$isLoginUrl) {
             $this->writeRedirect($app, $app->url->requestUrl);
             $this->redirectToLogin($app);
         }
         if ($app->url->requestMethod === 'POST') {
             $userId = $app->post->{$this->options->loginFormUserId};
             $password = $app->post->{$this->options->loginFormPassword};
             if (is_null($callback)) {
                 $user = $this->userProxy->getUserByLoginId($app, $this, $userId);
             } else {
                 $user = call_user_func($callback, $userId);
             }
             $cryptedPassword = $user ? $user->{$this->options->columnPassword} : false;
             $passwordSalt = $user ? $user->{$this->options->columnPasswordSalt} : '';
             if ($cryptedPassword && $this->isValidPassword($password, $cryptedPassword, $passwordSalt)) {
                 $this->login($app, $user);
                 $this->redirectAfterLogin($app);
             } else {
                 $app->error->{$this->options->errorName} = true;
                 $this->redirectToLogin($app);
             }
         }
     } else {
         if ($isLoginUrl) {
             $this->redirectAfterLogin($app);
         }
     }
 }
示例#7
0
 private function _filter($value)
 {
     if ($this->_filter && is_callable($this->_filter)) {
         $value = call_user_func($this->_filter, $value);
     }
     return $value;
 }
示例#8
0
 /**
  * @param mixed $accessor
  * @param bool  $retrieve
  * @return Document|null
  */
 public function getDocument($accessor = null, $retrieve = false)
 {
     if ($accessor === null) {
         $accessor = static::DEFAULT_ACCESSOR;
     }
     if ($accessor === null) {
         // the value contains the document itself
         $doc = $this->value;
         // if the view didn't emit the actual doc as value but was called with include_docs=true
         if (!$doc || !isset($doc->_id) && !isset($doc['_id'])) {
             $doc = $this->doc;
         }
     } elseif (is_callable($accessor)) {
         // an anonymous function or another kind of callback that will grab the value for us
         $doc = call_user_func($accessor, $this);
     } elseif (is_array($this->value) && isset($this->value[$accessor])) {
         // value is an array
         $doc = $this->value[$accessor];
     } elseif (isset($this->value->{$accessor})) {
         // it's the name of a property
         $doc = $this->value->{$accessor};
     } else {
         // exception
     }
     if ($doc) {
         $retval = new Document($this->getViewResult()->getDatabase());
         $retval->hydrate($doc);
         return $retval;
     } elseif ($retrieve) {
         // the view didn't emit the actual doc as value and the view wasn't called with include_docs=true
         return $this->viewResult->getDatabase()->retrieveDocument($this->id);
     } else {
         return null;
     }
 }
示例#9
0
 /**
  * @return array
  */
 public function getIssues()
 {
     if ($this->callback && !$this->callback_invoked) {
         call_user_func($this->callback);
     }
     return $this->issues;
 }
示例#10
0
 /**
  * {@inheritdoc}
  */
 public function filter(ProxyQueryInterface $queryBuilder, $alias, $field, $data)
 {
     if (!is_callable($this->getOption('callback'))) {
         throw new \RuntimeException(sprintf('Please provide a valid callback option "filter" for field "%s"', $this->getName()));
     }
     $this->active = call_user_func($this->getOption('callback'), $queryBuilder, $alias, $field, $data);
 }
示例#11
0
 /**
  * Loads all plugins.
  *
  * @param Application $app
  */
 public function load(Application $app)
 {
     foreach ($this->loadConfigs() as $name => $config) {
         if (isset($this->plugins[$name])) {
             continue;
         }
         if (isset($config['autoload'])) {
             foreach ($config['autoload'] as $namespace => $path) {
                 $app['autoloader']->addPsr4($namespace, $config['path'] . "/{$path}");
             }
         }
         if (isset($config['events'])) {
             foreach ($config['events'] as $event => $listener) {
                 $app->on($event, $listener);
             }
         }
         if (is_string($class = $config['main'])) {
             $plugin = new $class();
             if ($plugin instanceof ApplicationAware) {
                 $plugin->setApplication($app);
             }
             if ($plugin instanceof PluginInterface) {
                 $plugin->load($app, $config);
             }
             $this->plugins[$name] = $plugin;
         } elseif (is_callable($config['main'])) {
             $this->plugins[$name] = call_user_func($config['main'], $app, $config) ?: true;
         }
     }
 }
示例#12
0
 /**
  *   Raises an error.
  *   @param $errorMsg The error message.
  *   @param $field The component field that raised the error, if available.
  */
 protected function RaiseError($errorMsg, $field = null)
 {
     $this->LastError = $errorMsg;
     if (!empty($this->ErrorCallbackFn)) {
         call_user_func($this->ErrorCallbackFn, $this, get_called_class(), $field, $errorMsg);
     }
 }
示例#13
0
 public function notify($errno, $errstr, $errfile, $errline, $trace)
 {
     $body = array();
     $body[] = $this->_makeSection("", join("\n", array(@$_SERVER['GATEWAY_INTERFACE'] ? "//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}" : "", "{$errno}: {$errstr}", "at {$errfile} on line {$errline}")));
     if ($this->_whatToLog & self::LOG_TRACE && $trace) {
         $body[] = $this->_makeSection("TRACE", Debug_ErrorHook_Util::backtraceToString($trace));
     }
     /*if ($this->_whatToLog & self::LOG_SERVER) {
           $body[] = $this->_makeSection("SERVER", Debug_ErrorHook_Util::varExport($_SERVER));
       }*/
     if (!empty($_COOKIE) && $this->_whatToLog & self::LOG_COOKIE) {
         $body[] = $this->_makeSection("COOKIES", Debug_ErrorHook_Util::varExport($_COOKIE));
     }
     if (!empty($_GET) && $this->_whatToLog & self::LOG_GET) {
         $body[] = $this->_makeSection("GET", Debug_ErrorHook_Util::varExport($_GET));
     }
     if (!empty($_POST) && $this->_whatToLog & self::LOG_POST) {
         $body[] = $this->_makeSection("POST", Debug_ErrorHook_Util::varExport($_POST));
     }
     if (!empty($_SESSION) && $this->_whatToLog & self::LOG_SESSION) {
         $body[] = $this->_makeSection("SESSION", Debug_ErrorHook_Util::varExport(@$_SESSION));
     }
     // Append body suffix?
     $suffix = $this->_bodySuffix && is_callable($this->_bodySuffix) ? call_user_func($this->_bodySuffix) : $this->_bodySuffix;
     if ($suffix) {
         $body[] = $this->_makeSection("ADDITIONAL INFO", $suffix);
     }
     // Remain only 1st line for subject.
     $errstr = preg_replace("/\r?\n.*/s", '', $errstr);
     $this->_notifyText("{$errno}: {$errstr} at {$errfile} on line {$errline}", join("\n", $body));
 }
 /**
  * モジュールの起動(シングルトン)
  *
  * @param  $name string 読み込むモジュール
  * @param  $type string OPTIONAL モジュールのタイプ(wp_attache_mobile|pear)
  * @param  $args mixed モジュールに渡す引数(PEAR のみ使用)
  */
 function &boot($name = null, $type = 'wp_attache_mobile', $args = null)
 {
     static $i = array();
     if (empty($name)) {
         $class = __CLASS__;
         $name = 'controller';
         $i[$name] = new $class();
     } elseif (!isset($i[$name])) {
         if ($type === 'wp_attache_mobile') {
             if (($path = realpath(dirname(__FILE__) . "/modules/{$name}.php")) === false) {
                 wp_attache_mobile::notice(sprintf(__('wp_attache_mobile: %s module not found.', 'wp_attache_mobile'), ucfirst($name)), 'error');
             } else {
                 include $path;
                 $class = "wp_attache_mobile_{$name}";
                 $i[$name] = new $class();
             }
         } elseif ($type === 'pear') {
             if (($path = realpath(sprintf("%s/%s.php", wp_attache_mobile_controller::pear_path(), str_replace('_', '/', $name)))) === false) {
                 wp_die(sprintf(__('wp_attache_mobile: %s PEAR library not found.', 'wp_attache_mobile'), $name));
                 wp_attache_mobile::notice(sprintf(__('wp_attache_mobile: %s PEAR library not found.', 'wp_attache_mobile'), $name), 'error');
             } else {
                 include $path;
                 if (method_exists($name, 'singleton')) {
                     $i[$name] =& call_user_func(array($name, 'singleton'), $args);
                 } else {
                     $i[$name] = new $name();
                 }
             }
         } else {
             wp_die(sprintf(__('wp_attache_mobile: %s is invalid module type.', 'wp_attache_mobile'), $type));
             wp_attache_mobile::notice(sprintf(__('wp_attache_mobile: %s is invalid module type.', 'wp_attache_mobile'), $type), 'error');
         }
     }
     return $i[$name];
 }
示例#15
0
 function getVar($key, $format = 's')
 {
     if ($format == 's' && in_array($key, array())) {
         return call_user_func(array($this, $key));
     }
     return parent::getVar($key, $format);
 }
示例#16
0
 /**
  * @param int      $expectedType     Expected triggered error type (pass one of PHP's E_* constants)
  * @param string[] $expectedMessages Expected error messages
  * @param callable $testCode         A callable that is expected to trigger the error messages
  */
 public static function assertErrorsAreTriggered($expectedType, $expectedMessages, $testCode)
 {
     if (!is_callable($testCode)) {
         throw new \InvalidArgumentException(sprintf('The code to be tested must be a valid callable ("%s" given).', gettype($testCode)));
     }
     $e = null;
     $triggeredMessages = array();
     try {
         $prevHandler = set_error_handler(function ($type, $message, $file, $line, $context) use($expectedType, &$triggeredMessages, &$prevHandler) {
             if ($expectedType !== $type) {
                 return null !== $prevHandler && call_user_func($prevHandler, $type, $message, $file, $line, $context);
             }
             $triggeredMessages[] = $message;
         });
         call_user_func($testCode);
     } catch (\Exception $e) {
     } catch (\Throwable $e) {
     }
     restore_error_handler();
     if (null !== $e) {
         throw $e;
     }
     \PHPUnit_Framework_Assert::assertCount(count($expectedMessages), $triggeredMessages);
     foreach ($triggeredMessages as $i => $message) {
         \PHPUnit_Framework_Assert::assertContains($expectedMessages[$i], $message);
     }
 }
示例#17
0
 public static function getLoader()
 {
     if (null !== self::$loader) {
         return self::$loader;
     }
     spl_autoload_register(array('ComposerAutoloaderInitd530de204ef18056db76679ad2b19aa5', 'loadClassLoader'), true, true);
     self::$loader = $loader = new \Composer\Autoload\ClassLoader();
     spl_autoload_unregister(array('ComposerAutoloaderInitd530de204ef18056db76679ad2b19aa5', 'loadClassLoader'));
     $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION');
     if ($useStaticLoader) {
         require_once __DIR__ . '/autoload_static.php';
         call_user_func(\Composer\Autoload\ComposerStaticInitd530de204ef18056db76679ad2b19aa5::getInitializer($loader));
     } else {
         $map = (require __DIR__ . '/autoload_namespaces.php');
         foreach ($map as $namespace => $path) {
             $loader->set($namespace, $path);
         }
         $map = (require __DIR__ . '/autoload_psr4.php');
         foreach ($map as $namespace => $path) {
             $loader->setPsr4($namespace, $path);
         }
         $classMap = (require __DIR__ . '/autoload_classmap.php');
         if ($classMap) {
             $loader->addClassMap($classMap);
         }
     }
     $loader->register(true);
     return $loader;
 }
示例#18
0
 public function execute($action, $arguments)
 {
     if (!method_exists($this, $action)) {
         throw new Exception("Action '{$action}' is not valid!");
     }
     call_user_func(array($this, $action), $arguments);
 }
示例#19
0
 public function tick()
 {
     $read = $this->readStreams ?: null;
     $write = $this->writeStreams ?: null;
     $excepts = null;
     if (!$read && !$write) {
         return false;
     }
     if (stream_select($read, $write, $except, 0, $this->timeout) > 0) {
         if ($read) {
             foreach ($read as $stream) {
                 $listener = $this->readListeners[(int) $stream];
                 if (call_user_func($listener, $stream, $this) === false) {
                     $this->removeReadStream($stream);
                 }
             }
         }
         if ($write) {
             foreach ($write as $stream) {
                 if (!isset($this->writeListeners[(int) $stream])) {
                     continue;
                 }
                 $listener = $this->writeListeners[(int) $stream];
                 if (call_user_func($listener, $stream, $this) === false) {
                     $this->removeWriteStream($stream);
                 }
             }
         }
     }
     return true;
 }
 private function invokeStats(array $options, RequestInterface $request, $startTime, ResponseInterface $response = null, $error = null)
 {
     if (isset($options['on_stats'])) {
         $stats = new TransferStats($request, $response, microtime(true) - $startTime, $error, []);
         call_user_func($options['on_stats'], $stats);
     }
 }
示例#21
0
function fz_dispatcher()
{
    $controller = 'App_Controller_' . params('controller');
    $controllerInstance = new $controller();
    $controllerInstance->init();
    return call_user_func(array($controllerInstance, params('action') . 'Action'));
}
示例#22
0
/**
 * Initialize session.
 * @param boolean $keepopen keep session open? The default is
 * 			to close the session after $_SESSION has been populated.
 * @uses $_SESSION
 */
function session_init($keepopen = false)
{
    $settings = new phpVBoxConfigClass();
    // Sessions provided by auth module?
    if (@$settings->auth->capabilities['sessionStart']) {
        call_user_func(array($settings->auth, $settings->auth->capabilities['sessionStart']), $keepopen);
        return;
    }
    // No session support? No login...
    if (@$settings->noAuth || !function_exists('session_start')) {
        global $_SESSION;
        $_SESSION['valid'] = true;
        $_SESSION['authCheckHeartbeat'] = time();
        $_SESSION['admin'] = true;
        return;
    }
    // start session
    session_start();
    // Session is auto-started by PHP?
    if (!ini_get('session.auto_start')) {
        ini_set('session.use_trans_sid', 0);
        ini_set('session.use_only_cookies', 1);
        // Session path
        if (isset($settings->sessionSavePath)) {
            session_save_path($settings->sessionSavePath);
        }
        session_name(isset($settings->session_name) ? $settings->session_name : md5('phpvbx' . $_SERVER['DOCUMENT_ROOT'] . $_SERVER['HTTP_USER_AGENT']));
        session_start();
    }
    if (!$keepopen) {
        session_write_close();
    }
}
示例#23
0
文件: text.php 项目: akeeba/angie
 public static function loadLanguage($langCode = null)
 {
     if (is_null($langCode)) {
         $langCode = self::detectLanguage();
     }
     // If we are asked to load a non-default language, load the English (Great Britain) base translation first
     if ($langCode != 'en-GB') {
         static::loadLanguage('en-GB');
     }
     // Main file
     $filename = APATH_INSTALLATION . '/' . AApplication::getInstance()->getName() . '/language/' . $langCode . '.ini';
     $strings = AngieHelperIni::parse_ini_file($filename, false);
     self::$strings = array_merge(self::$strings, $strings);
     // Platform override file
     $filename = APATH_INSTALLATION . '/' . AApplication::getInstance()->getName() . '/platform/language/' . $langCode . '.ini';
     if (!@file_exists($filename)) {
         $filename = APATH_INSTALLATION . '/platform/language/' . $langCode . '.ini';
     }
     if (@file_exists($filename)) {
         $strings = AngieHelperIni::parse_ini_file($filename, false);
         self::$strings = array_merge(self::$strings, $strings);
     }
     // Performs callback on loaded strings
     if (!empty(static::$iniProcessCallbacks) && !empty(self::$strings)) {
         foreach (static::$iniProcessCallbacks as $callback) {
             $ret = call_user_func($callback, $filename, self::$strings);
             if ($ret === false) {
                 return;
             } elseif (is_array($ret)) {
                 self::$strings = $ret;
             }
         }
     }
 }
示例#24
0
 public static function run($ptr, $arg = 0)
 {
     if (call_user_func(array('ConfigurationTest', 'test_' . $ptr), $arg)) {
         return 'ok';
     }
     return 'fail';
 }
示例#25
0
 /**
  * Escapes a value for output in a view script.
  *
  * If escaping mechanism is either htmlspecialchars or htmlentities, uses
  * {@link $_encoding} setting.
  *
  * @param   mixed  $var  The output to escape.
  * @return  mixed  The escaped value.
  */
 public function escape($var)
 {
     if (in_array($this->_escape, array('htmlspecialchars', 'htmlentities'))) {
         return call_user_func($this->_escape, $var, ENT_COMPAT, $this->_charset);
     }
     return call_user_func($this->_escape, $var);
 }
 static function query_and_render($args)
 {
     $ctype = p2p_type($args['ctype']);
     if (!$ctype) {
         trigger_error(sprintf("Unregistered connection type '%s'.", $ctype), E_USER_WARNING);
         return '';
     }
     $directed = $ctype->find_direction($args['item']);
     if (!$directed) {
         return '';
     }
     $context = $args['context'];
     $extra_qv = array('p2p:per_page' => -1, 'p2p:context' => $context);
     $connected = call_user_func(array($directed, $args['method']), $args['item'], $extra_qv, 'abstract');
     switch ($args['mode']) {
         case 'inline':
             $render_args = array('separator' => ', ');
             break;
         case 'ol':
             $render_args = array('before_list' => '<ol id="' . $ctype->name . '_list">', 'after_list' => '</ol>');
             break;
         case 'ul':
         default:
             $render_args = array('before_list' => '<ul id="' . $ctype->name . '_list">', 'after_list' => '</ul>');
             break;
     }
     $render_args['echo'] = false;
     $html = self::render($connected, $render_args);
     return apply_filters("p2p_{$context}_html", $html, $connected, $directed, $args['mode']);
 }
 protected function createRow($items, $aData = array(), $level = 1)
 {
     if ($items->count()) {
         foreach ($items as $itm) {
             $getter = 'get' . $this->getValueField();
             $aResultTmp = array('Value' => call_user_func(array($itm, $getter)), 'Name' => $this->getTextFormat());
             $aRs = array();
             if (preg_match_all("/:(.*):/iU", $aResultTmp['Name'], $aRs)) {
                 foreach ($aRs[1] as $k => $val) {
                     $value = $itm;
                     if (strpos($val, "-") !== false) {
                         $xVal = explode("-", $val);
                         foreach ($xVal as $_val) {
                             $sGetter = 'get' . $_val;
                             $value = call_user_func(array($value, $sGetter));
                         }
                     } else {
                         $sGetter = 'get' . $val;
                         $value = call_user_func(array($value, $sGetter));
                     }
                     $aResultTmp['Name'] = str_replace($aRs[0][$k], $value, $aResultTmp['Name']);
                 }
             }
             if ($this->getIsTree() && $level > 1) {
                 $aResultTmp['Name'] = str_repeat(" |-- ", $level - 1) . $aResultTmp['Name'];
             }
             $aData[] = $aResultTmp;
             if ($itm->hasChilds()) {
                 $aData = $this->createRow($itm->getChilds(), $aData, $level + 1);
             }
         }
     }
     return $aData;
 }
示例#28
0
 /**
  * Finds a class.
  *
  * @param string $type
  *
  * @return string|\Closure
  *
  * @throws DiscoveryFailedException
  */
 protected static function findOneByType($type)
 {
     // Look in the cache
     if (null !== ($class = self::getFromCache($type))) {
         return $class;
     }
     $exceptions = [];
     foreach (self::$strategies as $strategy) {
         try {
             $candidates = call_user_func($strategy . '::getCandidates', $type);
         } catch (StrategyUnavailableException $e) {
             $exceptions[] = $e;
             continue;
         }
         foreach ($candidates as $candidate) {
             if (isset($candidate['condition'])) {
                 if (!self::evaluateCondition($candidate['condition'])) {
                     continue;
                 }
             }
             // save the result for later use
             self::storeInCache($type, $candidate);
             return $candidate['class'];
         }
     }
     throw new DiscoveryFailedException('Could not find resource using any discovery strategy', $exceptions);
 }
示例#29
-1
 /**
  * Loops until the waitCallback returns true and sleeps in between attempts
  * for a length of time specified by the interval. Also emits a WaitEvent
  * during each loop before sleeping.
  *
  * @throws \RuntimeException if the max attempts is exceeded
  */
 public function wait()
 {
     $attempts = 0;
     // Perform an initial delay if configured
     if ($this->config['delay']) {
         usleep($this->config['delay'] * 1000000);
     }
     // If not yet reached max attempts, keep trying to perform wait callback
     while ($attempts < $this->config['max_attempts']) {
         // Perform the callback; if true, then waiting is finished
         if (call_user_func($this->waitCallback)) {
             return;
         }
         // Emit a wait event so collaborators can do something between waits
         $event = new WaitEvent($this->config, $attempts);
         $this->getEmitter()->emit('wait', $event);
         // Wait the specified interval
         if ($interval = $this->config['interval']) {
             if (is_callable($interval)) {
                 $interval = $interval();
             }
             usleep($interval * 1000000);
         }
         $attempts++;
     }
     throw new \RuntimeException("Waiter failed after {$attempts} attempts");
 }
示例#30
-1
 /**
  * Apply a user function to each flows.
  *
  * @param  callable A callback function
  * @return \FlowConfigurationInterface
  */
 public function forEachFlow(callable $function)
 {
     foreach ($this->flows as $i => $flow) {
         $this->flows[$i] = call_user_func($function, $flow);
     }
     return $this;
 }