Skip to content

Commit 2b01d59

Browse files
committed
Merge branch '2.8' into 3.4
* 2.8: [Form] Fix PHPDoc for FormConfigBuilder $dataClass argument [Security] Update user phpdoc on tokens [WebProfilerBundle] Fixed icon alignment issue using Bootstrap 4.1.2 suppress side effects in 'get' or 'has' methods of NamespacedAttributeBag [HttpFoundation] reset callback on StreamedResponse when setNotModified() is called [HttpFoundation] Fixed phpdoc for get method of HeaderBag fix typo in ContainerBuilder docblock
2 parents 28abb38 + 13a4003 commit 2b01d59

File tree

11 files changed

+84
-22
lines changed

11 files changed

+84
-22
lines changed

src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar.css.twig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,7 @@ div.sf-toolbar .sf-toolbar-block a:hover {
292292
border-width: 0;
293293
position: relative;
294294
top: 8px;
295+
vertical-align: baseline;
295296
}
296297

297298
.sf-toolbar-block .sf-toolbar-icon img + span,

src/Symfony/Component/DependencyInjection/ContainerBuilder.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -637,10 +637,10 @@ private function doGet($id, $invalidBehavior = ContainerInterface::EXCEPTION_ON_
637637
* the parameters passed to the container constructor to have precedence
638638
* over the loaded ones.
639639
*
640-
* $container = new ContainerBuilder(array('foo' => 'bar'));
640+
* $container = new ContainerBuilder(new ParameterBag(array('foo' => 'bar')));
641641
* $loader = new LoaderXXX($container);
642642
* $loader->load('resource_name');
643-
* $container->register('foo', new stdClass());
643+
* $container->register('foo', 'stdClass');
644644
*
645645
* In the above example, even if the loaded resource defines a foo
646646
* parameter, the value will still be 'bar' as defined in the ContainerBuilder

src/Symfony/Component/Form/FormConfigBuilder.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ class FormConfigBuilder implements FormConfigBuilderInterface
138138
private $data;
139139

140140
/**
141-
* @var string
141+
* @var string|null
142142
*/
143143
private $dataClass;
144144

@@ -181,7 +181,7 @@ class FormConfigBuilder implements FormConfigBuilderInterface
181181
* Creates an empty form configuration.
182182
*
183183
* @param string|int $name The form name
184-
* @param string $dataClass The class of the form's data
184+
* @param string|null $dataClass The class of the form's data
185185
* @param EventDispatcherInterface $dispatcher The event dispatcher
186186
* @param array $options The form options
187187
*

src/Symfony/Component/HttpFoundation/HeaderBag.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,11 @@ public function add(array $headers)
101101
/**
102102
* Returns a header value by name.
103103
*
104-
* @param string $key The header name
105-
* @param string|string[] $default The default value
106-
* @param bool $first Whether to return the first value or all header values
104+
* @param string $key The header name
105+
* @param string|string[]|null $default The default value
106+
* @param bool $first Whether to return the first value or all header values
107107
*
108-
* @return string|string[] The first header value or default value if $first is true, an array of values otherwise
108+
* @return string|string[]|null The first header value or default value if $first is true, an array of values otherwise
109109
*/
110110
public function get($key, $default = null, $first = true)
111111
{

src/Symfony/Component/HttpFoundation/Session/Attribute/NamespacedAttributeBag.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,13 @@ protected function &resolveAttributePath($name, $writeContext = false)
124124

125125
foreach ($parts as $part) {
126126
if (null !== $array && !array_key_exists($part, $array)) {
127-
$array[$part] = $writeContext ? array() : null;
127+
if (!$writeContext) {
128+
$null = null;
129+
130+
return $null;
131+
}
132+
133+
$array[$part] = array();
128134
}
129135

130136
$array = &$array[$part];

src/Symfony/Component/HttpFoundation/StreamedResponse.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,4 +141,16 @@ public function getContent()
141141
{
142142
return false;
143143
}
144+
145+
/**
146+
* {@inheritdoc}
147+
*
148+
* @return $this
149+
*/
150+
public function setNotModified()
151+
{
152+
$this->setCallback(function () {});
153+
154+
return parent::setNotModified();
155+
}
144156
}

src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ public function testMustRevalidateWithProxyRevalidateCacheControlHeader()
126126

127127
public function testSetNotModified()
128128
{
129-
$response = new Response();
129+
$response = new Response('foo');
130130
$modified = $response->setNotModified();
131131
$this->assertObjectHasAttribute('headers', $modified);
132132
$this->assertObjectHasAttribute('content', $modified);
@@ -135,6 +135,11 @@ public function testSetNotModified()
135135
$this->assertObjectHasAttribute('statusText', $modified);
136136
$this->assertObjectHasAttribute('charset', $modified);
137137
$this->assertEquals(304, $modified->getStatusCode());
138+
139+
ob_start();
140+
$modified->sendContent();
141+
$string = ob_get_clean();
142+
$this->assertEmpty($string);
138143
}
139144

140145
public function testIsSuccessful()

src/Symfony/Component/HttpFoundation/Tests/Session/Attribute/NamespacedAttributeBagTest.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,17 @@ public function testHas($key, $value, $exists)
8282
$this->assertEquals($exists, $this->bag->has($key));
8383
}
8484

85+
/**
86+
* @dataProvider attributesProvider
87+
*/
88+
public function testHasNoSideEffect($key, $value, $expected)
89+
{
90+
$expected = json_encode($this->bag->all());
91+
$this->bag->has($key);
92+
93+
$this->assertEquals($expected, json_encode($this->bag->all()));
94+
}
95+
8596
/**
8697
* @dataProvider attributesProvider
8798
*/
@@ -96,6 +107,17 @@ public function testGetDefaults()
96107
$this->assertEquals('default', $this->bag->get('user2.login', 'default'));
97108
}
98109

