當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ArrayObject::serialize方法代碼示例

本文整理匯總了PHP中ArrayObject::serialize方法的典型用法代碼示例。如果您正苦於以下問題:PHP ArrayObject::serialize方法的具體用法?PHP ArrayObject::serialize怎麽用?PHP ArrayObject::serialize使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在ArrayObject的用法示例。


在下文中一共展示了ArrayObject::serialize方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: serialize

 public function serialize()
 {
     foreach (new \ArrayIterator($this) as $index => $object) {
         if ($object instanceof DisposableInterface && $object->isDisposed()) {
             $this->offsetUnset($index);
         }
     }
     return parent::serialize();
 }
開發者ID:SystemEd-Jacob,項目名稱:nethgui,代碼行數:9,代碼來源:ArrayDisposable.php

示例2: getComponentData

 public function getComponentData()
 {
     $cachedData = new \ArrayObject(['test_component1' => [ManagerInterface::COMPONENT_ARGUMENTS_KEY => ['argument_name1' => ['value' => 'value1']], ManagerInterface::CHILDREN_KEY => ['custom' => [ManagerInterface::COMPONENT_ARGUMENTS_KEY => ['custom_name1' => ['value' => 'custom_value1']], ManagerInterface::CHILDREN_KEY => []]]]]);
     return [['test_component1', new \ArrayObject(), $cachedData->serialize(), [], ['test_component1' => [ManagerInterface::COMPONENT_ARGUMENTS_KEY => ['argument_name1' => ['argument' => 'value1']], ManagerInterface::CHILDREN_KEY => ['custom' => [ManagerInterface::COMPONENT_ARGUMENTS_KEY => ['custom_name1' => ['argument' => 'custom_value1']], ManagerInterface::CHILDREN_KEY => []]]]]], ['test_component2', new \ArrayObject(['test_component2' => [ManagerInterface::COMPONENT_ARGUMENTS_KEY => ['argument_name2' => ['value' => 'value2']], ManagerInterface::CHILDREN_KEY => ['test_component21' => [ManagerInterface::COMPONENT_ARGUMENTS_KEY => ['argument_name21' => ['value' => 'value21']], ManagerInterface::CHILDREN_KEY => []]]]]), false, ['componentGroup' => [0 => [Converter::DATA_ARGUMENTS_KEY => ['argument_name2' => ['value' => 'value2']], Converter::DATA_ATTRIBUTES_KEY => ['name' => 'attribute_name2'], 'test_component21' => [0 => [Converter::DATA_ARGUMENTS_KEY => ['argument_name21' => ['value' => 'value21']], Converter::DATA_ATTRIBUTES_KEY => ['name' => 'attribute_name21']]]]]], ['test_component2' => [ManagerInterface::COMPONENT_ARGUMENTS_KEY => ['argument_name2' => ['argument' => 'value2']], ManagerInterface::COMPONENT_ATTRIBUTES_KEY => ['name' => 'attribute_name2'], ManagerInterface::CHILDREN_KEY => ['attribute_name21' => [ManagerInterface::COMPONENT_ARGUMENTS_KEY => ['argument_name21' => ['argument' => 'value21']], ManagerInterface::COMPONENT_ATTRIBUTES_KEY => ['name' => 'attribute_name21'], ManagerInterface::CHILDREN_KEY => []]]]]]];
 }
開發者ID:Doability,項目名稱:magento2dev,代碼行數:5,代碼來源:ManagerTest.php

示例3: serialize

 /**
  * overwrites the ArrayObject serialize function so that:
  * - $container->serialize() will serialize only the data collection but not the object instance
  * - serialize($container) will serialize the whole container instance
  *
  * @error 16308
  * @return string
  */
 public function serialize()
 {
     $debug = debug_backtrace();
     if (is_array($debug) && array_key_exists('line', $debug[0])) {
         return serialize($this->getArrayCopy());
     } else {
         $this->rewind();
         return parent::serialize();
     }
 }
開發者ID:xamiro-dev,項目名稱:xamiro,代碼行數:18,代碼來源:Container.php

示例4: serialize

 public function serialize()
 {
     return parent::serialize();
 }
開發者ID:badlamer,項目名稱:hhvm,代碼行數:4,代碼來源:bug45826.php

示例5: serialize

 /**
  * Hack to unset logger instance which cannot be serialized
  *
  * @return string
  */
 public function serialize()
 {
     $logger = $this->_logger;
     unset($this->_logger);
     $result = parent::serialize();
     $this->_logger = $logger;
     return $result;
 }
開發者ID:pradeep-wagento,項目名稱:magento2,代碼行數:13,代碼來源:Menu.php

示例6: serialize

 /**
  * Serializes key values data and root section name
  */
 public function serialize()
 {
     return serialize(array('data' => parent::serialize(), 'name' => $this->_name));
 }
開發者ID:Saltly,項目名稱:SourceBans,代碼行數:7,代碼來源:KeyValues.php

示例7: serialize

 /**
  * Serialization
  * { @internal Don't serialze the connection }}
  * 
  * @return array
  */
 public function serialize()
 {
     if (isset($this->_connection)) {
         $clone = clone $this;
         unset($clone->_connection);
         return $clone->serialize();
     }
     return parent::serialize();
 }
開發者ID:jasny,項目名稱:social,代碼行數:15,代碼來源:Collection.php

