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


PHP ArrayIterator::getArrayCopy方法代码示例

本文整理汇总了PHP中ArrayIterator::getArrayCopy方法的典型用法代码示例。如果您正苦于以下问题:PHP ArrayIterator::getArrayCopy方法的具体用法?PHP ArrayIterator::getArrayCopy怎么用?PHP ArrayIterator::getArrayCopy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ArrayIterator的用法示例。


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

示例1: testInitWithWrongProperty

 /**
  * @expectedException \X\ConfigManager\Exception\PropertyNotExistsException
  * @expectedExceptionMessageRegExp ~.*?X\\Test\\MappingClass\\RootElement.*?nonExistProperty.*?~
  *
  * @throws \X\ConfigManager\Exception\PropertyNotExistsException
  */
 public function testInitWithWrongProperty()
 {
     $rootElement = new RootElement();
     $rootElementWrongConfig = $this->rootElementConfig->getArrayCopy();
     $rootElementWrongConfig['content']['nonExistProperty'] = true;
     $rootElement->initialize($rootElementWrongConfig['content']);
 }
开发者ID:xpr0ger,项目名称:configuration-builder,代码行数:13,代码来源:ConfigurationElementTest.php

示例2: __toString

 public function __toString()
 {
     $items = $this->items->getArrayCopy();
     $itemStrings = array_map(function (Item $item) {
         return $item->__toString() . "\n";
     }, $items);
     return implode($itemStrings);
 }
开发者ID:estelsmith,项目名称:earley-parser,代码行数:8,代码来源:Set.php

示例3: __toString

 public function __toString()
 {
     /** @var Set[] $sets */
     $sets = $this->sets->getArrayCopy();
     $setsString = '';
     foreach ($sets as $index => $set) {
         $setsString .= sprintf("-- %d --\n", $index);
         $setsString .= $set->__toString() . "\n";
     }
     return $setsString;
 }
开发者ID:estelsmith,项目名称:earley-parser,代码行数:11,代码来源:State.php

示例4: testConstructor

 public function testConstructor()
 {
     // array input
     $input = [];
     $this->mock->expects($this->at(0))->method('setOptions')->with($this->equalTo($input));
     $class = new \ReflectionClass(self::CLASSNAME);
     $ctor = $class->getConstructor();
     $ctor->invoke($this->mock, $input);
     // traversable input
     $input = new \ArrayIterator([]);
     $this->mock->expects($this->at(0))->method('setOptions')->with($this->equalTo($input->getArrayCopy()));
     $ctor->invoke($this->mock, $input);
     // string input
     $input = 'adapter';
     $this->mock->expects($this->at(0))->method('setAdapter')->with($this->equalTo($input));
     $ctor->invoke($this->mock, $input);
     // adapter input
     $input = $this->getMockForAbstractClass('Conversio\\ConversionAlgorithmInterface');
     $this->mock->expects($this->at(0))->method('setAdapter')->with($this->equalTo($input));
     $ctor->invoke($this->mock, $input);
     // null input
     $input = null;
     $this->mock->expects($this->never())->method('setAdapter')->with($this->equalTo($input));
     $this->mock->expects($this->never())->method('setOptions')->with($this->equalTo($input));
     $ctor->invoke($this->mock, $input);
 }
开发者ID:leodido,项目名称:conversio,代码行数:26,代码来源:ConversionTest.php

示例5: getArrayCopy

 /**
  * {@inheritdoc}
  */
 public function getArrayCopy()
 {
     $data = parent::getArrayCopy();
     foreach ($data as $index => $value) {
         $data[$index] = $value->getArrayCopy();
     }
     return $data;
 }
开发者ID:jdolieslager,项目名称:jsonrpc,代码行数:11,代码来源:Response.php

示例6: unshift

 /**
  * @param $offset
  * @param $value
  */
 public function unshift($offset, \Barberry\PostedFile $value)
 {
     $currentKey = $this->key();
     $this->specsIterator = new \ArrayIterator(array_merge(array($offset => $value), array_diff_key($this->specsIterator->getArrayCopy(), array($offset => false))));
     while ($this->specsIterator->key() !== $currentKey) {
         $this->specsIterator->next();
     }
 }
开发者ID:lionjsa,项目名称:Barberry,代码行数:12,代码来源:Collection.php

示例7: getArrayCopy

 /**
  * {@inheritdoc}
  */
 public function getArrayCopy()
 {
     $result = parent::getArrayCopy();
     foreach ($result as $offset => $value) {
         $result[$offset] = $value->getArrayCopy();
         unset($result[$offset]['index']);
     }
     return $result;
 }
