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

Skip to content

Commit 3417a15

Browse files
Merge branch '4.2'
* 4.2: 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 [Messenger] fixed RabbitMQ arguments not passed as integer values
2 parents 0ac32bc + bc8656c commit 3417a15

File tree

19 files changed

+153
-29
lines changed

19 files changed

+153
-29
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
@@ -136,6 +136,9 @@ public function reset()
136136
$this->clonesIndex = 0;
137137
}
138138

139+
/**
140+
* @internal
141+
*/
139142
public function serialize()
140143
{
141144
if ($this->clonesCount !== $this->clonesIndex) {
@@ -152,9 +155,12 @@ public function serialize()
152155
return $ser;
153156
}
154157

158+
/**
159+
* @internal
160+
*/
155161
public function unserialize($data)
156162
{
157-
parent::unserialize($data);
163+
$this->data = unserialize($data);
158164
$charset = array_pop($this->data);
159165
$fileLinkFormat = array_pop($this->data);
160166
$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/Messenger/Tests/Transport/AmqpExt/ConnectionTest.php

Lines changed: 47 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Component\Messenger\Tests\Transport\AmqpExt;
1313

1414
use PHPUnit\Framework\TestCase;
15+
use Symfony\Component\Messenger\Exception\InvalidArgumentException;
1516
use Symfony\Component\Messenger\Transport\AmqpExt\AmqpFactory;
1617
use Symfony\Component\Messenger\Transport\AmqpExt\Connection;
1718

@@ -96,17 +97,30 @@ public function testSetsParametersOnTheQueueAndExchange()
9697

9798
$amqpQueue->expects($this->once())->method('setArguments')->with([
9899
'x-dead-letter-exchange' => 'dead-exchange',
99-
'x-message-ttl' => '1200',
100+
'x-delay' => 100,
101+
'x-expires' => 150,
102+
'x-max-length' => 200,
103+
'x-max-length-bytes' => 300,
104+
'x-max-priority' => 4,
105+
'x-message-ttl' => 100,
100106
]);
101107

102108
$amqpExchange->expects($this->once())->method('setArguments')->with([
103109
'alternate-exchange' => 'alternate',
104110
]);
105111

106-
$connection = Connection::fromDsn('amqp://localhost/%2f/messages?queue[arguments][x-dead-letter-exchange]=dead-exchange', [
112+
$dsn = 'amqp://localhost/%2f/messages?'.
113+
'queue[arguments][x-dead-letter-exchange]=dead-exchange&'.
114+
'queue[arguments][x-message-ttl]=100&'.
115+
'queue[arguments][x-delay]=100&'.
116+
'queue[arguments][x-expires]=150&'
117+
;
118+
$connection = Connection::fromDsn($dsn, [
107119
'queue' => [
108120
'arguments' => [
109-
'x-message-ttl' => '1200',
121+
'x-max-length' => '200',
122+
'x-max-length-bytes' => '300',
123+
'x-max-priority' => '4',
110124
],
111125
],
112126
'exchange' => [
@@ -118,6 +132,36 @@ public function testSetsParametersOnTheQueueAndExchange()
118132
$connection->publish('body');
119133
}
120134

135+
public function invalidQueueArgumentsDataProvider(): iterable
136+
{
137+
$baseDsn = 'amqp://localhost/%2f/messages';
138+
yield [$baseDsn.'?queue[arguments][x-delay]=not-a-number', []];
139+
yield [$baseDsn.'?queue[arguments][x-expires]=not-a-number', []];
140+
yield [$baseDsn.'?queue[arguments][x-max-length]=not-a-number', []];
141+
yield [$baseDsn.'?queue[arguments][x-max-length-bytes]=not-a-number', []];
142+
yield [$baseDsn.'?queue[arguments][x-max-priority]=not-a-number', []];
143+
yield [$baseDsn.'?queue[arguments][x-message-ttl]=not-a-number', []];
144+
145+
// Ensure the exception is thrown when the arguments are passed via the array options
146+
yield [$baseDsn, ['queue' => ['arguments' => ['x-delay' => 'not-a-number']]]];
147+
yield [$baseDsn, ['queue' => ['arguments' => ['x-expires' => 'not-a-number']]]];
148+
yield [$baseDsn, ['queue' => ['arguments' => ['x-max-length' => 'not-a-number']]]];
149+
yield [$baseDsn, ['queue' => ['arguments' => ['x-max-length-bytes' => 'not-a-number']]]];
150+
yield [$baseDsn, ['queue' => ['arguments' => ['x-max-priority' => 'not-a-number']]]];
151+
yield [$baseDsn, ['queue' => ['arguments' => ['x-message-ttl' => 'not-a-number']]]];
152+
}
153+
154+
/**
155+
* @dataProvider invalidQueueArgumentsDataProvider
156+
*/
157+
public function testFromDsnWithInvalidValueOnQueueArguments(string $dsn, array $options)
158+
{
159+
$this->expectException(InvalidArgumentException::class);
160+
$this->expectExceptionMessage('Integer expected for queue argument');
161+
162+
Connection::fromDsn($dsn, $options);
163+
}
164+
121165
public function testItUsesANormalConnectionByDefault()
122166
{
123167
$factory = new TestAmqpFactory(

0 commit comments

Comments
 (0)