示例8: serialize

 /**
  * Serialize an ArrayObject
  * @return void The serialized representation of the <b>ArrayObject</b>.
  */
 public function serialize()
 {
     if (version_compare(PHP_VERSION, '5.3.0', '>=')) {
         return parent::serialize();
     }
     $serialized = serialize($this->getArrayCopy());
     $serialized = 'x:i:0;' . $serialized . ';m:a:0:{}';
     return $serialized;
 }
開發者ID:ehrlichandreas,項目名稱:ehrlichandreas1-util,代碼行數:13,代碼來源:Array.php

示例9: testTraitImpartsSerializableInterface

 /**
  * @covers ::serialize
  * @covers ::unserialize
  * @dataProvider basicDataProvider()
  */
 public function testTraitImpartsSerializableInterface(\ArrayObject $seedArray)
 {
     $serialString = $seedArray->serialize();
     $mock = $this->getArrayObjectDecorator($seedArray);
     $this->assertEquals($serialString, $mock->serialize());
     $mock2 = $this->getArrayObjectDecorator(new \ArrayObject());
     $mock2->unserialize($serialString);
     $this->assertEquals($serialString, $mock2->serialize());
 }
開發者ID:pbull,項目名稱:acquia-platform-cloud-data-model,代碼行數:14,代碼來源:ArrayObjectImplementationMethodsTest.php

示例10: getDirectoryHash

 /**
  * Calculates an hash value for all files with certain extensions.
  * This is used to test if the hash value changed, so if
  * it changed, the appserver can react accordingly.
  *
  * @param \SplFileInfo $directory The directory to watch
  *
  * @return string The hash value build out of the found filenames
  */
 protected function getDirectoryHash(\SplFileInfo $directory)
 {
     // prepare the array
     $files = new \ArrayObject();
     // prepare the array with the file extensions of the files used to build the hash
     $extensionsToWatch = $this->getExtensionsToWatch();
     // clear the cache
     clearstatcache();
     // add all files with the found extensions to the array
     foreach (glob($directory . '/*.{' . implode(',', $extensionsToWatch) . '}', GLOB_BRACE) as $filename) {
         $files->append($filename);
     }
     // calculate and return the hash value for the array
     return md5($files->serialize());
 }
開發者ID:appserver-io,項目名稱:appserver,代碼行數:24,代碼來源:AbstractScanner.php

示例11: ArrayObject

<?php

$dados = ['salmão', 'tilápia', 'sardinha', 'badejo', 'pescada', 'dourado', 'corvina', 'cavala', 'bagre'];
$objarray = new ArrayObject($dados);
$objarray->append('bacalhau');
print 'Posição 2: ' . $objarray->offsetGet(2) . '<br>' . PHP_EOL;
$objarray->offsetSet(2, 'linguado');
print 'Posição 2: ' . $objarray->offsetGet(2) . '<br>' . PHP_EOL;
$objarray->offsetUnset(4);
if ($objarray->offsetExists(10)) {
    echo 'Posição 10 encontrada' . '<br>' . PHP_EOL;
} else {
    echo 'Posição 10 não encontrada' . '<br>' . PHP_EOL;
}
print 'Total: ' . $objarray->count();
$objarray[] = 'atum';
$objarray->natsort();
print '<br>' . PHP_EOL;
foreach ($objarray as $item) {
    print 'Item: ' . $item . '<br>' . PHP_EOL;
}
print $objarray->serialize();
開發者ID:jmoliver,項目名稱:php-programando-com-orientacao-a-objeto,代碼行數:22,代碼來源:spl_array.php

示例12: getDirectoryHash

 /**
  * Calculates an hash value for all files with certain extensions.
  * This is used to test if the hash value changed, so if
  * it changed, the appserver can react accordingly.
  *
  * @param \SplFileInfo $directory         The directory to watch
  * @param array        $extensionsToWatch The extensions we have to look for
  *
  * @return string The hash value build out of the found filenames
  */
 protected function getDirectoryHash(\SplFileInfo $directory, array $extensionsToWatch)
 {
     // prepare the array
     $files = new \ArrayObject();
     // add all files with the found extensions to the array
     foreach (new \DirectoryIterator($directory) as $fileInfo) {
         if ($fileInfo->isFile() && in_array($fileInfo->getExtension(), $extensionsToWatch)) {
             $files->append($fileInfo->getFilename());
         }
     }
     // calculate and return the hash value for the array
     return md5($files->serialize());
 }
開發者ID:n3rds-eddie,項目名稱:TechDivision_ApplicationServer,代碼行數:23,代碼來源:AbstractScanner.php

示例13: ArrayObject

<?php

$a = new ArrayObject(array(1, 2, 3));
$b = $a->serialize();
$c = new ArrayObject();
$d = $c->unserialize($b);
var_dump($a);
var_dump($c);
var_dump($d);
var_dump($a == $c);
開發者ID:badlamer,項目名稱:hhvm,代碼行數:10,代碼來源:unserialize.php

示例14: serialize

 /**
  * Implementation of ArrayAccess::serialize()
  *
  * Returns a serialized ArrayObject.
  *
  * @return string The serialized representation of the ArrayObject.
  */
 public function serialize()
 {
     return $this->arrayObject->serialize();
 }
開發者ID:pbull,項目名稱:acquia-platform-cloud-data-model,代碼行數:11,代碼來源:ArrayObjectImplementationMethods.php


注:本文中的ArrayObject::serialize方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。