开发者ID:jdolieslager,项目名称:jsonrpc,代码行数:12,代码来源:Parameter.php

示例8: testProxiesMagicCallsToInnermostIterator

 public function testProxiesMagicCallsToInnermostIterator()
 {
     $i = new \ArrayIterator();
     $proxy = new MethodProxyIterator(new MethodProxyIterator(new MethodProxyIterator($i)));
     $proxy->append('a');
     $proxy->append('b');
     $this->assertEquals(array('a', 'b'), $i->getArrayCopy());
     $this->assertEquals(array('a', 'b'), $proxy->getArrayCopy());
 }
开发者ID:Frinstio,项目名称:AlfredWorkflow.com,代码行数:9,代码来源:MethodProxyIteratorTest.php

示例9: process

 /**
  * @param string         $content
  * @param \ArrayIterator $queue
  *
  * @return \C2iS\ApnsSender\Model\MessageError|bool
  */
 public function process($content, \ArrayIterator $queue)
 {
     while ($queue->valid()) {
         $key = $queue->key();
         $token = $queue->current();
         $message = MessageFactory::createMessage($key, $token, $content);
         if (!$this->streamHandler->write($message)) {
             $streamError = $this->streamHandler->readError();
             $messageError = MessageFactory::createError($queue->getArrayCopy(), $streamError, $key, $token);
             $this->logger->info('Error sending notification to token', array('current_key' => $key, 'current_token' => $token, 'error_code' => $messageError->getErrorCode(), 'error_message' => $messageError->getErrorMessage(), 'error_key' => $messageError->getCustomIdentifier(), 'error_token' => $messageError->getToken()));
             return $messageError;
         }
         $queue->next();
         Sleep::millisecond(self::SEND_INTERVAL);
     }
     Sleep::millisecond(self::END_WAIT);
     $streamError = $this->streamHandler->readError();
     if ($streamError) {
         $messageError = MessageFactory::createError($queue->getArrayCopy(), $streamError);
         $this->logger->info('Error sending notification to token', array('key' => $messageError->getCustomIdentifier(), 'token' => $messageError->getToken(), 'error_code' => $messageError->getErrorCode(), 'error_message' => $messageError->getErrorMessage()));
         return $messageError;
     }
     return true;
 }
开发者ID:c2is,项目名称:ApnsSender,代码行数:30,代码来源:Worker.php

示例10: extractArray

 /**
  * Extract array of var in object
  * @param   Object $object
  * @returns array Array extracted of the object
  */
 public function extractArray($object, $isRecursive = false)
 {
     if (method_exists($object, "toArray")) {
         return $object->toArray();
     }
     $arrayCollection = new \ArrayIterator();
     $reflection = new \ReflectionClass($object);
     $vars = array_keys($reflection->getdefaultProperties());
     foreach ($vars as $key) {
         $value = $this->resolveGetNameMethod($key, $object);
         if ($value !== null) {
             if (is_object($value) && !$isRecursive) {
                 $arrayCollection->offsetSet($key, $this->extractArray($value, true));
             } else {
                 $arrayCollection->offsetSet($key, $value);
             }
         }
     }
     return $arrayCollection->getArrayCopy();
 }
开发者ID:brenodouglas,项目名称:doctrineconfig,代码行数:25,代码来源:SimpleHydrator.php

示例11: avoidBackwardDuplicates

 /**
  * Removes results which were found in the previous iteration.
  * 
  * This applies to backward iteration only
  */
 private function avoidBackwardDuplicates(array &$results)
 {
     // applies only on the last step of backward iteration
     if ($this->direction == KeyReader::DIRECTION_FORWARD || $this->offset >= 0) {
         return;
     }
     // get the minimum of the last iteration
     $lastResults = $this->iterator->getArrayCopy();
     if (empty($lastResults)) {
         return;
     }
     $lastMinimum = end($lastResults)->getKey();
     // reduce the results
     $reducedResults = array();
     foreach ($results as $result) {
         if ($result->getKey() >= $lastMinimum) {
             continue;
         }
         $reducedResults[] = $result;
     }
     $results = $reducedResults;
 }
开发者ID:malkusch,项目名称:php-index,代码行数:27,代码来源:IndexIterator.php

