当前位置: 首页>>代码示例>>PHP>>正文


PHP xcallable函数代码示例

本文整理汇总了PHP中xcallable函数的典型用法代码示例。如果您正苦于以下问题:PHP xcallable函数的具体用法?PHP xcallable怎么用?PHP xcallable使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了xcallable函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: paint

 /**
  * Paint the element.
  *
  * @param   \Hoa\Stream\IStream\Out  $out    Out stream.
  * @return  void
  */
 public function paint(Stream\IStream\Out $out)
 {
     $root = $this->getAbstractElementSuperRoot();
     $value = $this->computeValue();
     $with = '__main__';
     if (true === $this->abstract->attributeExists('with')) {
         $with = $this->abstract->readAttribute('with');
     }
     $translation = $root->getTranslation($with);
     if (null === $translation) {
         $out->writeAll($value);
         return;
     }
     $callable = null;
     $arguments = [$value];
     if (true === $this->abstract->attributeExists('n')) {
         $callable = xcallable($translation, '_n');
         $arguments[] = $this->abstract->readAttribute('n');
     } else {
         $callable = xcallable($translation, '_');
     }
     $with = $this->abstract->readCustomAttributes('with');
     if (!empty($with)) {
         foreach ($with as $w) {
             $arguments[] = $this->computeAttributeValue($w);
         }
     }
     $result = $callable->distributeArguments($arguments);
     if (false !== strpos($result, '<')) {
         $this->computeFromString($result);
     } else {
         $out->writeAll($result);
     }
     return;
 }
开发者ID:Jir4,项目名称:Xyl,代码行数:41,代码来源:Translate.php

示例2: __construct

 public function __construct($repository)
 {
     $this->_readline = new Hoa\Console\Readline();
     $git = new Hoa\Console\Processus('git log --pretty=\'format:\' --patch --reverse --raw -z', null, null, $repository);
     $git->on('output', xcallable($this, 'output'));
     $git->on('stop', xcallable($this, 'over'));
     $git->run();
 }
开发者ID:shulard,项目名称:Literature,代码行数:8,代码来源:Patcher.php

示例3: render

 public function render()
 {
     $this->renderInternal();
     Cursor::setStyle('▋', true);
     do {
         $this->readline = new Readline();
         $this->readline->addMapping('j', xcallable($this, '_bindJ'));
         $this->readline->addMapping('k', xcallable($this, '_bindK'));
         $line = $this->readline->readLine(' ');
     } while (false !== $line && 'quit' !== $line);
 }
开发者ID:jvelo,项目名称:datatext,代码行数:11,代码来源:NavigableTable.php

示例4: __construct

 /**
  * Start the stream reader/writer as if it is a XML document.
  *
  * @param   \Hoa\Stream\IStream\In  $stream                 Stream to
  *                                                          read/write.
  * @param   bool                    $initializeNamespace    Whether we
  *                                                          initialize
  *                                                          namespaces.
  * @param   mixed                   $entityResolver         Entity resolver.
  * @param   bool                    $autoSave               Whether we
  *                                                          should
  *                                                          auto-save.
  * @return  void
  * @throws  \Hoa\Xml\Exception
  */
 public function __construct(Stream\IStream\In $stream, $initializeNamespace = true, $entityResolver = null, $autoSave = true)
 {
     if (true === $autoSave && !$stream instanceof Stream\IStream\Out) {
         throw new Exception('The stream %s (that has opened %s) must implement ' . '\\Hoa\\Stream\\IStream\\In and \\Hoa\\Stream\\IStream\\Out interfaces.', 0, [get_class($stream), $stream->getStreamName()]);
     }
     parent::__construct('\\Hoa\\Xml\\Element\\ReadWrite', $stream, $initializeNamespace, $entityResolver);
     if (true === $autoSave) {
         event('hoa://Event/Stream/' . $stream->getStreamName() . ':close-before')->attach(xcallable($this, '_close'));
     }
     $this->_autoSave = $autoSave;
     return;
 }
开发者ID:Grummfy,项目名称:Central,代码行数:27,代码来源:ReadWrite.php