110+
/**
111+
* @dataProvider attributesProvider
112+
*/
113+
public function testGetNoSideEffect($key, $value, $expected)
114+
{
115+
$expected = json_encode($this->bag->all());
116+
$this->bag->get($key);
117+
118+
$this->assertEquals($expected, json_encode($this->bag->all()));
119+
}
120+
99121
/**
100122
* @dataProvider attributesProvider
101123
*/

src/Symfony/Component/HttpFoundation/Tests/StreamedResponseTest.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,4 +123,22 @@ public function testReturnThis()
123123
$this->assertInstanceOf('Symfony\Component\HttpFoundation\StreamedResponse', $response->sendHeaders());
124124
$this->assertInstanceOf('Symfony\Component\HttpFoundation\StreamedResponse', $response->sendHeaders());
125125
}
126+
127+
public function testSetNotModified()
128+
{
129+
$response = new StreamedResponse(function () { echo 'foo'; });
130+
$modified = $response->setNotModified();
131+
$this->assertObjectHasAttribute('headers', $modified);
132+
$this->assertObjectHasAttribute('content', $modified);
133+
$this->assertObjectHasAttribute('version', $modified);
134+
$this->assertObjectHasAttribute('statusCode', $modified);
135+
$this->assertObjectHasAttribute('statusText', $modified);
136+
$this->assertObjectHasAttribute('charset', $modified);
137+
$this->assertEquals(304, $modified->getStatusCode());
138+
139+
ob_start();
140+
$modified->sendContent();
141+
$string = ob_get_clean();
142+
$this->assertEmpty($string);
143+
}
126144
}

src/Symfony/Component/Security/Core/Authentication/Token/AbstractToken.php

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -77,14 +77,7 @@ public function getUser()
7777
}
7878

7979
/**
80-
* Sets the user in the token.
81-
*
82-
* The user can be a UserInterface instance, or an object implementing
83-
* a __toString method or the username as a regular string.
84-
*
85-
* @param string|object $user The user
86-
*
87-
* @throws \InvalidArgumentException
80+
* {@inheritdoc}
8881
*/
8982
public function setUser($user)
9083
{

0 commit comments

Comments
 (0)