8000 Merge branch '5.0' · symfony/symfony@773bebc · GitHub
[go: up one dir, main page]

Skip to content

Commit 773bebc

Browse files
Merge branch '5.0'
* 5.0: [VarDumper] fix for change in PHP 7.4.6 (bis) [VarExporter] fix for change in PHP 7.4.6 [BrowserKit] Allow Referer set by history to be overridden (3.4)
2 parents cf04f1e + 7e376fd commit 773bebc

File tree

9 files changed

+25
-17
lines changed

9 files changed

+25
-17
lines changed

src/Symfony/Component/BrowserKit/AbstractBrowser.php

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,6 @@
2222
*
2323
* To make the actual request, you need to implement the doRequest() method.
2424
*
25-
* HttpBrowser is an implementation that uses the HttpClient component
26-
* to make real HTTP requests.
27-
*
2825
* If you want to be able to run requests in their own process (insulated flag),
2926
* you need to also implement the getScript() method.
3027
*
@@ -51,9 +48,7 @@ abstract class AbstractBrowser
5148
private $isMainRequest = true;
5249

5350
/**
54-
* @param array $server The server parameters (equivalent of $_SERVER)
55-
* @param History $history A History instance to store the browser history
56-
* @param CookieJar $cookieJar A CookieJar instance to store the cookies
51+
* @param array $server The server parameters (equivalent of $_SERVER)
5752
*/
5853
public function __construct(array $server = [], History $history = null, CookieJar $cookieJar = null)
5954
{
@@ -297,7 +292,6 @@ public function clickLink(string $linkText): Crawler
297292
/**
298293
* Submits a form.
299294
*
300-
* @param Form $form A Form instance
301295
* @param array $values An array of form field values
302296
* @param array $serverParameters An array of server parameters
303297
*
@@ -366,7 +360,7 @@ public function request(string $method, string $uri, array $parameters = [], arr
366360
$uri = preg_replace('{^'.parse_url($uri, PHP_URL_SCHEME).'}', $server['HTTPS'] ? 'https' : 'http', $uri);
367361
}
368362

369-
if (!$this->history->isEmpty()) {
363+
if (!isset($server['HTTP_REFERER']) && !$this->history->isEmpty()) {
370364
$server['HTTP_REFERER'] = $this->history->current()->getUri();
371365
}
372366

@@ -481,8 +475,6 @@ protected function getScript($request)
481475
/**
482476
* Filters the BrowserKit request to the origin one.
483477
*
484-
* @param Request $request The BrowserKit Request to filter
485-
*
486478
* @return object An origin request instance
487479
*/
488480
protected function filterRequest(Request $request)
@@ -685,8 +677,7 @@ protected function getAbsoluteUri(string $uri)
685677
/**
686678
* Makes a request from a Request object directly.
687679
*
688-
* @param Request $request A Request instance
689-
* @param bool $changeHistory Whether to update the history or not (only used internally for back(), forward(), and reload())
680+
* @param bool $changeHistory Whether to update the history or not (only used internally for back(), forward(), and reload())
690681
*
691682
* @return Crawler
692683
*/
@@ -695,7 +686,7 @@ protected function requestFromRequest(Request $request, $changeHistory = true)
695686
return $this->request($request->getMethod(), $request->getUri(), $request->getParameters(), $request->getFiles(), $request->getServer(), $request->getContent(), $changeHistory);
696687
}
697688

698-
private function updateServerFromUri($server, $uri)
689+
private function updateServerFromUri(array $server, string $uri): array
699690
{
700691
$server['HTTP_HOST'] = $this->extractHost($uri);
701692
$scheme = parse_url($uri, PHP_URL_SCHEME);
@@ -705,7 +696,7 @@ private function updateServerFromUri($server, $uri)
705696
return $server;
706697
}
707698

708-
private function extractHost($uri)
699+
private function extractHost(string $uri): ?string
709700
{
710701
$host = parse_url($uri, PHP_URL_HOST);
711702

src/Symfony/Component/BrowserKit/Tests/AbstractBrowserTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,15 @@ public function testRequestReferer()
215215
$this->assertEquals('http://www.example.com/foo/fooba F438 r', $server['HTTP_REFERER'], '->request() sets the referer');
216216
}
217217

