public static function getInitializer(ClassLoader $loader)
 {
     return \Closure::bind(function () use($loader) {
         $loader->prefixLengthsPsr4 = ComposerStaticInitf1352f2cf6649e5122b3200d19030cce::$prefixLengthsPsr4;
         $loader->prefixDirsPsr4 = ComposerStaticInitf1352f2cf6649e5122b3200d19030cce::$prefixDirsPsr4;
     }, null, ClassLoader::class);
 }
 public static function getInitializer(ClassLoader $loader)
 {
     return \Closure::bind(function () use($loader) {
         $loader->prefixLengthsPsr4 = ComposerStaticInit2103f6e438c101833cc1f952a48877c1::$prefixLengthsPsr4;
         $loader->prefixDirsPsr4 = ComposerStaticInit2103f6e438c101833cc1f952a48877c1::$prefixDirsPsr4;
     }, null, ClassLoader::class);
 }
 public static function getInitializer(ClassLoader $loader)
 {
     return \Closure::bind(function () use($loader) {
         $loader->prefixesPsr0 = ComposerStaticInit387a61af024f277d76be6a9ad67ce9d2::$prefixesPsr0;
         $loader->classMap = ComposerStaticInit387a61af024f277d76be6a9ad67ce9d2::$classMap;
     }, null, ClassLoader::class);
 }
 public static function getInitializer(ClassLoader $loader)
 {
     return \Closure::bind(function () use($loader) {
         $loader->prefixLengthsPsr4 = ComposerStaticInit85a1cefa95be2f464cf7f947cbc4c785::$prefixLengthsPsr4;
         $loader->prefixDirsPsr4 = ComposerStaticInit85a1cefa95be2f464cf7f947cbc4c785::$prefixDirsPsr4;
     }, null, ClassLoader::class);
 }
 private function fillClassInstance($instance, $data)
 {
     $instantiator = $this;
     $valueProcessor = function ($value) use(&$valueProcessor, $instantiator) {
         if ($value instanceof ArrayedObject) {
             $value = $instantiator->instantiate($value);
         }
         if (is_array($value)) {
             foreach ($value as &$innerValue) {
                 $innerValue = $valueProcessor($innerValue);
             }
         }
         return $value;
     };
     $setObjectVarsClosure = function ($data, $class, &$valueProcessor) {
         foreach ($data as $property => $value) {
             if (property_exists($class, $property)) {
                 $value = $valueProcessor($value);
                 $this->{$property} = $value;
             }
         }
     };
     $class = get_class($instance);
     do {
         $bindedSetObjectVarsClosure = \Closure::bind($setObjectVarsClosure, $instance, $class);
         $bindedSetObjectVarsClosure($data, $class, $valueProcessor);
     } while ($class = get_parent_class($class));
 }
Example #6
0
 protected function __construct($namespace = '', $defaultLifetime = 0)
 {
     $this->namespace = '' === $namespace ? '' : $this->getId($namespace) . ':';
     if (null !== $this->maxIdLength && strlen($namespace) > $this->maxIdLength - 24) {
         throw new InvalidArgumentException(sprintf('Namespace must be %d chars max, %d given ("%s")', $this->maxIdLength - 24, strlen($namespace), $namespace));
     }
     $this->createCacheItem = \Closure::bind(function ($key, $value, $isHit) use($defaultLifetime) {
         $item = new CacheItem();
         $item->key = $key;
         $item->value = $value;
         $item->isHit = $isHit;
         $item->defaultLifetime = $defaultLifetime;
         return $item;
     }, null, CacheItem::class);
     $this->mergeByLifetime = \Closure::bind(function ($deferred, $namespace, &$expiredIds) {
         $byLifetime = array();
         $now = time();
         $expiredIds = array();
         foreach ($deferred as $key => $item) {
             if (null === $item->expiry) {
                 $byLifetime[0 < $item->defaultLifetime ? $item->defaultLifetime : 0][$namespace . $key] = $item->value;
             } elseif ($item->expiry > $now) {
                 $byLifetime[$item->expiry - $now][$namespace . $key] = $item->value;
             } else {
                 $expiredIds[] = $namespace . $key;
             }
         }
         return $byLifetime;
     }, null, CacheItem::class);
 }
