/**
  * @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']);
 }
Beispiel #2
0
 public function __toString()
 {
     $items = $this->items->getArrayCopy();
     $itemStrings = array_map(function (Item $item) {
         return $item->__toString() . "\n";
     }, $items);
     return implode($itemStrings);
 }
Beispiel #3
0
 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;
 }
Beispiel #4
0
 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);
 }
Beispiel #5
0
 /**
  * {@inheritdoc}
  */
 public function getArrayCopy()
 {
     $data = parent::getArrayCopy();
     foreach ($data as $index => $value) {
         $data[$index] = $value->getArrayCopy();
     }
     return $data;
 }
Beispiel #6
0
 /**
  * @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();
     }
 }
Beispiel #7
0
 /**
  * {@inheritdoc}
  */
 public function getArrayCopy()
 {
     $result = parent::getArrayCopy();
     foreach ($result as $offset => $value) {
         $result[$offset] = $value->getArrayCopy();
         unset($result[$offset]['index']);
     }
     return $result;
 }
 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());
 }
Beispiel #9
0
 /**
  * @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;
 }
 /**
  * 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();
 }
Beispiel #11
0
 /**
  * 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;
 }
Beispiel #12
0
 /**
  * 返回数组
  *
  * @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;
 }
Beispiel #13
0
Datei: Util.php Projekt: srccn/f3
 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;
 }
Beispiel #14
0
 public function toArray()
 {
     return (object) $this->data->getArrayCopy();
 }
 /**
  * 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;
     }
 }
 /**
  * @param ArrayIterator $iterator
  */
 protected function _prepareIndexDocumentCallback(ArrayIterator $iterator)
 {
     $this->_currentIndexedDocument = $iterator->getArrayCopy();
     $indexableAttributes = $this->getIndexerEntityProvider()->getIndexableAttributes();
     $storeId = $this->getIndexerEntityProvider()->getStore();
     while ($iterator->valid()) {
         $attributeCode = $iterator->key();
         $value = $iterator->current();
         if (is_array($value)) {
             $value = array_values(array_filter(array_unique($value)));
         }
         if (array_key_exists($attributeCode, $indexableAttributes['searchable'])) {
             $attributeInstance = $indexableAttributes['searchable'][$attributeCode];
             if ($attributeInstance->usesSource() && !empty($value)) {
                 if ($attributeInstance->getFrontendInput() == 'multiselect') {
                     $value = explode(',', is_array($value) ? $value[0] : $value);
                 }
                 if ($this->getIndexerEntityProvider()->isAttributeWithOptions($attributeInstance)) {
                     $val = is_array($value) ? $value[0] : $value;
                     if (!isset($this->_currentIndexedDocument['_options'])) {
                         $this->_currentIndexedDocument['_options'] = array();
                     }
                     $option = $attributeInstance->setStoreId($storeId)->getFrontend()->getOption($val);
                     $this->_currentIndexedDocument['_options'][] = $option;
                 }
             }
             if ($attributeInstance->getBackendType() == 'datetime') {
                 $value = $this->_addStoreDateFormat($storeId, $value[0]);
             }
             $this->_currentIndexedDocument[$attributeCode] = $this->_castAttributeValueType($attributeInstance, $value);
         } elseif (array_key_exists($attributeCode, $indexableAttributes['sortable'])) {
             $sortableVal = is_array($value) ? $value[0] : $value;
             $attributeInstance = $indexableAttributes['sortable'][$attributeCode];
             $sortable = $this->getSortableAttributeFieldName($attributeInstance);
             $attributeInstance->setStoreId($storeId);
             if ($attributeInstance->usesSource()) {
                 $sortableVal = $attributeInstance->getFrontend()->getOption($sortableVal);
             } elseif ($attributeInstance->getBackendType() == 'decimal') {
                 $sortableVal = (double) $sortableVal;
             }
             $this->_currentIndexedDocument[$sortable] = $sortableVal;
             $this->_currentIndexedDocument[$attributeCode] = $this->_castAttributeValueType($attributeInstance, $value);
         } else {
             $this->_currentIndexedDocument[$attributeCode] = $value;
         }
         $iterator->next();
     }
 }
Beispiel #17
0
 /**
  * 
  * @return array $array
  */
 public function getResourcesArray()
 {
     return $this->resources->getArrayCopy();
 }
<?php