示例5: initializeFunctions

 /**
  * Initialize functions mapping.
  *
  * @return void
  */
 protected function initializeFunctions()
 {
     if (sizeof($this->opa_functions) > 0) {
         return;
     }
     $average = function () {
         $arguments = func_get_args();
         return array_sum($arguments) / count($arguments);
     };
     $this->opa_functions = array('abs' => xcallable('abs'), 'ceil' => xcallable('ceil'), 'floor' => xcallable('floor'), 'int' => xcallable('intval'), 'max' => xcallable('max'), 'min' => xcallable('min'), 'rand' => xcallable('rand'), 'round' => xcallable('round'), 'random' => xcallable('rand'), 'current' => xcallable('caIsCurrentDate'), 'future' => xcallable('caDateEndsInFuture'), 'wc' => xcallable('str_word_count'), 'length' => xcallable('strlen'), 'date' => xcallable('caDateToHistoricTimestamp'), 'formatdate' => xcallable('caFormatDate'), 'formatgmdate' => xcallable('caFormatGMDate'), 'sizeof' => xcallable(function () {
         return count(func_get_args());
     }), 'count' => xcallable(function () {
         return count(func_get_args());
     }), 'age' => xcallable('caCalculateAgeInYears'), 'ageyears' => xcallable('caCalculateAgeInYears'), 'agedays' => xcallable('caCalculateAgeInDays'), 'avgdays' => xcallable('caCalculateDateRangeAvgInDays'), 'average' => xcallable($average), 'avg' => xcallable($average), 'sum' => xcallable(function () {
         return array_sum(func_get_args());
     }));
     return;
 }
开发者ID:samrahman,项目名称:providence,代码行数:23,代码来源:ExpressionVisitor.php

示例6: resolve

 public function resolve($value)
 {
     if (self::STATE_PENDING !== $this->_state) {
         throw new Exception('This promise is not pending, cannot resolve it.', 0);
     }
     try {
         if ($value instanceof self) {
             $value->then(xcallable($this, 'resolve'), xcallable($this, 'reject'));
             return;
         }
         $this->setValue($value);
         $this->_state = self::STATE_FULFILLED;
         if (null === $this->_deferred) {
             return;
         }
         $this->handle($this->_deferred);
     } catch (\Exception $e) {
         $this->reject($e);
     }
     return;
 }
开发者ID:shulard,项目名称:Promise,代码行数:21,代码来源:Promise.php

示例7: case_callable_xcallable

 public function case_callable_xcallable()
 {
     $this->given($context = new CUT(), $context['foo'] = xcallable($this, 'fakeCallable'))->when($result = $context['foo'])->then->boolean($result)->isTrue();
 }
开发者ID:djuptho,项目名称:Ruler,代码行数:4,代码来源:Context.php

示例8: __construct

 /**
  * Start the stream reader/writer as if it is a XML document.
  *
  * @param   \Hoa\Stream\IStream\Out  $stream                 Stream to
  *                                                           read/write.
  * @param   bool                     $initializeNamespace    Whether we
  *                                                           initialize
  *                                                           namespaces.
  * @param   mixed                    $entityResolver         Entity resolver.
  * @return  void
  */
 public function __construct(Stream\IStream\Out $stream, $initializeNamespace = true, $entityResolver = null)
 {
     parent::__construct('\\Hoa\\Xml\\Element\\Write', $stream, $initializeNamespace, $entityResolver);
     event('hoa://Event/Stream/' . $stream->getStreamName() . ':close-before')->attach(xcallable($this, '_close'));
     return;
 }
开发者ID:Grummfy,项目名称:Central,代码行数:17,代码来源:Write.php

示例9: newBuffer

 /**
  * Start a new buffer.
  * The callable acts like a filter.
  *
  * @param   mixed   $callable    Callable.
  * @param   int     $size        Size.
  * @return  int
  */
 public function newBuffer($callable = null, $size = null)
 {
     $last = current(self::$_stack);
     $hash = $this->getHash();
     if (false === $last || $hash != $last[0]) {
         self::$_stack[] = [0 => $hash, 1 => 1];
     } else {
         ++self::$_stack[key(self::$_stack)][1];
     }
     end(self::$_stack);
     if (null === $callable) {
         ob_start();
     } else {
         ob_start(xcallable($callable), null === $size ? 0 : $size);
     }
     return $this->getBufferLevel();
 }
开发者ID:robertgeb,项目名称:Map-Project,代码行数:25,代码来源:Response.php

示例10: filter

 /**
  * Add a filter.
  * Used in the self::getStatistic() method, no in iterator.
  * A filter is a callable that will receive 3 values about a mark: ID, time
  * result, and time pourcent. The callable must return a boolean.
  *
  * @param   mixed  $callable    Callable.
  * @return  void
  */
 public function filter($callable)
 {
     $this->_filters[] = xcallable($callable);
     return $this;
 }
开发者ID:shulard,项目名称:Bench,代码行数:14,代码来源:Bench.php