Example #7
0
 public static function getInitializer(ClassLoader $loader)
 {
     return \Closure::bind(function () use($loader) {
         $loader->prefixLengthsPsr4 = ComposerStaticInitc9b168e8400f8789b0e099f4aa1d40aa::$prefixLengthsPsr4;
         $loader->prefixDirsPsr4 = ComposerStaticInitc9b168e8400f8789b0e099f4aa1d40aa::$prefixDirsPsr4;
     }, null, ClassLoader::class);
 }
Example #8
0
function get_changed_values($object)
{
    $function = \Closure::bind(function ($object) {
        $changedValues = $object->changedValues;
        // hack I know
        if (property_exists($object, 'objects')) {
            foreach ($object->objects as $namespace => $namespaceValues) {
                foreach ($namespaceValues as $name => $values) {
                    if (is_array($values)) {
                        foreach ($values as $valueKey => $value) {
                            $changed = get_changed_values($value);
                            if (false == empty($changed)) {
                                $changedValues[$namespace][$name][$valueKey] = $changed;
                            }
                        }
                    } elseif (is_object($values)) {
                        $changed = get_changed_values($values);
                        if (false == empty($changed)) {
                            $changedValues[$namespace][$name] = $changed;
                        }
                    }
                }
            }
        }
        return $changedValues;
    }, null, $object);
    return $function($object);
}
Example #9
0
function partial(callable $callable, $partialArgs, $defaultArgs = [])
{
    $partialMerge = function ($partialArgs, $addedArgs, $defaultArgs = []) {
        end($partialArgs);
        $l = key($partialArgs);
        for ($i = 0; $i <= $l; $i++) {
            if (!array_key_exists($i, $partialArgs) && count($addedArgs)) {
                $partialArgs[$i] = array_shift($addedArgs);
            }
        }
        if (count($addedArgs)) {
            // there are $addedArgs left, so there should be no 'holes' in $partialArgs
            $partialArgs = array_merge($partialArgs, $addedArgs);
        }
        // fill any 'holes' in $partialArgs with entries from $defaultArgs
        $result = array_replace($defaultArgs, $partialArgs);
        ksort($result);
        return $result;
    };
    return function () use($callable, $partialArgs, $defaultArgs, $partialMerge) {
        if ($callable instanceof \Closure && isset($this)) {
            $callable = \Closure::bind($callable, $this);
        }
        return call_user_func_array($callable, $partialMerge($partialArgs, func_get_args(), $defaultArgs));
    };
}
 public function addMethod($methodName, $methodCallable)
 {
     if (!is_callable($methodCallable)) {
         throw new \InvalidArgumentException('Second param must be callable');
     }
     $this->methods[$methodName] = \Closure::bind($methodCallable, $this, get_class());
 }
 public static function getInitializer(ClassLoader $loader)
 {
     return \Closure::bind(function () use($loader) {
         $loader->prefixLengthsPsr4 = ComposerStaticInitee24b804a2f00cc5ec6cefabe5f3d658::$prefixLengthsPsr4;
         $loader->prefixDirsPsr4 = ComposerStaticInitee24b804a2f00cc5ec6cefabe5f3d658::$prefixDirsPsr4;
     }, null, ClassLoader::class);
 }
