[ Index ] |
PHP Cross Reference of phpBB-3.1.12-deutsch |
[Summary view] [Print] [Text view]
1 <?php 2 3 /* 4 * This file is part of the Symfony package. 5 * 6 * (c) Fabien Potencier <fabien@symfony.com> 7 * 8 * For the full copyright and license information, please view the LICENSE 9 * file that was distributed with this source code. 10 */ 11 12 namespace Symfony\Component\HttpKernel\DataCollector; 13 14 /** 15 * DataCollector. 16 * 17 * Children of this class must store the collected data in the data property. 18 * 19 * @author Fabien Potencier <fabien@symfony.com> 20 */ 21 abstract class DataCollector implements DataCollectorInterface, \Serializable 22 { 23 protected $data; 24 25 public function serialize() 26 { 27 return serialize($this->data); 28 } 29 30 public function unserialize($data) 31 { 32 $this->data = unserialize($data); 33 } 34 35 /** 36 * Converts a PHP variable to a string. 37 * 38 * @param mixed $var A PHP variable 39 * 40 * @return string The string representation of the variable 41 */ 42 protected function varToString($var) 43 { 44 if (is_object($var)) { 45 return sprintf('Object(%s)', get_class($var)); 46 } 47 48 if ($var instanceof \__PHP_Incomplete_Class) { 49 return sprintf('__PHP_Incomplete_Class(%s)', $this->getClassNameFromIncomplete($var)); 50 } 51 52 if (is_array($var)) { 53 $a = array(); 54 foreach ($var as $k => $v) { 55 $a[] = sprintf('%s => %s', $k, $this->varToString($v)); 56 } 57 58 return sprintf('Array(%s)', implode(', ', $a)); 59 } 60 61 if (is_resource($var)) { 62 return sprintf('Resource(%s#%d)', get_resource_type($var), $var); 63 } 64 65 if (null === $var) { 66 return 'null'; 67 } 68 69 if (false === $var) { 70 return 'false'; 71 } 72 73 if (true === $var) { 74 return 'true'; 75 } 76 77 return (string) $var; 78 } 79 80 private function getClassNameFromIncomplete(\__PHP_Incomplete_Class $var) 81 { 82 $array = new \ArrayObject($var); 83 84 return $array['__PHP_Incomplete_Class_Name']; 85 } 86 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Thu Jan 11 00:25:41 2018 | Cross-referenced by PHPXref 0.7.1 |