diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php index 52369bbffa..4dfbb0b82d 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php @@ -264,7 +264,7 @@ class Configuration implements ConfigurationInterface ->canBeEnabled() ->beforeNormalization() ->always(function ($v) { - if (true === $v['enabled']) { + if (\is_array($v) && true === $v['enabled']) { $workflows = $v; unset($workflows['enabled']); diff --git a/src/Symfony/Component/Config/Util/XmlUtils.php b/src/Symfony/Component/Config/Util/XmlUtils.php index df1edd68bd..dfacaff4ea 100644 --- a/src/Symfony/Component/Config/Util/XmlUtils.php +++ b/src/Symfony/Component/Config/Util/XmlUtils.php @@ -234,7 +234,7 @@ class XmlUtils return true; case 'false' === $lowercaseValue: return false; - case isset($value[1]) && '0b' == $value[0].$value[1]: + case isset($value[1]) && '0b' == $value[0].$value[1] && preg_match('/^0b[01]*$/', $value): return bindec($value); case is_numeric($value): return '0x' === $value[0].$value[1] ? hexdec($value) : (float) $value; diff --git a/src/Symfony/Component/Debug/ErrorHandler.php b/src/Symfony/Component/Debug/ErrorHandler.php index c7dc3279d7..9d7c0c67ad 100644 --- a/src/Symfony/Component/Debug/ErrorHandler.php +++ b/src/Symfony/Component/Debug/ErrorHandler.php @@ -470,7 +470,7 @@ class ErrorHandler } if ($throw) { - if (E_USER_ERROR & $type) { + if (\PHP_VERSION_ID < 70400 && E_USER_ERROR & $type) { for ($i = 1; isset($backtrace[$i]); ++$i) { if (isset($backtrace[$i]['function'], $backtrace[$i]['type'], $backtrace[$i - 1]['function']) && '__toString' === $backtrace[$i]['function'] diff --git a/src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php b/src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php index 3094d22d95..2cf75a0e8e 100644 --- a/src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php +++ b/src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php @@ -283,6 +283,10 @@ class ErrorHandlerTest extends TestCase public function testHandleUserError() { + if (\PHP_VERSION_ID >= 70400) { + $this->markTestSkipped('PHP 7.4 allows __toString to throw exceptions'); + } + try { $handler = ErrorHandler::register(); $handler->throwAt(0, true); diff --git a/src/Symfony/Component/DomCrawler/FormFieldRegistry.php b/src/Symfony/Component/DomCrawler/FormFieldRegistry.php index 8f432cfbbb..bd73742af7 100644 --- a/src/Symfony/Component/DomCrawler/FormFieldRegistry.php +++ b/src/Symfony/Component/DomCrawler/FormFieldRegistry.php @@ -57,7 +57,7 @@ class FormFieldRegistry $target = &$this->fields; while (\count($segments) > 1) { $path = array_shift($segments); - if (!\array_key_exists($path, $target)) { + if (!\is_array($target) || !\array_key_exists($path, $target)) { return; } $target = &$target[$path]; @@ -80,7 +80,7 @@ class FormFieldRegistry $target = &$this->fields; while ($segments) { $path = array_shift($segments); - if (!\array_key_exists($path, $target)) { + if (!\is_array($target) || !\array_key_exists($path, $target)) { throw new \InvalidArgumentException(sprintf('Unreachable field "%s"', $path)); } $target = &$target[$path]; diff --git a/src/Symfony/Component/Finder/Tests/Iterator/SortableIteratorTest.php b/src/Symfony/Component/Finder/Tests/Iterator/SortableIteratorTest.php index 57f1e096a5..118c4769f2 100644 --- a/src/Symfony/Component/Finder/Tests/Iterator/SortableIteratorTest.php +++ b/src/Symfony/Component/Finder/Tests/Iterator/SortableIteratorTest.php @@ -33,11 +33,7 @@ class SortableIteratorTest extends RealIteratorTestCase if (!\is_callable($mode)) { switch ($mode) { case SortableIterator::SORT_BY_ACCESSED_TIME: - if ('\\' === \DIRECTORY_SEPARATOR) { - touch(self::toAbsolute('.git')); - } else { - file_get_contents(self::toAbsolute('.git')); - } + touch(self::toAbsolute('.git')); sleep(1); file_get_contents(self::toAbsolute('.bar')); break; diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/DateTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/DateTypeTest.php index 91e6ff5f8e..96c74fe0e4 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/DateTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/DateTypeTest.php @@ -471,6 +471,7 @@ class DateTypeTest extends BaseTypeTest public function testMonthsOption() { + \Locale::setDefault('en'); $form = $this->factory->create(static::TESTED_TYPE, null, [ 'months' => [6, 7], 'format' => \IntlDateFormatter::SHORT, @@ -479,8 +480,8 @@ class DateTypeTest extends BaseTypeTest $view = $form->createView(); $this->assertEquals([ - new ChoiceView(6, '6', '06'), - new ChoiceView(7, '7', '07'), + new ChoiceView(6, '6', '6'), + new ChoiceView(7, '7', '7'), ], $view['month']->vars['choices']); } @@ -544,14 +545,15 @@ class DateTypeTest extends BaseTypeTest public function testIsDayWithinRangeReturnsTrueIfWithin() { + \Locale::setDefault('en'); $view = $this->factory->create(static::TESTED_TYPE, null, [ 'days' => [6, 7], ]) ->createView(); $this->assertEquals([ - new ChoiceView(6, '6', '06'), - new ChoiceView(7, '7', '07'), + new ChoiceView(6, '6', '6'), + new ChoiceView(7, '7', '7'), ], $view['day']->vars['choices']); } diff --git a/src/Symfony/Component/Intl/Tests/Data/Provider/AbstractCurrencyDataProviderTest.php b/src/Symfony/Component/Intl/Tests/Data/Provider/AbstractCurrencyDataProviderTest.php index 3b1f4957aa..12660eb0ac 100644 --- a/src/Symfony/Component/Intl/Tests/Data/Provider/AbstractCurrencyDataProviderTest.php +++ b/src/Symfony/Component/Intl/Tests/Data/Provider/AbstractCurrencyDataProviderTest.php @@ -589,6 +589,7 @@ abstract class AbstractCurrencyDataProviderTest extends AbstractDataProviderTest * @var CurrencyDataProvider */ protected $dataProvider; + private $defaultLocale; protected function setUp() { @@ -598,6 +599,15 @@ abstract class AbstractCurrencyDataProviderTest extends AbstractDataProviderTest $this->getDataDirectory().'/'.Intl::CURRENCY_DIR, $this->createEntryReader() ); + + $this->defaultLocale = \Locale::getDefault(); + } + + protected function tearDown() + { + parent::tearDown(); + + \Locale::setDefault($this->defaultLocale); } abstract protected function getDataDirectory(); diff --git a/src/Symfony/Component/Intl/Tests/Data/Provider/AbstractLanguageDataProviderTest.php b/src/Symfony/Component/Intl/Tests/Data/Provider/AbstractLanguageDataProviderTest.php index 917f6f0dd1..2d294f2c64 100644 --- a/src/Symfony/Component/Intl/Tests/Data/Provider/AbstractLanguageDataProviderTest.php +++ b/src/Symfony/Component/Intl/Tests/Data/Provider/AbstractLanguageDataProviderTest.php @@ -831,6 +831,7 @@ abstract class AbstractLanguageDataProviderTest extends AbstractDataProviderTest * @var LanguageDataProvider */ protected $dataProvider; + private $defaultLocale; protected function setUp() { @@ -840,6 +841,15 @@ abstract class AbstractLanguageDataProviderTest extends AbstractDataProviderTest $this->getDataDirectory().'/'.Intl::LANGUAGE_DIR, $this->createEntryReader() ); + + $this->defaultLocale = \Locale::getDefault(); + } + + protected function tearDown() + { + parent::tearDown(); + + \Locale::setDefault($this->defaultLocale); } abstract protected function getDataDirectory(); diff --git a/src/Symfony/Component/Intl/Tests/Data/Provider/AbstractLocaleDataProviderTest.php b/src/Symfony/Component/Intl/Tests/Data/Provider/AbstractLocaleDataProviderTest.php index 88242a6f9b..7da43c70eb 100644 --- a/src/Symfony/Component/Intl/Tests/Data/Provider/AbstractLocaleDataProviderTest.php +++ b/src/Symfony/Component/Intl/Tests/Data/Provider/AbstractLocaleDataProviderTest.php @@ -23,6 +23,7 @@ abstract class AbstractLocaleDataProviderTest extends AbstractDataProviderTest * @var LocaleDataProvider */ protected $dataProvider; + private $defaultLocale; protected function setUp() { @@ -32,6 +33,13 @@ abstract class AbstractLocaleDataProviderTest extends AbstractDataProviderTest $this->getDataDirectory().'/'.Intl::LOCALE_DIR, $this->createEntryReader() ); + + $this->defaultLocale = \Locale::getDefault(); + } + + protected function tearDown() + { + \Locale::setDefault($this->defaultLocale); } abstract protected function getDataDirectory(); diff --git a/src/Symfony/Component/Intl/Tests/Data/Provider/AbstractRegionDataProviderTest.php b/src/Symfony/Component/Intl/Tests/Data/Provider/AbstractRegionDataProviderTest.php index aeb922f9e3..6e2f57aa7a 100644 --- a/src/Symfony/Component/Intl/Tests/Data/Provider/AbstractRegionDataProviderTest.php +++ b/src/Symfony/Component/Intl/Tests/Data/Provider/AbstractRegionDataProviderTest.php @@ -283,6 +283,7 @@ abstract class AbstractRegionDataProviderTest extends AbstractDataProviderTest * @var RegionDataProvider */ protected $dataProvider; + private $defaultLocale; protected function setUp() { @@ -292,6 +293,15 @@ abstract class AbstractRegionDataProviderTest extends AbstractDataProviderTest $this->getDataDirectory().'/'.Intl::REGION_DIR, $this->createEntryReader() ); + + $this->defaultLocale = \Locale::getDefault(); + } + + protected function tearDown() + { + parent::tearDown(); + + \Locale::setDefault($this->defaultLocale); } abstract protected function getDataDirectory(); diff --git a/src/Symfony/Component/Intl/Tests/Data/Provider/AbstractScriptDataProviderTest.php b/src/Symfony/Component/Intl/Tests/Data/Provider/AbstractScriptDataProviderTest.php index 8620fb2060..5c279065a1 100644 --- a/src/Symfony/Component/Intl/Tests/Data/Provider/AbstractScriptDataProviderTest.php +++ b/src/Symfony/Component/Intl/Tests/Data/Provider/AbstractScriptDataProviderTest.php @@ -219,6 +219,7 @@ abstract class AbstractScriptDataProviderTest extends AbstractDataProviderTest * @var ScriptDataProvider */ protected $dataProvider; + private $defaultLocale; protected function setUp() { @@ -228,6 +229,15 @@ abstract class AbstractScriptDataProviderTest extends AbstractDataProviderTest $this->getDataDirectory().'/'.Intl::SCRIPT_DIR, $this->createEntryReader() ); + + $this->defaultLocale = \Locale::getDefault(); + } + + protected function tearDown() + { + parent::tearDown(); + + \Locale::setDefault($this->defaultLocale); } abstract protected function getDataDirectory(); diff --git a/src/Symfony/Component/Intl/Tests/DateFormatter/AbstractIntlDateFormatterTest.php b/src/Symfony/Component/Intl/Tests/DateFormatter/AbstractIntlDateFormatterTest.php index 682380bf54..df99b12109 100644 --- a/src/Symfony/Component/Intl/Tests/DateFormatter/AbstractIntlDateFormatterTest.php +++ b/src/Symfony/Component/Intl/Tests/DateFormatter/AbstractIntlDateFormatterTest.php @@ -24,11 +24,23 @@ use Symfony\Component\Intl\Util\IcuVersion; */ abstract class AbstractIntlDateFormatterTest extends TestCase { + private $defaultLocale; + protected function setUp() { + parent::setUp(); + + $this->defaultLocale = \Locale::getDefault(); \Locale::setDefault('en'); } + protected function tearDown() + { + parent::tearDown(); + + \Locale::setDefault($this->defaultLocale); + } + /** * When a time zone is not specified, it uses the system default however it returns null in the getter method. * diff --git a/src/Symfony/Component/Intl/Tests/IntlTest.php b/src/Symfony/Component/Intl/Tests/IntlTest.php index d45a1ded5c..059f5eb6c4 100644 --- a/src/Symfony/Component/Intl/Tests/IntlTest.php +++ b/src/Symfony/Component/Intl/Tests/IntlTest.php @@ -16,6 +16,22 @@ use Symfony\Component\Intl\Intl; class IntlTest extends TestCase { + private $defaultLocale; + + protected function setUp() + { + parent::setUp(); + + $this->defaultLocale = \Locale::getDefault(); + } + + protected function tearDown() + { + parent::tearDown(); + + \Locale::setDefault($this->defaultLocale); + } + /** * @requires extension intl */ diff --git a/src/Symfony/Component/Intl/Tests/NumberFormatter/AbstractNumberFormatterTest.php b/src/Symfony/Component/Intl/Tests/NumberFormatter/AbstractNumberFormatterTest.php index 9e8499eba9..f64131a61b 100644 --- a/src/Symfony/Component/Intl/Tests/NumberFormatter/AbstractNumberFormatterTest.php +++ b/src/Symfony/Component/Intl/Tests/NumberFormatter/AbstractNumberFormatterTest.php @@ -36,7 +36,7 @@ abstract class AbstractNumberFormatterTest extends TestCase { return [ [100, 'ALL', '100'], - [100, 'BRL', '100.00'], + [100, 'BRL', '100'], [100, 'CRC', '100'], [100, 'JPY', '100'], [100, 'CHF', '100'], diff --git a/src/Symfony/Component/Stopwatch/Tests/StopwatchTest.php b/src/Symfony/Component/Stopwatch/Tests/StopwatchTest.php index f85ccd0ec4..b8efa373b4 100644 --- a/src/Symfony/Component/Stopwatch/Tests/StopwatchTest.php +++ b/src/Symfony/Component/Stopwatch/Tests/StopwatchTest.php @@ -87,7 +87,7 @@ class StopwatchTest extends TestCase $event = $stopwatch->stop('foo'); $this->assertInstanceOf('Symfony\Component\Stopwatch\StopwatchEvent', $event); - $this->assertEquals(200, $event->getDuration(), '', self::DELTA); + $this->assertEqualsWithDelta(200, $event->getDuration(), self::DELTA); } public function testUnknownEvent() diff --git a/src/Symfony/Component/Translation/Loader/CsvFileLoader.php b/src/Symfony/Component/Translation/Loader/CsvFileLoader.php index 18cc83ed68..db17bd5631 100644 --- a/src/Symfony/Component/Translation/Loader/CsvFileLoader.php +++ b/src/Symfony/Component/Translation/Loader/CsvFileLoader.php @@ -41,6 +41,10 @@ class CsvFileLoader extends FileLoader $file->setCsvControl($this->delimiter, $this->enclosure, $this->escape); foreach ($file as $data) { + if (false === $data) { + continue; + } + if ('#' !== substr($data[0], 0, 1) && isset($data[1]) && 2 === \count($data)) { $messages[$data[0]] = $data[1]; } diff --git a/src/Symfony/Component/Translation/Tests/IdentityTranslatorTest.php b/src/Symfony/Component/Translation/Tests/IdentityTranslatorTest.php index c3d7b1f7d1..a5c63df988 100644 --- a/src/Symfony/Component/Translation/Tests/IdentityTranslatorTest.php +++ b/src/Symfony/Component/Translation/Tests/IdentityTranslatorTest.php @@ -17,6 +17,22 @@ use Symfony\Component\Translation\IdentityTranslator; class IdentityTranslatorTest extends TestCase { + private $defaultLocale; + + protected function setUp() + { + parent::setUp(); + + $this->defaultLocale = \Locale::getDefault(); + } + + protected function tearDown() + { + parent::tearDown(); + + \Locale::setDefault($this->defaultLocale); + } + /** * @dataProvider getTransTests */ diff --git a/src/Symfony/Component/Validator/Tests/Constraints/CountryValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/CountryValidatorTest.php index 429aef812f..f5cb9a6db3 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/CountryValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/CountryValidatorTest.php @@ -18,6 +18,22 @@ use Symfony\Component\Validator\Test\ConstraintValidatorTestCase; class CountryValidatorTest extends ConstraintValidatorTestCase { + private $defaultLocale; + + protected function setUp() + { + parent::setUp(); + + $this->defaultLocale = \Locale::getDefault(); + } + + protected function tearDown() + { + parent::tearDown(); + + \Locale::setDefault($this->defaultLocale); + } + protected function createValidator() { return new CountryValidator(); diff --git a/src/Symfony/Component/Validator/Tests/Constraints/CurrencyValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/CurrencyValidatorTest.php index 7a61973536..d46fcd5548 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/CurrencyValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/CurrencyValidatorTest.php @@ -18,6 +18,22 @@ use Symfony\Component\Validator\Test\ConstraintValidatorTestCase; class CurrencyValidatorTest extends ConstraintValidatorTestCase { + private $defaultLocale; + + protected function setUp() + { + parent::setUp(); + + $this->defaultLocale = \Locale::getDefault(); + } + + protected function tearDown() + { + parent::tearDown(); + + \Locale::setDefault($this->defaultLocale); + } + protected function createValidator() { return new CurrencyValidator(); diff --git a/src/Symfony/Component/Validator/Tests/Constraints/LanguageValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/LanguageValidatorTest.php index f23fd13fcb..31a987bdd3 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/LanguageValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/LanguageValidatorTest.php @@ -18,6 +18,22 @@ use Symfony\Component\Validator\Test\ConstraintValidatorTestCase; class LanguageValidatorTest extends ConstraintValidatorTestCase { + private $defaultLocale; + + protected function setUp() + { + parent::setUp(); + + $this->defaultLocale = \Locale::getDefault(); + } + + protected function tearDown() + { + parent::tearDown(); + + \Locale::setDefault($this->defaultLocale); + } + protected function createValidator() { return new LanguageValidator(); diff --git a/src/Symfony/Component/Validator/Tests/Constraints/RangeValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/RangeValidatorTest.php index 661161d886..df33d2c422 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/RangeValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/RangeValidatorTest.php @@ -50,7 +50,7 @@ class RangeValidatorTest extends ConstraintValidatorTestCase [9.99999, '9.99999'], ['9.99999', '"9.99999"'], [5, '5'], - [1.0, '1.0'], + [1.0, '1'], ]; } @@ -60,7 +60,7 @@ class RangeValidatorTest extends ConstraintValidatorTestCase [20.000001, '20.000001'], ['20.000001', '"20.000001"'], [21, '21'], - [30.0, '30.0'], + [30.0, '30'], ]; } diff --git a/src/Symfony/Component/VarDumper/Tests/Caster/ExceptionCasterTest.php b/src/Symfony/Component/VarDumper/Tests/Caster/ExceptionCasterTest.php index ea83e77163..738180f5b2 100644 --- a/src/Symfony/Component/VarDumper/Tests/Caster/ExceptionCasterTest.php +++ b/src/Symfony/Component/VarDumper/Tests/Caster/ExceptionCasterTest.php @@ -52,7 +52,6 @@ Exception { › } } %s%eTests%eCaster%eExceptionCasterTest.php:40 { …} - Symfony\Component\VarDumper\Tests\Caster\ExceptionCasterTest->testDefaultSettings() {} %A EODUMP; @@ -71,8 +70,7 @@ EODUMP; › return new \Exception(''.$msg); › } } - %s%eTests%eCaster%eExceptionCasterTest.php:65 { …} - Symfony\Component\VarDumper\Tests\Caster\ExceptionCasterTest->testSeek() {} + %s%eTests%eCaster%eExceptionCasterTest.php:64 { …} %A EODUMP; @@ -96,8 +94,7 @@ Exception { › return new \Exception(''.$msg); › } } - %s%eTests%eCaster%eExceptionCasterTest.php:84 { …} - Symfony\Component\VarDumper\Tests\Caster\ExceptionCasterTest->testNoArgs() {} + %s%eTests%eCaster%eExceptionCasterTest.php:82 { …} %A EODUMP;