Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit bc8656c

Browse files
Merge branch '3.4' into 4.2
* 3.4: Add missing `@internal` annotations Disable Twig in the profiler menu when Twig is not used Mark some/most implementations of Serializable as `@internal` [Config] ensure moving away from Serializable wont break cache:clear [VarDumper] dont implement Serializable in Stub [Config] fix compat with wrapping autoloaders
2 parents 50a0bda + 823a95d commit bc8656c

File tree

17 files changed

+76
-25
lines changed

17 files changed

+76
-25
lines changed

src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/twig.html.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
{% endblock %}
3232

3333
{% block menu %}
34-
<span class="label">
34+
<span class="label {{ 0 == collector.templateCount ? 'disabled' }}">
3535
<span class="icon">{{ include('@WebProfiler/Icon/twig.svg') }}</span>
3636
<strong>Twig</strong>
3737
</span>

src/Symfony/Component/Config/Resource/ClassExistenceResource.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ public function isFresh($timestamp)
9595
}
9696

9797
/**
98-
* {@inheritdoc}
98+
* @internal
9999
*/
100100
public function serialize()
101101
{
@@ -107,7 +107,7 @@ public function serialize()
107107
}
108108

109109
/**
110-
* {@inheritdoc}
110+
* @internal
111111
*/
112112
public function unserialize($serialized)
113113
{
@@ -116,8 +116,10 @@ public function unserialize($serialized)
116116

117117
/**
118118
* @throws \ReflectionException When $class is not found and is required
119+
*
120+
* @internal
119121
*/
120-
private static function throwOnRequiredClass($class)
122+
public static function throwOnRequiredClass($class)
121123
{
122124
if (self::$autoloadedClass === $class) {
123125
return;

src/Symfony/Component/Config/Resource/ComposerResource.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,17 @@ public function isFresh($timestamp)
5151
return self::$runtimeVendors === $this->vendors;
5252
}
5353

54+
/**
55+
* @internal
56+
*/
5457
public function serialize()
5558
{
5659
return serialize($this->vendors);
5760
}
5861

62+
/**
63+
* @internal
64+
*/
5965
public function unserialize($serialized)
6066
{
6167
$this->vendors = unserialize($serialized);

src/Symfony/Component/Config/Resource/DirectoryResource.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,11 +104,17 @@ public function isFresh($timestamp)
104104
return true;
105105
}
106106

107+
/**
108+
* @internal
109+
*/
107110
public function serialize()
108111
{
109112
return serialize([$this->resource, $this->pattern]);
110113
}
111114

115+
/**
116+
* @internal
117+
*/
112118
public function unserialize($serialized)
113119
{
114120
list($this->resource, $this->pattern) = unserialize($serialized);

src/Symfony/Component/Config/Resource/FileExistenceResource.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,15 @@ public function isFresh($timestamp)
5959
}
6060

6161
/**
62-
* {@inheritdoc}
62+
* @internal
6363
*/
6464
public function serialize()
6565
{
6666
return serialize([$this->resource, $this->exists]);
6767
}
6868

6969
/**
70-
* {@inheritdoc}
70+
* @internal
7171
*/
7272
public function unserialize($serialized)
7373
{

src/Symfony/Component/Config/Resource/FileResource.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,17 @@ public function isFresh($timestamp)
6363
return false !== ($filemtime = @filemtime($this->resource)) && $filemtime <= $timestamp;
6464
}
6565

66+
/**
67+
* @internal
68+
*/
6669
public function serialize()
6770
{
6871
return serialize($this->resource);
6972
}
7073

74+
/**
75+
* @internal
76+
*/
7177
public function unserialize($serialized)
7278
{
7379
$this->resource = unserialize($serialized);

src/Symfony/Component/Config/Resource/GlobResource.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,9 @@ public function isFresh($timestamp)
7777
return $this->hash === $hash;
7878
}
7979

80+
/**
81+
* @internal
82+
*/
8083
public function serialize()
8184
{
8285
if (null === $this->hash) {
@@ -86,6 +89,9 @@ public function serialize()
8689
return serialize([$this->prefix, $this->pattern, $this->recursive, $this->hash, $this->forExclusion, $this->excludedPrefixes]);
8790
}
8891

92+
/**
93+
* @internal
94+
*/
8995
public function unserialize($serialized)
9096
{
9197
list($this->prefix, $this->pattern, $this->recursive, $this->hash, $this->forExclusion, $this->excludedPrefixes) = unserialize($serialized) + [4 => false, []];

src/Symfony/Component/Config/Resource/ReflectionClassResource.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ public function __toString()
5858
return 'reflection.'.$this->className;
5959
}
6060

61+
/**
62+
* @internal
63+
*/
6164
public function serialize()
6265
{
6366
if (null === $this->hash) {
@@ -68,6 +71,9 @@ public function serialize()
6871
return serialize([$this->files, $this->className, $this->hash]);
6972
}
7073

74+
/**
75+
* @internal
76+
*/
7177
public function unserialize($serialized)
7278
{
7379
list($this->files, $this->className, $this->hash) = unserialize($serialized);

src/Symfony/Component/Config/ResourceCheckerConfigCache.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,18 +156,19 @@ private function safelyUnserialize($file)
156156
{
157157
$e = null;
158158
$meta = false;
159+
$content = file_get_contents($file);
159160
$signalingException = new \UnexpectedValueException();
160161
$prevUnserializeHandler = ini_set('unserialize_callback_func', '');
161162
$prevErrorHandler = set_error_handler(function ($type, $msg, $file, $line, $context = []) use (&$prevErrorHandler, $signalingException) {
162-
if (E_WARNING === $type && 'Class __PHP_Incomplete_Class has no unserializer' === $msg) {
163+
if (__FILE__ === $file) {
163164
throw $signalingException;
164165
}
165166

166167
return $prevErrorHandler ? $prevErrorHandler($type, $msg, $file, $line, $context) : false;
167168
});
168169

169170
try {
170-
$meta = unserialize(file_get_contents($file));
171+
$meta = unserialize($content);
171172
} catch (\Throwable $e) {
172173
if ($e !== $signalingException) {
173174
throw $e;

src/Symfony/Component/DependencyInjection/Config/ContainerParametersResource.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,15 @@ public function __toString()
3939
}
4040

4141
/**
42-
* {@inheritdoc}
42+
* @internal
4343
*/
4444
public function serialize()
4545
{
4646
return serialize($this->parameters);
4747
}
4848

4949
/**
50-
* {@inheritdoc}
50+
* @internal
5151
*/
5252
public function unserialize($serialized)
5353
{

src/Symfony/Component/Form/Extension/DataCollector/FormDataCollector.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,9 @@ public function getData()
229229
return $this->data;
230230
}
231231

232+
/**
233+
* @internal
234+
*/
232235
public function serialize()
233236
{
234237
foreach ($this->data['forms_by_hash'] as &$form) {

src/Symfony/Component/Form/FormError.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,7 @@ public function getOrigin()
135135
}
136136

137137
/**
138-
* Serializes this error.
139-
*
140-
* @return string The serialized error
138+
* @internal
141139
*/
142140
public function serialize()
143141
{
@@ -151,9 +149,7 @@ public function serialize()
151149
}
152150

153151
/**
154-
* Unserializes a serialized error.
155-
*
156-
* @param string $serialized The serialized error
152+
* @internal
157153
*/
158154
public function unserialize($serialized)
159155
{

src/Symfony/Component/HttpKernel/DataCollector/DataCollector.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ abstract class DataCollector implements DataCollectorInterface, \Serializable
3434
*/
3535
private $cloner;
3636

37+
/**
38+
* @internal
39+
*/
3740
public function serialize()
3841
{
3942
$trace = debug_backtrace(DEBUG_BACKTRACE_PROVIDE_OBJECT, 2);
@@ -42,6 +45,9 @@ public function serialize()
4245
return $isCalledFromOverridingMethod ? $this->data : serialize($this->data);
4346
}
4447

48+
/**
49+
* @internal
50+
*/
4551
public function unserialize($data)
4652
{
4753
$this->data = \is_array($data) ? $data : unserialize($data);

src/Symfony/Component/HttpKernel/DataCollector/DumpDataCollector.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,9 @@ public function reset()
133133
$this->clonesIndex = 0;
134134
}
135135

136+
/**
137+
* @internal
138+
*/
136139
public function serialize()
137140
{
138141
if ($this->clonesCount !== $this->clonesIndex) {
@@ -149,9 +152,12 @@ public function serialize()
149152
return $ser;
150153
}
151154

155+
/**
156+
* @internal
157+
*/
152158
public function unserialize($data)
153159
{
154-
parent::unserialize($data);
160+
$this->data = unserialize($data);
155161
$charset = array_pop($this->data);
156162
$fileLinkFormat = array_pop($this->data);
157163
$this->dataCount = \count($this->data);

src/Symfony/Component/HttpKernel/Debug/FileLinkFormatter.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,17 @@ public function format($file, $line)
6161
return false;
6262
}
6363

64+
/**
65+
* @internal
66+
*/
6467
public function serialize()
6568
{
6669
return serialize($this->getFileLinkFormat());
6770
}
6871

72+
/**
73+
* @internal
74+
*/
6975
public function unserialize($serialized)
7076
{
7177
$this->fileLinkFormat = unserialize($serialized, ['allowed_classes' => false]);

src/Symfony/Component/Validator/Constraint.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -284,9 +284,7 @@ public function getTargets()
284284
*
285285
* @return array The properties to serialize
286286
*
287-
* @internal This method may be replaced by an implementation of
288-
* {@link \Serializable} in the future. Please don't use or
289-
* overwrite it.
287+
* @internal
290288
*/
291289
public function __sleep()
292290
{

src/Symfony/Component/VarDumper/Cloner/Stub.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*
1717
* @author Nicolas Grekas <[email protected]>
1818
*/
19-
class Stub implements \Serializable
19+
class Stub
2020
{
2121
const TYPE_REF = 1;
2222
const TYPE_STRING = 2;
@@ -42,16 +42,19 @@ class Stub implements \Serializable
4242
/**
4343
* @internal
4444
*/
45-
public function serialize()
45+
public function __sleep()
4646
{
47-
return \serialize([$this->class, $this->position, $this->cut, $this->type, $this->value, $this->handle, $this->refCount, $this->attr]);
47+
$this->serialized = [$this->class, $this->position, $this->cut, $this->type, $this->value, $this->handle, $this->refCount, $this->attr];
48+
49+
return ['serialized'];
4850
}
4951

5052
/**
5153
* @internal
5254
*/
53-
public function unserialize($serialized)
55+
public function __wakeup()
5456
{
55-
list($this->class, $this->position, $this->cut, $this->type, $this->value, $this->handle, $this->refCount, $this->attr) = \unserialize($serialized);
57+
list($this->class, $this->position, $this->cut, $this->type, $this->value, $this->handle, $this->refCount, $this->attr) = $this->serialized;
58+
unset($this->serialized);
5659
}
5760
}

0 commit comments

Comments
 (0)