Example #12
0
 public static function getInitializer(ClassLoader $loader)
 {
     return \Closure::bind(function () use($loader) {
         $loader->prefixLengthsPsr4 = ComposerStaticInit4136185281a97be0e373e4c1a575a123::$prefixLengthsPsr4;
         $loader->prefixDirsPsr4 = ComposerStaticInit4136185281a97be0e373e4c1a575a123::$prefixDirsPsr4;
     }, null, ClassLoader::class);
 }
 public static function getInitializer(ClassLoader $loader)
 {
     return \Closure::bind(function () use($loader) {
         $loader->prefixLengthsPsr4 = ComposerStaticInit923639f9b6d3390d9802ecd1f72b6130::$prefixLengthsPsr4;
         $loader->prefixDirsPsr4 = ComposerStaticInit923639f9b6d3390d9802ecd1f72b6130::$prefixDirsPsr4;
     }, null, ClassLoader::class);
 }
Example #14
0
 public static function getInitializer(ClassLoader $loader)
 {
     return \Closure::bind(function () use($loader) {
         $loader->prefixesPsr0 = ComposerStaticInit8c00ac27a90dfc4ac1a7acb480023ed4::$prefixesPsr0;
         $loader->classMap = ComposerStaticInit8c00ac27a90dfc4ac1a7acb480023ed4::$classMap;
     }, null, ClassLoader::class);
 }
 public static function getInitializer(ClassLoader $loader)
 {
     return \Closure::bind(function () use($loader) {
         $loader->prefixLengthsPsr4 = ComposerStaticInit5aaf7da0fd82b6a6ed0ed396a67edc3d::$prefixLengthsPsr4;
         $loader->prefixDirsPsr4 = ComposerStaticInit5aaf7da0fd82b6a6ed0ed396a67edc3d::$prefixDirsPsr4;
     }, null, ClassLoader::class);
 }
Example #16
0
 public static function getInitializer(ClassLoader $loader)
 {
     return \Closure::bind(function () use($loader) {
         $loader->prefixLengthsPsr4 = ComposerStaticInitd530de204ef18056db76679ad2b19aa5::$prefixLengthsPsr4;
         $loader->prefixDirsPsr4 = ComposerStaticInitd530de204ef18056db76679ad2b19aa5::$prefixDirsPsr4;
     }, null, ClassLoader::class);
 }
 /**
  * @param string $type
  */
 private function call_filters($type)
 {
     $loaded_route = $this->router->get_active_route();
     $filter_list = Route::get_filters($loaded_route, $type);
     foreach ($filter_list as $filter_data) {
         $param_list = $this->__filter_params;
         $callback = $filter_data['filter'];
         $params = $filter_data['parameters'];
         // check if callback has parameters
         if (!is_null($params)) {
             // separate the multiple parameters in case there are defined
             $params = explode(':', $params);
             // search for uris defined as parameters, they will be marked as {(.*)}
             foreach ($params as &$p) {
                 if (preg_match('/\\{(.*)\\}/', $p, $match_p)) {
                     $p = $this->uri->segment($match_p[1]);
                 }
             }
             $param_list = array_merge($param_list, $params);
         }
         if (class_exists('Closure') and method_exists('Closure', 'bind')) {
             $callback = Closure::bind($callback, $this);
         }
         call_user_func_array($callback, $param_list);
     }
 }
 public static function getInitializer(ClassLoader $loader)
 {
     return \Closure::bind(function () use($loader) {
         $loader->prefixLengthsPsr4 = ComposerStaticInit02b5dde78564c382f4b7de2333fdf133::$prefixLengthsPsr4;
         $loader->prefixDirsPsr4 = ComposerStaticInit02b5dde78564c382f4b7de2333fdf133::$prefixDirsPsr4;
     }, null, ClassLoader::class);
 }
