Mercurial > hg > isophonics-drupal-site
comparison vendor/symfony/http-kernel/DataCollector/DataCollector.php @ 17:129ea1e6d783
Update, including to Drupal core 8.6.10
author | Chris Cannam |
---|---|
date | Thu, 28 Feb 2019 13:21:36 +0000 |
parents | 1fec387a4317 |
children | af1871eacc83 |
comparison
equal
deleted
inserted
replaced
16:c2387f117808 | 17:129ea1e6d783 |
---|---|
26 * @author Fabien Potencier <fabien@symfony.com> | 26 * @author Fabien Potencier <fabien@symfony.com> |
27 * @author Bernhard Schussek <bschussek@symfony.com> | 27 * @author Bernhard Schussek <bschussek@symfony.com> |
28 */ | 28 */ |
29 abstract class DataCollector implements DataCollectorInterface, \Serializable | 29 abstract class DataCollector implements DataCollectorInterface, \Serializable |
30 { | 30 { |
31 protected $data = array(); | 31 protected $data = []; |
32 | 32 |
33 /** | 33 /** |
34 * @var ValueExporter | 34 * @var ValueExporter |
35 */ | 35 */ |
36 private $valueExporter; | 36 private $valueExporter; |
38 /** | 38 /** |
39 * @var ClonerInterface | 39 * @var ClonerInterface |
40 */ | 40 */ |
41 private $cloner; | 41 private $cloner; |
42 | 42 |
43 /** | |
44 * @internal | |
45 */ | |
43 public function serialize() | 46 public function serialize() |
44 { | 47 { |
45 return serialize($this->data); | 48 $trace = debug_backtrace(DEBUG_BACKTRACE_PROVIDE_OBJECT, 2); |
49 $isCalledFromOverridingMethod = isset($trace[1]['function'], $trace[1]['object']) && 'serialize' === $trace[1]['function'] && $this === $trace[1]['object']; | |
50 | |
51 return $isCalledFromOverridingMethod ? $this->data : serialize($this->data); | |
46 } | 52 } |
47 | 53 |
54 /** | |
55 * @internal | |
56 */ | |
48 public function unserialize($data) | 57 public function unserialize($data) |
49 { | 58 { |
50 $this->data = unserialize($data); | 59 $this->data = \is_array($data) ? $data : unserialize($data); |
51 } | 60 } |
52 | 61 |
53 /** | 62 /** |
54 * Converts the variable into a serializable Data instance. | 63 * Converts the variable into a serializable Data instance. |
55 * | 64 * |
109 /** | 118 /** |
110 * @return callable[] The casters to add to the cloner | 119 * @return callable[] The casters to add to the cloner |
111 */ | 120 */ |
112 protected function getCasters() | 121 protected function getCasters() |
113 { | 122 { |
114 return array( | 123 return [ |
115 '*' => function ($v, array $a, Stub $s, $isNested) { | 124 '*' => function ($v, array $a, Stub $s, $isNested) { |
116 if (!$v instanceof Stub) { | 125 if (!$v instanceof Stub) { |
117 foreach ($a as $k => $v) { | 126 foreach ($a as $k => $v) { |
118 if (is_object($v) && !$v instanceof \DateTimeInterface && !$v instanceof Stub) { | 127 if (\is_object($v) && !$v instanceof \DateTimeInterface && !$v instanceof Stub) { |
119 $a[$k] = new CutStub($v); | 128 $a[$k] = new CutStub($v); |
120 } | 129 } |
121 } | 130 } |
122 } | 131 } |
123 | 132 |
124 return $a; | 133 return $a; |
125 }, | 134 }, |
126 ); | 135 ]; |
127 } | 136 } |
128 } | 137 } |