$b = array('name' => 'mengzhi', 'age' => '12', 'city' => 'shanghai');
$a = new ArrayIterator($b);
$a->append(array('home' => 'china', 'work' => 'developer'));
$c = $a->getArrayCopy();
echo "<pre>";
var_dump($a);
var_dump($c);
 /**
  * {@inheritdoc}
  */
 public function contains(ComponentInterface $component)
 {
     return in_array($component, $this->coll->getArrayCopy(), true);
 }
Beispiel #20
0
 protected function encode(\ArrayIterator $array)
 {
     return base64_encode(serialize($array->getArrayCopy()));
 }
Beispiel #21
0
<?php

$arr = new ArrayObject(array(1, 2));
$iter1 = new ArrayIterator($arr);
var_dump($iter1->getArrayCopy());
$iter2 = new ArrayIterator($iter1);
var_dump($iter2->getArrayCopy());
Beispiel #22
0
 /**
  * @param FractalFactory                     $fractalFactory
  * @param Fractal\Resource\ResourceInterface $resource
  * @param Fractal\Manager                    $manager
  * @param Fractal\Scope                      $scope
  * @param \ArrayIterator                     $data
  */
 protected function setPayloadAssertions(FractalFactory $fractalFactory, Fractal\Resource\ResourceInterface $resource, Fractal\Manager $manager, Fractal\Scope $scope, \ArrayIterator $data)
 {
     $fractalFactory->createManager()->shouldBeCalled()->willReturn($manager);
     $manager->createData($resource)->shouldBeCalled()->willReturn($scope);
     $scope->toArray()->shouldBeCalled()->willReturn($data->getArrayCopy());
 }
Beispiel #23
0
 /**
  * Gets an array
  * @return array
  */
 public function getArray()
 {
     return $this->_list->getArrayCopy();
 }
 public function testIterator()
 {
     $ar = new ArrayObject(array('1' => 'one', '2' => 'two', '3' => 'three'));
     $iterator = $ar->getIterator();
     $iterator2 = new \ArrayIterator($ar->getArrayCopy());
     $this->assertEquals($iterator2->getArrayCopy(), $iterator->getArrayCopy());
 }
 /**
  * @return array
  */
 public function getLocations()
 {
     return $this->locations->getArrayCopy();
 }
Beispiel #26
0
 /**
  * Return a copy of the unfiltered array.
  */
 public function get_array_copy_raw()
 {
     return parent::getArrayCopy();
 }
Beispiel #27
0
 /**
  * Returns the data contained in the Result
  *
  * @return array
  */
 public function getData()
 {
     return $this->oDataIterator->getArrayCopy();
 }
 /**
  * {@inheritDoc}
  */
 public function toArray()
 {
     return $this->map->getArrayCopy();
 }
 /**
  * Prepare organization diff
  * 
  * @access public
  * 
  * @param \ArrayIterator $organizationComparisonData
  * @return \ArrayIterator prepared organization comparison data
  */
 public function prepareOrganizationDiff($organizationComparisonData)
 {
     $organizationComparisonArray = $organizationComparisonData->getArrayCopy();
     $organizationComparisonPreparedArray = $this->prepareForDisplay(reset($organizationComparisonArray));
     $locationChanged = false;
     if ($organizationComparisonPreparedArray["before"]->longtitude != $organizationComparisonPreparedArray["after"]->longtitude || $organizationComparisonPreparedArray["before"]->latitude != $organizationComparisonPreparedArray["after"]->latitude) {
         $locationChanged = true;
     }
     $organizationComparisonPreparedArray["after"]->locationChanged = $locationChanged;
     $attachmentsArray = array('CRAttachment', 'wireTransferAttachment', 'atpLicenseAttachment', 'atcLicenseAttachment');
     foreach ($attachmentsArray as $attachment) {
         $attachmentChanged = false;
         $attachmentChangedText = $attachment . "Changed";
         if ($organizationComparisonPreparedArray["before"]->{$attachment} != $organizationComparisonPreparedArray["after"]->{$attachment}) {
             $attachmentChanged = true;
         }
         $organizationComparisonPreparedArray["after"]->{$attachmentChangedText} = $attachmentChanged;
     }
     $organizationComparisonPreparedData = new \ArrayIterator(array($organizationComparisonPreparedArray));
     return $organizationComparisonPreparedData;
 }
Beispiel #30
0
 public function transformArrayIterator(\ArrayIterator $arrayIterator)
 {
     return new \ArrayIterator($this->transformArray($arrayIterator->getArrayCopy()));
 }