Example #19
0
 protected function __construct($namespace = '', $defaultLifetime = 0)
 {
     $this->namespace = '' === $namespace ? '' : $this->getId($namespace);
     $this->createCacheItem = \Closure::bind(function ($key, $value, $isHit) use($defaultLifetime) {
         $item = new CacheItem();
         $item->key = $key;
         $item->value = $value;
         $item->isHit = $isHit;
         $item->defaultLifetime = $defaultLifetime;
         return $item;
     }, $this, CacheItem::class);
     $this->mergeByLifetime = \Closure::bind(function ($deferred, $namespace, &$expiredIds) {
         $byLifetime = array();
         $now = time();
         $expiredIds = array();
         foreach ($deferred as $key => $item) {
             if (null === $item->expiry) {
                 $byLifetime[0][$namespace . $key] = $item->value;
             } elseif ($item->expiry > $now) {
                 $byLifetime[$item->expiry - $now][$namespace . $key] = $item->value;
             } else {
                 $expiredIds[] = $namespace . $key;
             }
         }
         return $byLifetime;
     }, $this, CacheItem::class);
 }
 public static function getInitializer(ClassLoader $loader)
 {
     return \Closure::bind(function () use($loader) {
         $loader->prefixLengthsPsr4 = ComposerStaticInitb8a50a4ca2319fdf8bb9b75a63bd3789::$prefixLengthsPsr4;
         $loader->prefixDirsPsr4 = ComposerStaticInitb8a50a4ca2319fdf8bb9b75a63bd3789::$prefixDirsPsr4;
     }, null, ClassLoader::class);
 }
 public static function getInitializer(ClassLoader $loader)
 {
     return \Closure::bind(function () use($loader) {
         $loader->prefixLengthsPsr4 = ComposerStaticIniteda2edcf35e3249484bbc681eb6321db::$prefixLengthsPsr4;
         $loader->prefixDirsPsr4 = ComposerStaticIniteda2edcf35e3249484bbc681eb6321db::$prefixDirsPsr4;
     }, null, ClassLoader::class);
 }
Example #22
0
 public static function getInitializer(ClassLoader $loader)
 {
     return \Closure::bind(function () use($loader) {
         $loader->prefixLengthsPsr4 = ComposerStaticInit3509bae1b43f46f35451983aa30aec82::$prefixLengthsPsr4;
         $loader->prefixDirsPsr4 = ComposerStaticInit3509bae1b43f46f35451983aa30aec82::$prefixDirsPsr4;
     }, null, ClassLoader::class);
 }
 public function testCreateSendgridDriver()
 {
     $createSendgridDriver = \Closure::bind(function () {
         return $this->createSendgridDriver();
     }, $this->transportManager, 'Sichikawa\\LaravelSendgridDriver\\TransportManager');
     $this->assertInstanceOf(SendgridTransport::class, $createSendgridDriver());
 }
Example #24
0
 /**
  * @inheritdoc
  */
 public function listen($queue, callable $callback, array $options = [])
 {
     $options = array_merge($this->defaultConfig['listener'], $options);
     $connectionConfig = $this->getConfig('connection', $this->config['queues'][$queue]['connection']);
     $ackAt = isset($options['multi_ack']) ? ceil($connectionConfig['prefetch_count'] / 2) : 0;
     try {
         $queue = $this->getQueue($queue);
         $acknowledged = 0;
         $queue->consume(\Closure::bind(function (\AMQPEnvelope $envelope) use($callback, $queue, $ackAt, &$acknowledged) {
             $result = new Message\Result();
             call_user_func($callback, Helper\Message::convert($envelope), $result);
             if ($result->getStatus()) {
                 if ($ackAt > 1) {
                     if (0 == ++$acknowledged % $ackAt) {
                         $queue->ack($envelope->getDeliveryTag(), AMQP_MULTIPLE);
                     }
                 } else {
                     $queue->ack($envelope->getDeliveryTag());
                 }
             } else {
                 $queue->nack($envelope->getDeliveryTag(), $result->isRequeue() ? AMQP_REQUEUE : AMQP_NOPARAM);
             }
             if ($result->isStop()) {
                 return false;
             }
         }, $this), Helper\Options::toFlags($options));
     } catch (\Exception $e) {
         throw Helper\Exception::convert($e);
     }
 }
