Merge branch '5.2' into 5.x
* 5.2: [HttpFoundation] Make test pass without Xdebug. [Mime] Leverage PHP 8's detection of CSV files. [HttpFoundation] Make sure we reuse the current PHP binary for the webserver process in functional tests. [FrameworkBundle] TextDescriptor::formatControllerLink checked method… Fix CS [HttpClient] throw clearer error when no scheme is provided Fix github pr template and include 5.2 for bugfixes [HttpFoundation] Ignore stack trace printed by Xdebug 3. fix lexing backslashes in single quoted strings
This commit is contained in:
commit
1bf434139a
2
.github/PULL_REQUEST_TEMPLATE.md
vendored
2
.github/PULL_REQUEST_TEMPLATE.md
vendored
@ -1,6 +1,6 @@
|
|||||||
| Q | A
|
| Q | A
|
||||||
| ------------- | ---
|
| ------------- | ---
|
||||||
| Branch? | 5.x for features / 4.4 or 5.1 for bug fixes <!-- see below -->
|
| Branch? | 5.x for features / 4.4, 5.1 or 5.2 for bug fixes <!-- see below -->
|
||||||
| Bug fix? | yes/no
|
| Bug fix? | yes/no
|
||||||
| New feature? | yes/no <!-- please update src/**/CHANGELOG.md files -->
|
| New feature? | yes/no <!-- please update src/**/CHANGELOG.md files -->
|
||||||
| Deprecations? | yes/no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
|
| Deprecations? | yes/no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
|
||||||
|
@ -535,7 +535,9 @@ class TextDescriptor extends Descriptor
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (\is_array($controller)) {
|
if (null === $controller) {
|
||||||
|
return $anchorText;
|
||||||
|
} elseif (\is_array($controller)) {
|
||||||
$r = new \ReflectionMethod($controller[0], $controller[1]);
|
$r = new \ReflectionMethod($controller[0], $controller[1]);
|
||||||
} elseif ($controller instanceof \Closure) {
|
} elseif ($controller instanceof \Closure) {
|
||||||
$r = new \ReflectionFunction($controller);
|
$r = new \ReflectionFunction($controller);
|
||||||
|
@ -391,6 +391,10 @@ trait HttpClientTrait
|
|||||||
throw new InvalidArgumentException(sprintf('Invalid "base_uri" option: host or scheme is missing in "%s".', implode('', $base)));
|
throw new InvalidArgumentException(sprintf('Invalid "base_uri" option: host or scheme is missing in "%s".', implode('', $base)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (null === $url['scheme'] && (null === $base || null === $base['scheme'])) {
|
||||||
|
throw new InvalidArgumentException(sprintf('Invalid URL: scheme is missing in "%s". Did you forget to add "http(s)://"?', implode('', $base ?? $url)));
|
||||||
|
}
|
||||||
|
|
||||||
if (null === $base && '' === $url['scheme'].$url['authority']) {
|
if (null === $base && '' === $url['scheme'].$url['authority']) {
|
||||||
throw new InvalidArgumentException(sprintf('Invalid URL: no "base_uri" option was provided and host or scheme is missing in "%s".', implode('', $url)));
|
throw new InvalidArgumentException(sprintf('Invalid URL: no "base_uri" option was provided and host or scheme is missing in "%s".', implode('', $url)));
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
namespace Symfony\Component\HttpClient\Tests;
|
namespace Symfony\Component\HttpClient\Tests;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
use Symfony\Component\HttpClient\Exception\InvalidArgumentException;
|
||||||
use Symfony\Component\HttpClient\HttpClientTrait;
|
use Symfony\Component\HttpClient\HttpClientTrait;
|
||||||
use Symfony\Contracts\HttpClient\HttpClientInterface;
|
use Symfony\Contracts\HttpClient\HttpClientInterface;
|
||||||
|
|
||||||
@ -120,6 +121,20 @@ class HttpClientTraitTest extends TestCase
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testResolveUrlWithoutScheme()
|
||||||
|
{
|
||||||
|
$this->expectException(InvalidArgumentException::class);
|
||||||
|
$this->expectExceptionMessage('Invalid URL: scheme is missing in "//localhost:8080". Did you forget to add "http(s)://"?');
|
||||||
|
self::resolveUrl(self::parseUrl('localhost:8080'), null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testResolveBaseUrlWitoutScheme()
|
||||||
|
{
|
||||||
|
$this->expectException(InvalidArgumentException::class);
|
||||||
|
$this->expectExceptionMessage('Invalid URL: scheme is missing in "//localhost:8081". Did you forget to add "http(s)://"?');
|
||||||
|
self::resolveUrl(self::parseUrl('/foo'), self::parseUrl('localhost:8081'));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dataProvider provideParseUrl
|
* @dataProvider provideParseUrl
|
||||||
*/
|
*/
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
Warning: Expiry date cannot have a year greater than 9999 in %scookie_max_age.php on line 10
|
Warning: Expiry date cannot have a year greater than 9999 in %scookie_max_age.php on line 10
|
||||||
|
%A
|
||||||
Array
|
Array
|
||||||
(
|
(
|
||||||
[0] => Content-Type: text/plain; charset=utf-8
|
[0] => Content-Type: text/plain; charset=utf-8
|
||||||
|
@ -23,7 +23,7 @@ class ResponseFunctionalTest extends TestCase
|
|||||||
1 => ['file', '/dev/null', 'w'],
|
1 => ['file', '/dev/null', 'w'],
|
||||||
2 => ['file', '/dev/null', 'w'],
|
2 => ['file', '/dev/null', 'w'],
|
||||||
];
|
];
|
||||||
if (!self::$server = @proc_open('exec php -S localhost:8054', $spec, $pipes, __DIR__.'/Fixtures/response-functional')) {
|
if (!self::$server = @proc_open('exec '.\PHP_BINARY.' -S localhost:8054', $spec, $pipes, __DIR__.'/Fixtures/response-functional')) {
|
||||||
self::markTestSkipped('PHP server unable to start.');
|
self::markTestSkipped('PHP server unable to start.');
|
||||||
}
|
}
|
||||||
sleep(1);
|
sleep(1);
|
||||||
|
@ -23,7 +23,7 @@ class AbstractSessionHandlerTest extends TestCase
|
|||||||
1 => ['file', '/dev/null', 'w'],
|
1 => ['file', '/dev/null', 'w'],
|
||||||
2 => ['file', '/dev/null', 'w'],
|
2 => ['file', '/dev/null', 'w'],
|
||||||
];
|
];
|
||||||
if (!self::$server = @proc_open('exec php -S localhost:8053', $spec, $pipes, __DIR__.'/Fixtures')) {
|
if (!self::$server = @proc_open('exec '.\PHP_BINARY.' -S localhost:8053', $spec, $pipes, __DIR__.'/Fixtures')) {
|
||||||
self::markTestSkipped('PHP server unable to start.');
|
self::markTestSkipped('PHP server unable to start.');
|
||||||
}
|
}
|
||||||
sleep(1);
|
sleep(1);
|
||||||
|
@ -173,6 +173,7 @@ final class MimeTypes implements MimeTypesInterface
|
|||||||
'application/cdmi-queue' => ['cdmiq'],
|
'application/cdmi-queue' => ['cdmiq'],
|
||||||
'application/cdr' => ['cdr'],
|
'application/cdr' => ['cdr'],
|
||||||
'application/coreldraw' => ['cdr'],
|
'application/coreldraw' => ['cdr'],
|
||||||
|
'application/csv' => ['csv'],
|
||||||
'application/cu-seeme' => ['cu'],
|
'application/cu-seeme' => ['cu'],
|
||||||
'application/dash+xml' => ['mpd'],
|
'application/dash+xml' => ['mpd'],
|
||||||
'application/davmount+xml' => ['davmount'],
|
'application/davmount+xml' => ['davmount'],
|
||||||
@ -1960,7 +1961,7 @@ final class MimeTypes implements MimeTypesInterface
|
|||||||
'csp' => ['application/vnd.commonspace'],
|
'csp' => ['application/vnd.commonspace'],
|
||||||
'css' => ['text/css'],
|
'css' => ['text/css'],
|
||||||
'cst' => ['application/x-director'],
|
'cst' => ['application/x-director'],
|
||||||
'csv' => ['text/csv', 'text/x-comma-separated-values', 'text/x-csv'],
|
'csv' => ['text/csv', 'text/x-comma-separated-values', 'text/x-csv', 'application/csv'],
|
||||||
'csvs' => ['text/csv-schema'],
|
'csvs' => ['text/csv-schema'],
|
||||||
'cu' => ['application/cu-seeme'],
|
'cu' => ['application/cu-seeme'],
|
||||||
'cue' => ['application/x-cue'],
|
'cue' => ['application/x-cue'],
|
||||||
|
@ -0,0 +1,3 @@
|
|||||||
|
a,b,c
|
||||||
|
d,e,f
|
||||||
|
g,h,i
|
|
@ -73,4 +73,18 @@ class MimeTypesTest extends AbstractMimeTypeGuesserTest
|
|||||||
$this->assertContains('text/baz', $mt->getMimeTypes('foo'));
|
$this->assertContains('text/baz', $mt->getMimeTypes('foo'));
|
||||||
$this->assertSame(['foo', 'moof'], $mt->getExtensions('text/baz'));
|
$this->assertSame(['foo', 'moof'], $mt->getExtensions('text/baz'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PHP 8 detects .csv files as "application/csv" while PHP 7 returns "text/plain".
|
||||||
|
*
|
||||||
|
* @requires PHP 8
|
||||||
|
*/
|
||||||
|
public function testCsvExtension()
|
||||||
|
{
|
||||||
|
$mt = new MimeTypes();
|
||||||
|
|
||||||
|
$mime = $mt->guessMimeType(__DIR__.'/Fixtures/mimetypes/abc.csv');
|
||||||
|
$this->assertSame('application/csv', $mime);
|
||||||
|
$this->assertSame(['csv'], $mt->getExtensions($mime));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1178,7 +1178,9 @@ class Parser
|
|||||||
for (; \strlen($this->currentLine) > $cursor; ++$cursor) {
|
for (; \strlen($this->currentLine) > $cursor; ++$cursor) {
|
||||||
switch ($this->currentLine[$cursor]) {
|
switch ($this->currentLine[$cursor]) {
|
||||||
case '\\':
|
case '\\':
|
||||||
if (isset($this->currentLine[++$cursor])) {
|
if ("'" === $quotation) {
|
||||||
|
$value .= '\\';
|
||||||
|
} elseif (isset($this->currentLine[++$cursor])) {
|
||||||
$value .= '\\'.$this->currentLine[$cursor];
|
$value .= '\\'.$this->currentLine[$cursor];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1617,6 +1617,11 @@ YAML
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testBackslashInSingleQuotedString()
|
||||||
|
{
|
||||||
|
$this->assertSame(['foo' => 'bar\\'], $this->parser->parse("foo: 'bar\'"));
|
||||||
|
}
|
||||||
|
|
||||||
public function testParseMultiLineString()
|
public function testParseMultiLineString()
|
||||||
{
|
{
|
||||||
$this->assertEquals("foo bar\nbaz", $this->parser->parse("foo\nbar\n\nbaz"));
|
$this->assertEquals("foo bar\nbaz", $this->parser->parse("foo\nbar\n\nbaz"));
|
||||||
|
Reference in New Issue
Block a user