示例11: invoke

 /**
  * Invoke.
  *
  * @acccess  protected
  * @param    \Hoa\Core\Consistency\Xcallable    &$reflection       Callable.
  * @param    \ReflectionFunctionAbstract        &$reflection       Reflection.
  * @param    array                              &$arguments        Arguments.
  * @param    bool                                $isConstructor    Whether
  *                                                                 it is a
  *                                                                 constructor.
  * @return   mixed
  * @throws   \Exception
  */
 protected function invoke(Core\Consistency\Xcallable &$callable, \ReflectionFunctionAbstract &$reflection, array &$arguments, $isConstructor)
 {
     if ($reflection instanceof \ReflectionFunction) {
         return $reflection->invokeArgs($arguments);
     }
     if (false === $isConstructor) {
         $_callback = $callable->getValidCallback();
         $_object = $_callback[0];
         return $reflection->invokeArgs($_object, $arguments);
     }
     $class = $reflection->getDeclaringClass();
     $instance = $class->newInstanceArgs($arguments);
     $callable = xcallable($instance, '__construct');
     $reflection = $callable->getReflection();
     return void;
 }
开发者ID:Grummfy,项目名称:Central,代码行数:29,代码来源:Runtime.php

示例12: getStarOperator

 /**
  * Return a "*" or "catch all" operator.
  *
  * @param Visitor\Element $element The node representing the operator.
  *
  * @return \Hoa\Core\Consistency\Xcallable
  */
 protected function getStarOperator(AST\Operator $element)
 {
     return xcallable(function () use($element) {
         return sprintf('%s(%s)', $element->getName(), implode(', ', func_get_args()));
     });
 }
开发者ID:royopa,项目名称:rulerz,代码行数:13,代码来源:SqlVisitor.php

示例13: setOperator

 /**
  * Set an operator.
  *
  * @param string   $operator    Operator.
  * @param callable $transformer Callable.
  *
  * @return self
  */
 public function setOperator($operator, callable $transformer)
 {
     $this->operators[$operator] = xcallable($transformer);
     return $this;
 }
开发者ID:royopa,项目名称:rulerz,代码行数:13,代码来源:GenericVisitor.php

示例14: initWebSocketServer

 /**
  * Initialize WebSocket server
  *
  * @return Hoa\Websocket\Server
  */
 public function initWebSocketServer()
 {
     $webSocketServer = $this->getWebSocketServer();
     $webSocketServer->setLogger($this->getLogger());
     if ($this->getNodeClass() !== null) {
         $webSocketServer->getConnection()->setNodeName($this->getNodeClass());
     }
     $socket = $webSocketServer->getConnection()->getSocket();
     $this->getLogger()->log('<fg=yellow>Starting server...</fg=yellow>');
     $this->getLogger()->log('Environment: <fg=green>%s</fg=green>', $this->kernelEnvironment);
     $this->getLogger()->log('Class used:');
     $this->getLogger()->log('  Logger           : %s', get_class($this->getLogger()));
     $this->getLogger()->log('  Runner           : %s', get_class($this));
     $this->getLogger()->log('  WebSocket Server : %s', get_class($webSocketServer));
     $this->getLogger()->log('  Socket Server    : %s', get_class($socket));
     $this->getLogger()->log('  Node             : %s', ltrim($webSocketServer->getConnection()->getNodeName(), '\\'));
     $this->getLogger()->log('<fg=yellow>Listening on %s:%d</fg=yellow>', $socket->getAddress(), $socket->getPort());
     $webSocketServer->on('open', xcallable($this, 'onOpen'));
     $webSocketServer->on('message', xcallable($this, 'onMessage'));
     $webSocketServer->on('binary-message', xcallable($this, 'onBinaryMessage'));
     $webSocketServer->on('ping', xcallable($this, 'onPing'));
     $webSocketServer->on('error', xcallable($this, 'onError'));
     $webSocketServer->on('close', xcallable($this, 'onClose'));
     $this->loadEvents();
     return $webSocketServer;
 }
开发者ID:atipik,项目名称:hoa-websocket-bundle,代码行数:31,代码来源:Runner.php

示例15: detach

 /**
  * Detach an object to an event.
  * Please see $this->attach() method.
  *
  * @param   mixed   $callable    Callable.
  * @return  \Hoa\Event\Event
  */
 public function detach($callable)
 {
     unset($this->_callable[xcallable($callable)->getHash()]);
     return $this;
 }
开发者ID:robertgeb,项目名称:Map-Project,代码行数:12,代码来源:Event.php


注:本文中的xcallable函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。