-
No options where passed when constructing this form.
+
No options were passed when constructing this form.
{% endif %}
diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar.css.twig b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar.css.twig
index 8953316de06f2..4012625e85d15 100644
--- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar.css.twig
+++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar.css.twig
@@ -54,6 +54,7 @@
text-align: left;
text-transform: none;
z-index: 99999;
+ direction: ltr;
/* neutralize the aliasing defined by external CSS styles */
-webkit-font-smoothing: subpixel-antialiased;
diff --git a/src/Symfony/Component/Config/Definition/ArrayNode.php b/src/Symfony/Component/Config/Definition/ArrayNode.php
index ac310819d4199..2afa629cdae46 100644
--- a/src/Symfony/Component/Config/Definition/ArrayNode.php
+++ b/src/Symfony/Component/Config/Definition/ArrayNode.php
@@ -141,7 +141,7 @@ public function setPerformDeepMerging($boolean)
}
/**
- * Whether extra keys should just be ignore without an exception.
+ * Whether extra keys should just be ignored without an exception.
*
* @param bool $boolean To allow extra keys
* @param bool $remove To remove extra keys
diff --git a/src/Symfony/Component/Config/Resource/ComposerResource.php b/src/Symfony/Component/Config/Resource/ComposerResource.php
index c826d1bb75127..9fb304bea8f06 100644
--- a/src/Symfony/Component/Config/Resource/ComposerResource.php
+++ b/src/Symfony/Component/Config/Resource/ComposerResource.php
@@ -48,7 +48,7 @@ public function isFresh($timestamp)
{
self::refresh();
- return self::$runtimeVendors === $this->vendors;
+ return array_values(self::$runtimeVendors) === array_values($this->vendors);
}
/**
diff --git a/src/Symfony/Component/Config/Resource/ReflectionClassResource.php b/src/Symfony/Component/Config/Resource/ReflectionClassResource.php
index a86a37ed8dcbd..f05042f8d32fa 100644
--- a/src/Symfony/Component/Config/Resource/ReflectionClassResource.php
+++ b/src/Symfony/Component/Config/Resource/ReflectionClassResource.php
@@ -140,7 +140,7 @@ private function generateSignature(\ReflectionClass $class)
foreach ($class->getProperties(\ReflectionProperty::IS_PUBLIC | \ReflectionProperty::IS_PROTECTED) as $p) {
yield $p->getDocComment().$p;
- yield print_r($defaults[$p->name], true);
+ yield print_r(isset($defaults[$p->name]) ? $defaults[$p->name] : null, true);
}
}
diff --git a/src/Symfony/Component/Config/Tests/Resource/ReflectionClassResourceTest.php b/src/Symfony/Component/Config/Tests/Resource/ReflectionClassResourceTest.php
index 23f2cc567c4cd..1f0bcb17b4f5e 100644
--- a/src/Symfony/Component/Config/Tests/Resource/ReflectionClassResourceTest.php
+++ b/src/Symfony/Component/Config/Tests/Resource/ReflectionClassResourceTest.php
@@ -137,6 +137,14 @@ public function provideHashedSignature()
yield [1, 13, 'protected function prot($a = [123]) {}'];
yield [0, 14, '/** priv docblock */'];
yield [0, 15, ''];
+
+ if (\PHP_VERSION_ID >= 70400) {
+ // PHP7.4 typed properties without default value are
+ // undefined, make sure this doesn't throw an error
+ yield [1, 5, 'public array $pub;'];
+ yield [0, 7, 'protected int $prot;'];
+ yield [0, 9, 'private string $priv;'];
+ }
}
public function testEventSubscriber()
diff --git a/src/Symfony/Component/Console/CommandLoader/CommandLoaderInterface.php b/src/Symfony/Component/Console/CommandLoader/CommandLoaderInterface.php
index 9462996f6d2af..ca1029cb60042 100644
--- a/src/Symfony/Component/Console/CommandLoader/CommandLoaderInterface.php
+++ b/src/Symfony/Component/Console/CommandLoader/CommandLoaderInterface.php
@@ -1,5 +1,14 @@
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
namespace Symfony\Component\Console\CommandLoader;
use Symfony\Component\Console\Command\Command;
diff --git a/src/Symfony/Component/Console/CommandLoader/ContainerCommandLoader.php b/src/Symfony/Component/Console/CommandLoader/ContainerCommandLoader.php
index 753ad0fb705c2..8000c7d5eca82 100644
--- a/src/Symfony/Component/Console/CommandLoader/ContainerCommandLoader.php
+++ b/src/Symfony/Component/Console/CommandLoader/ContainerCommandLoader.php
@@ -1,5 +1,14 @@
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
namespace Symfony\Component\Console\CommandLoader;
use Psr\Container\ContainerInterface;
diff --git a/src/Symfony/Component/Console/Formatter/OutputFormatterStyle.php b/src/Symfony/Component/Console/Formatter/OutputFormatterStyle.php
index b27439a761355..477bd87f0c4aa 100644
--- a/src/Symfony/Component/Console/Formatter/OutputFormatterStyle.php
+++ b/src/Symfony/Component/Console/Formatter/OutputFormatterStyle.php
@@ -75,11 +75,7 @@ public function __construct($foreground = null, $background = null, array $optio
}
/**
- * Sets style foreground color.
- *
- * @param string|null $color The color name
- *
- * @throws InvalidArgumentException When the color name isn't defined
+ * {@inheritdoc}
*/
public function setForeground($color = null)
{
@@ -97,11 +93,7 @@ public function setForeground($color = null)
}
/**
- * Sets style background color.
- *
- * @param string|null $color The color name
- *
- * @throws InvalidArgumentException When the color name isn't defined
+ * {@inheritdoc}
*/
public function setBackground($color = null)
{
@@ -119,11 +111,7 @@ public function setBackground($color = null)
}
/**
- * Sets some specific style option.
- *
- * @param string $option The option name
- *
- * @throws InvalidArgumentException When the option name isn't defined
+ * {@inheritdoc}
*/
public function setOption($option)
{
@@ -137,11 +125,7 @@ public function setOption($option)
}
/**
- * Unsets some specific style option.
- *
- * @param string $option The option name
- *
- * @throws InvalidArgumentException When the option name isn't defined
+ * {@inheritdoc}
*/
public function unsetOption($option)
{
@@ -168,11 +152,7 @@ public function setOptions(array $options)
}
/**
- * Applies the style to a given text.
- *
- * @param string $text The text to style
- *
- * @return string
+ * {@inheritdoc}
*/
public function apply($text)
{
diff --git a/src/Symfony/Component/Console/Formatter/OutputFormatterStyleInterface.php b/src/Symfony/Component/Console/Formatter/OutputFormatterStyleInterface.php
index 4c7dc4134d723..af171c27020c9 100644
--- a/src/Symfony/Component/Console/Formatter/OutputFormatterStyleInterface.php
+++ b/src/Symfony/Component/Console/Formatter/OutputFormatterStyleInterface.php
@@ -21,7 +21,7 @@ interface OutputFormatterStyleInterface
/**
* Sets style foreground color.
*
- * @param string $color The color name
+ * @param string|null $color The color name
*/
public function setForeground($color = null);
diff --git a/src/Symfony/Component/Console/Question/ChoiceQuestion.php b/src/Symfony/Component/Console/Question/ChoiceQuestion.php
index 5cb5056903e43..3dca160049338 100644
--- a/src/Symfony/Component/Console/Question/ChoiceQuestion.php
+++ b/src/Symfony/Component/Console/Question/ChoiceQuestion.php
@@ -134,17 +134,15 @@ private function getDefaultValidator()
$isAssoc = $this->isAssoc($choices);
return function ($selected) use ($choices, $errorMessage, $multiselect, $isAssoc) {
- // Collapse all spaces.
- $selectedChoices = str_replace(' ', '', $selected);
-
if ($multiselect) {
// Check for a separated comma values
- if (!preg_match('/^[^,]+(?:,[^,]+)*$/', $selectedChoices, $matches)) {
+ if (!preg_match('/^[^,]+(?:,[^,]+)*$/', $selected, $matches)) {
throw new InvalidArgumentException(sprintf($errorMessage, $selected));
}
- $selectedChoices = explode(',', $selectedChoices);
+
+ $selectedChoices = array_map('trim', explode(',', $selected));
} else {
- $selectedChoices = [$selected];
+ $selectedChoices = [trim($selected)];
}
$multiselectChoices = [];
diff --git a/src/Symfony/Component/Console/Tests/Question/ChoiceQuestionTest.php b/src/Symfony/Component/Console/Tests/Question/ChoiceQuestionTest.php
new file mode 100644
index 0000000000000..5ec7a9cacb4de
--- /dev/null
+++ b/src/Symfony/Component/Console/Tests/Question/ChoiceQuestionTest.php
@@ -0,0 +1,64 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Console\Tests\Question;
+
+use PHPUnit\Framework\TestCase;
+use Symfony\Component\Console\Question\ChoiceQuestion;
+
+class ChoiceQuestionTest extends TestCase
+{
+ /**
+ * @dataProvider selectUseCases
+ */
+ public function testSelectUseCases($multiSelect, $answers, $expected, $message)
+ {
+ $question = new ChoiceQuestion('A question', [
+ 'First response',
+ 'Second response',
+ 'Third response',
+ 'Fourth response',
+ ]);
+
+ $question->setMultiselect($multiSelect);
+
+ foreach ($answers as $answer) {
+ $validator = $question->getValidator();
+ $actual = $validator($answer);
+
+ $this->assertEquals($actual, $expected, $message);
+ }
+ }
+
+ public function selectUseCases()
+ {
+ return [
+ [
+ false,
+ ['First response', 'First response ', ' First response', ' First response '],
+ 'First response',
+ 'When passed single answer on singleSelect, the defaultValidator must return this answer as a string',
+ ],
+ [
+ true,
+ ['First response', 'First response ', ' First response', ' First response '],
+ ['First response'],
+ 'When passed single answer on MultiSelect, the defaultValidator must return this answer as an array',
+ ],
+ [
+ true,
+ ['First response,Second response', ' First response , Second response '],
+ ['First response', 'Second response'],
+ 'When passed multiple answers on MultiSelect, the defaultValidator must return these answers as an array',
+ ],
+ ];
+ }
+}
diff --git a/src/Symfony/Component/Debug/DebugClassLoader.php b/src/Symfony/Component/Debug/DebugClassLoader.php
index 9ceac9af162b0..13ab9e700c743 100644
--- a/src/Symfony/Component/Debug/DebugClassLoader.php
+++ b/src/Symfony/Component/Debug/DebugClassLoader.php
@@ -149,11 +149,11 @@ public function loadClass($class)
if (!$file = $this->classLoader[0]->findFile($class) ?: false) {
// no-op
} elseif (\function_exists('opcache_is_script_cached') && @opcache_is_script_cached($file)) {
- require $file;
+ include $file;
return;
- } else {
- require $file;
+ } elseif (false === include $file) {
+ return;
}
} else {
\call_user_func($this->classLoader, $class);
diff --git a/src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php b/src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php
index bb82c63328b19..bb7fe413abe63 100644
--- a/src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php
+++ b/src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php
@@ -70,8 +70,8 @@ public function testRegister()
public function testErrorGetLast()
{
- $handler = ErrorHandler::register();
$logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock();
+ $handler = ErrorHandler::register();
$handler->setDefaultLogger($logger);
$handler->screamAt(E_ALL);
@@ -143,9 +143,8 @@ public function testConstruct()
public function testDefaultLogger()
{
try {
- $handler = ErrorHandler::register();
-
$logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock();
+ $handler = ErrorHandler::register();
$handler->setDefaultLogger($logger, E_NOTICE);
$handler->setDefaultLogger($logger, [E_USER_NOTICE => LogLevel::CRITICAL]);
@@ -334,12 +333,11 @@ public function testHandleDeprecation()
public function testHandleException()
{
try {
+ $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock();
$handler = ErrorHandler::register();
$exception = new \Exception('foo');
- $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock();
-
$logArgCheck = function ($level, $message, $context) {
$this->assertSame('Uncaught Exception: foo', $message);
$this->assertArrayHasKey('exception', $context);
@@ -483,6 +481,7 @@ public function testSettingLoggerWhenExceptionIsBuffered()
public function testHandleFatalError()
{
try {
+ $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock();
$handler = ErrorHandler::register();
$error = [
@@ -492,8 +491,6 @@ public function testHandleFatalError()
'line' => 123,
];
- $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock();
-
$logArgCheck = function ($level, $message, $context) {
$this->assertEquals('Fatal Parse Error: foo', $message);
$this->assertArrayHasKey('exception', $context);
diff --git a/src/Symfony/Component/Debug/Tests/ExceptionHandlerTest.php b/src/Symfony/Component/Debug/Tests/ExceptionHandlerTest.php
index e166136cbbed4..8a196649503c3 100644
--- a/src/Symfony/Component/Debug/Tests/ExceptionHandlerTest.php
+++ b/src/Symfony/Component/Debug/Tests/ExceptionHandlerTest.php
@@ -76,7 +76,7 @@ public function testHeaders()
ob_start();
$handler->sendPhpResponse(new MethodNotAllowedHttpException(['POST']));
- $response = ob_get_clean();
+ ob_get_clean();
$expectedHeaders = [
['HTTP/1.0 405', true, null],
@@ -99,35 +99,65 @@ public function testNestedExceptions()
public function testHandle()
{
- $exception = new \Exception('foo');
+ $handler = new ExceptionHandler(true);
+ ob_start();
- $handler = $this->getMockBuilder('Symfony\Component\Debug\ExceptionHandler')->setMethods(['sendPhpResponse'])->getMock();
- $handler
- ->expects($this->exactly(2))
- ->method('sendPhpResponse');
+ $handler->handle(new \Exception('foo'));
- $handler->handle($exception);
+ $this->assertThatTheExceptionWasOutput(ob_get_clean(), \Exception::class, 'Exception', 'foo');
+ }
- $handler->setHandler(function ($e) use ($exception) {
- $this->assertSame($exception, $e);
+ public function testHandleWithACustomHandlerThatOutputsSomething()
+ {
+ $handler = new ExceptionHandler(true);
+ ob_start();
+ $handler->setHandler(function () {
+ echo 'ccc';
});
- $handler->handle($exception);
+ $handler->handle(new \Exception());
+ ob_end_flush(); // Necessary because of this PHP bug : https://bugs.php.net/bug.php?id=76563
+ $this->assertSame('ccc', ob_get_clean());
}
- public function testHandleOutOfMemoryException()
+ public function testHandleWithACustomHandlerThatOutputsNothing()
+ {
+ $handler = new ExceptionHandler(true);
+ $handler->setHandler(function () {});
+
+ $handler->handle(new \Exception('ccc'));
+
+ $this->assertThatTheExceptionWasOutput(ob_get_clean(), \Exception::class, 'Exception', 'ccc');
+ }
+
+ public function testHandleWithACustomHandlerThatFails()
{
- $exception = new OutOfMemoryException('foo', 0, E_ERROR, __FILE__, __LINE__);
+ $handler = new ExceptionHandler(true);
+ $handler->setHandler(function () {
+ throw new \RuntimeException();
+ });
- $handler = $this->getMockBuilder('Symfony\Component\Debug\ExceptionHandler')->setMethods(['sendPhpResponse'])->getMock();
- $handler
- ->expects($this->once())
- ->method('sendPhpResponse');
+ $handler->handle(new \Exception('ccc'));
- $handler->setHandler(function ($e) {
+ $this->assertThatTheExceptionWasOutput(ob_get_clean(), \Exception::class, 'Exception', 'ccc');
+ }
+
+ public function testHandleOutOfMemoryException()
+ {
+ $handler = new ExceptionHandler(true);
+ ob_start();
+ $handler->setHandler(function () {
$this->fail('OutOfMemoryException should bypass the handler');
});
- $handler->handle($exception);
+ $handler->handle(new OutOfMemoryException('foo', 0, E_ERROR, __FILE__, __LINE__));
+
+ $this->assertThatTheExceptionWasOutput(ob_get_clean(), OutOfMemoryException::class, 'OutOfMemoryException', 'foo');
+ }
+
+ private function assertThatTheExceptionWasOutput($content, $expectedClass, $expectedTitle, $expectedMessage)
+ {
+ $this->assertContains(sprintf('