示例12: as_array

 /**
  * 返回数组
  *
  * @param string $key 返回以$key为键名的数组
  * @param string $value_key 返回$value_key键名的值
  */
 public function as_array($key = null, $value_key = null)
 {
     $data = parent::getArrayCopy();
     if ($key || $value_key) {
         $result = array();
         foreach ($data as $item) {
             if ($key) {
                 if ($value_key) {
                     $result[$item->{$key}] = $item->{$value_key};
                 } else {
                     $result[$item->{$key}] = $item;
                 }
             } else {
                 if ($value_key) {
                     $result[] = $item->{$value_key};
                 } else {
                     $result[] = $item;
                 }
             }
         }
         return $result;
     }
     return $data;
 }
开发者ID:myqee,项目名称:core,代码行数:30,代码来源:result.class.php

示例13: prependColumn

 static function prependColumn($column, $table)
 {
     if (count($column) !== count($table)) {
         die("failed prepend Column, due to number of elements mismatch." . count($column) . " vs " . count($table));
     }
     $a = new ArrayIterator($table);
     $returnTable = $a->getArrayCopy();
     $number = count($column);
     for ($i = 0; $i < $number; $i++) {
         array_unshift($returnTable[$i], $column[$i]);
     }
     return $returnTable;
 }
开发者ID:srccn,项目名称:f3,代码行数:13,代码来源:Util.php

示例14: toArray

 public function toArray()
 {
     return (object) $this->data->getArrayCopy();
 }
开发者ID:jayS-de,项目名称:JsonMapper,代码行数:4,代码来源:Node.php

示例15: translateUrl

 /**
  * Translate an url
  *
  * @param string   $matchedRouteName    The routematch name
  * @param Uri|null $uri                 Use other URI (Console environments)
  * @param array    $params              The params for the route
  * @param array    $options             The options for the router::assemble
  * @param boolean  $forceHttpRouter     Force to use the http router
  * @param boolean  $reuseMatchedParams  Whether to reuse matched parameters
  *
  * @return string
  */
 public function translateUrl($matchedRouteName = null, Uri $uri = null, array $params = array(), array $options = array(), $forceHttpRouter = false, $reuseMatchedParams = false)
 {
     $routeMatch = $this->getMvcEvent()->getRouteMatch();
     $router = $this->getMvcEvent()->getRouter();
     if ($forceHttpRouter) {
         $router = $this->getMvcEvent()->getApplication()->getServiceManager()->get('httprouter');
     }
     if ($matchedRouteName === null) {
         $matchedRouteName = $routeMatch->getMatchedRouteName();
         if ($matchedRouteName === null) {
             throw new Exception\RuntimeException('RouteMatch does not contain a matched route name');
         }
     }
     if ($reuseMatchedParams && $routeMatch !== null) {
         $routeMatchParams = $routeMatch->getParams();
         if (isset($routeMatchParams[ModuleRouteListener::ORIGINAL_CONTROLLER])) {
             $routeMatchParams['controller'] = $routeMatchParams[ModuleRouteListener::ORIGINAL_CONTROLLER];
             unset($routeMatchParams[ModuleRouteListener::ORIGINAL_CONTROLLER]);
         }
         if (isset($routeMatchParams[ModuleRouteListener::MODULE_NAMESPACE])) {
             unset($routeMatchParams[ModuleRouteListener::MODULE_NAMESPACE]);
         }
         $params = array_merge($routeMatchParams, $params);
     }
     $result = $this->translate($matchedRouteName, self::NAMESPACE_ROUTE_MATCH);
     if ($result !== $matchedRouteName) {
         foreach ($params as $key => $value) {
             if (array_key_exists($key, $result) === false) {
                 continue;
             }
             $paramKey = $key;
             if (array_key_exists($paramKey, $this->urlMapping)) {
                 $paramKey = $this->urlMapping[$paramKey];
             }
             if ($idx = array_search($value, $result[$paramKey])) {
                 $params[$key] = $idx;
             }
         }
     }
     if ($uri === null) {
         $request = $this->getMvcEvent()->getRequest();
         if ($request instanceof \Zend\Http\Request) {
             $uri = $request->getUri();
         } else {
             $uri = new \Zend\Uri\Http();
             $this->getEventManager()->triggerMissingUri(array('uri' => $uri));
         }
     }
     $options['name'] = $matchedRouteName;
     $options['uri'] = $uri;
     $options = new \ArrayIterator($options);
     $params = new \ArrayIterator($params);
     $this->getEventManager()->triggerPreAssemble(array('options' => $options, 'params' => $params));
     try {
         return $router->assemble($params->getArrayCopy(), $options->getArrayCopy());
     } catch (\Exception $e) {
         echo $e->getTraceAsString();
         exit;
     }
 }
开发者ID:jdolieslager,项目名称:fetranslator,代码行数:72,代码来源:Translator.php


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