Example #25
0
 public static function getInitializer(ClassLoader $loader)
 {
     return \Closure::bind(function () use($loader) {
         $loader->prefixLengthsPsr4 = ComposerStaticInitff8fdb38850ff251f4358720f3236811::$prefixLengthsPsr4;
         $loader->prefixDirsPsr4 = ComposerStaticInitff8fdb38850ff251f4358720f3236811::$prefixDirsPsr4;
     }, null, ClassLoader::class);
 }
Example #26
0
 public function testCache_インスタンス生成()
 {
     $cache = call_user_func(\Closure::bind(function () {
         return new Cache();
     }, null, 'Lodestone\\Cache'));
     $this->assertTrue($cache instanceof Cache);
 }
 public static function getInitializer(ClassLoader $loader)
 {
     return \Closure::bind(function () use($loader) {
         $loader->prefixesPsr0 = ComposerStaticInit48659fc570da1a2d7d2349b19a7d2aa2::$prefixesPsr0;
         $loader->classMap = ComposerStaticInit48659fc570da1a2d7d2349b19a7d2aa2::$classMap;
     }, null, ClassLoader::class);
 }
 public static function getInitializer(ClassLoader $loader)
 {
     return \Closure::bind(function () use($loader) {
         $loader->prefixLengthsPsr4 = ComposerStaticInit2094ff3d8e92ca93ee143de89c1ea6d7::$prefixLengthsPsr4;
         $loader->prefixDirsPsr4 = ComposerStaticInit2094ff3d8e92ca93ee143de89c1ea6d7::$prefixDirsPsr4;
     }, null, ClassLoader::class);
 }
 /**
  * Creates a number format object from the provided definition.
  *
  * @param array  $definition The number format definition.
  * @param string $locale     The locale of the number format definition.
  *
  * @return NumberFormat
  */
 protected function createNumberFormatFromDefinition(array $definition, $locale)
 {
     if (!isset($definition['decimal_separator'])) {
         $definition['decimal_separator'] = '.';
     }
     if (!isset($definition['grouping_separator'])) {
         $definition['grouping_separator'] = ',';
     }
     if (!isset($definition['plus_sign'])) {
         $definition['plus_sign'] = '+';
     }
     if (!isset($definition['minus_sign'])) {
         $definition['minus_sign'] = '-';
     }
     if (!isset($definition['percent_sign'])) {
         $definition['percent_sign'] = '%';
     }
     $numberFormat = new NumberFormat();
     $setValues = \Closure::bind(function ($definition, $locale) {
         $this->locale = $locale;
         $this->numberingSystem = $definition['numbering_system'];
         $this->decimalSeparator = $definition['decimal_separator'];
         $this->groupingSeparator = $definition['grouping_separator'];
         $this->plusSign = $definition['plus_sign'];
         $this->minusSign = $definition['minus_sign'];
         $this->percentSign = $definition['percent_sign'];
         $this->decimalPattern = $definition['decimal_pattern'];
         $this->percentPattern = $definition['percent_pattern'];
         $this->currencyPattern = $definition['currency_pattern'];
         $this->accountingCurrencyPattern = $definition['accounting_currency_pattern'];
     }, $numberFormat, '\\CommerceGuys\\Intl\\NumberFormat\\NumberFormat');
     $setValues($definition, $locale);
     return $numberFormat;
 }
 public static function getInitializer(ClassLoader $loader)
 {
     return \Closure::bind(function () use($loader) {
         $loader->prefixLengthsPsr4 = ComposerStaticInitacfecd0691b24a734456dd0df23cb980::$prefixLengthsPsr4;
         $loader->prefixDirsPsr4 = ComposerStaticInitacfecd0691b24a734456dd0df23cb980::$prefixDirsPsr4;
     }, null, ClassLoader::class);
 }