218+
public function testRequestRefererCanBeOverridden()
219+
{
220+
$client = new TestClient();
221+
$client->request('GET', 'http://www.example.com/foo/foobar');
222+
$client->request('GET', 'bar', [], [], ['HTTP_REFERER' => 'xyz']);
223+
$server = $client->getRequest()->getServer();
224+
$this->assertEquals('xyz', $server['HTTP_REFERER'], '->request() allows referer to be overridden');
225+
}
226+
218227
public function testRequestHistory()
219228
{
220229
$client = $this->getBrowser();

src/Symfony/Component/VarDumper/Caster/SplCaster.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ public static function castObjectStorage(\SplObjectStorage $c, array $a, Stub $s
175175
{
176176
$storage = [];
177177
unset($a[Caster::PREFIX_DYNAMIC."\0gcdata"]); // Don't hit https://bugs.php.net/65967
178+
unset($a["\0SplObjectStorage\0storage"]);
178179

179180
$clone = clone $c;
180181
foreach ($clone as $obj) {

src/Symfony/Component/VarExporter/Tests/Fixtures/array-iterator.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
123,
1515
],
1616
[],
17+
null,
1718
],
1819
]
1920
);

src/Symfony/Component/VarExporter/Tests/Fixtures/array-object-custom.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
[
1717
"\0".'Symfony\\Component\\VarExporter\\Tests\\MyArrayObject'."\0".'unused' => 123,
1818
],
19+
null,
1920
],
2021
]
2122
);

src/Symfony/Component/VarExporter/Tests/Fixtures/array-object.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,13 @@
1818
[
1919
'foo' => $o[1],
2020
],
21+
null,
2122
],
2223
-1 => [
2324
0,
2425
[],
2526
[],
27+
null,
2628
],
2729
]
2830
);

src/Symfony/Component/VarExporter/Tests/Fixtures/final-array-iterator.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
0,
1313
[],
1414
[],
15+
null,
1516
],
1617
]
1718
);

src/Symfony/Component/VarExporter/Tests/VarExporterTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,12 @@ public function testExport(string $testName, $value, bool $staticValueExpected =
8787
$dump = "<?php\n\nreturn ".$marshalledValue.";\n";
8888
$dump = str_replace(var_export(__FILE__, true), "\\dirname(__DIR__).\\DIRECTORY_SEPARATOR.'VarExporterTest.php'", $dump);
8989

90-
if (\PHP_VERSION_ID < 70400 && \in_array($testName, ['array-object', 'array-iterator', 'array-object-custom', 'spl-object-storage', 'final-array-iterator', 'final-error'], true)) {
90+
if (\PHP_VERSION_ID >= 70406 || !\in_array($testName, ['array-object', 'array-iterator', 'array-object-custom', 'spl-object-storage', 'final-array-iterator', 'final-error'], true)) {
91+
$fixtureFile = __DIR__.'/Fixtures/'.$testName.'.php';
92+
} elseif (\PHP_VERSION_ID < 70400) {
9193
$fixtureFile = __DIR__.'/Fixtures/'.$testName.'-legacy.php';
9294
} else {
93-
$fixtureFile = __DIR__.'/Fixtures/'.$testName.'.php';
95+
$this->markAsSkipped('PHP >= 7.4.6 required.');
9496
}
9597
$this->assertStringEqualsFile($fixtureFile, $dump);
9698

src/Symfony/Component/VarExporter/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"symfony/polyfill-php80": "^1.15"
2121
},
2222
"require-dev": {
23-
"symfony/var-dumper": "^4.4|^5.0"
23+
"symfony/var-dumper": "^4.4.9|^5.0.9"
2424
},
2525
"autoload": {
2626
"psr-4": { "Symfony\\Component\\VarExporter\\": "" },

0 commit comments

Comments
 (0)
0