From 05ec8a08b40280760853aaec69ef25f6a95fc56b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Deruss=C3=A9?= Date: Tue, 6 Aug 2019 11:10:43 +0200 Subject: [PATCH 1/2] Fix remaining tests --- .../DependencyInjection/Configuration.php | 2 +- src/Symfony/Component/Config/Util/XmlUtils.php | 2 +- src/Symfony/Component/Debug/ErrorHandler.php | 2 +- .../Component/Debug/Tests/ErrorHandlerTest.php | 4 ++++ .../Component/DomCrawler/FormFieldRegistry.php | 4 ++-- .../Tests/Iterator/SortableIteratorTest.php | 6 +----- .../Tests/Extension/Core/Type/DateTypeTest.php | 10 ++++++---- .../AbstractCurrencyDataProviderTest.php | 10 ++++++++++ .../AbstractLanguageDataProviderTest.php | 10 ++++++++++ .../Provider/AbstractLocaleDataProviderTest.php | 8 ++++++++ .../Provider/AbstractRegionDataProviderTest.php | 10 ++++++++++ .../Provider/AbstractScriptDataProviderTest.php | 10 ++++++++++ .../AbstractIntlDateFormatterTest.php | 12 ++++++++++++ src/Symfony/Component/Intl/Tests/IntlTest.php | 16 ++++++++++++++++ .../AbstractNumberFormatterTest.php | 2 +- .../Component/Stopwatch/Tests/StopwatchTest.php | 2 +- .../Translation/Loader/CsvFileLoader.php | 4 ++++ .../Translation/Tests/IdentityTranslatorTest.php | 16 ++++++++++++++++ .../Tests/Constraints/CountryValidatorTest.php | 16 ++++++++++++++++ .../Tests/Constraints/CurrencyValidatorTest.php | 16 ++++++++++++++++ .../Tests/Constraints/LanguageValidatorTest.php | 16 ++++++++++++++++ .../Tests/Constraints/RangeValidatorTest.php | 4 ++-- .../Tests/Caster/ExceptionCasterTest.php | 7 ++----- 23 files changed, 166 insertions(+), 23 deletions(-) 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; From 1a83f9beedf92c4a1cb1a7ea05ce857d6e20f62a Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Wed, 7 Aug 2019 13:13:33 +0200 Subject: [PATCH 2/2] Fix inconsistent return points. --- src/Symfony/Bridge/Monolog/Logger.php | 2 + .../SecurityBundle/Security/FirewallMap.php | 6 ++- src/Symfony/Component/Console/Terminal.php | 52 +++++++++---------- .../Compiler/AutowirePass.php | 12 +++-- .../Loader/XmlFileLoader.php | 2 +- .../Component/HttpKernel/HttpCache/Store.php | 13 +++-- .../PropertyAccess/PropertyAccessor.php | 2 + .../Routing/Loader/XmlFileLoader.php | 4 +- .../Component/Serializer/Serializer.php | 4 ++ 9 files changed, 57 insertions(+), 40 deletions(-) diff --git a/src/Symfony/Bridge/Monolog/Logger.php b/src/Symfony/Bridge/Monolog/Logger.php index a8b31cc09b..a88b46fd78 100644 --- a/src/Symfony/Bridge/Monolog/Logger.php +++ b/src/Symfony/Bridge/Monolog/Logger.php @@ -73,5 +73,7 @@ class Logger extends BaseLogger implements DebugLoggerInterface return $handler; } } + + return null; } } diff --git a/src/Symfony/Bundle/SecurityBundle/Security/FirewallMap.php b/src/Symfony/Bundle/SecurityBundle/Security/FirewallMap.php index 599f9050af..3bb16b26c7 100644 --- a/src/Symfony/Bundle/SecurityBundle/Security/FirewallMap.php +++ b/src/Symfony/Bundle/SecurityBundle/Security/FirewallMap.php @@ -135,14 +135,14 @@ class _FirewallMap $context = $this->getFirewallContext($request); if (null === $context) { - return; + return null; } return $context->getConfig(); } /** - * @return FirewallContext + * @return FirewallContext|null */ private function getFirewallContext(Request $request) { @@ -164,5 +164,7 @@ class _FirewallMap return $this->container->get($contextId); } } + + return null; } } diff --git a/src/Symfony/Component/Console/Terminal.php b/src/Symfony/Component/Console/Terminal.php index 456cca11ca..56eb050964 100644 --- a/src/Symfony/Component/Console/Terminal.php +++ b/src/Symfony/Component/Console/Terminal.php @@ -87,25 +87,13 @@ class Terminal */ private static function getConsoleMode() { - if (!\function_exists('proc_open')) { - return; + $info = self::readFromProcess('mode CON'); + + if (null === $info || !preg_match('/--------+\r?\n.+?(\d+)\r?\n.+?(\d+)\r?\n/', $info, $matches)) { + return null; } - $descriptorspec = [ - 1 => ['pipe', 'w'], - 2 => ['pipe', 'w'], - ]; - $process = proc_open('mode CON', $descriptorspec, $pipes, null, null, ['suppress_errors' => true]); - if (\is_resource($process)) { - $info = stream_get_contents($pipes[1]); - fclose($pipes[1]); - fclose($pipes[2]); - proc_close($process); - - if (preg_match('/--------+\r?\n.+?(\d+)\r?\n.+?(\d+)\r?\n/', $info, $matches)) { - return [(int) $matches[2], (int) $matches[1]]; - } - } + return [(int) $matches[2], (int) $matches[1]]; } /** @@ -114,9 +102,19 @@ class Terminal * @return string|null */ private static function getSttyColumns() + { + return self::readFromProcess('stty -a | grep columns'); + } + + /** + * @param string $command + * + * @return string|null + */ + private static function readFromProcess($command) { if (!\function_exists('proc_open')) { - return; + return null; } $descriptorspec = [ @@ -124,14 +122,16 @@ class Terminal 2 => ['pipe', 'w'], ]; - $process = proc_open('stty -a | grep columns', $descriptorspec, $pipes, null, null, ['suppress_errors' => true]); - if (\is_resource($process)) { - $info = stream_get_contents($pipes[1]); - fclose($pipes[1]); - fclose($pipes[2]); - proc_close($process); - - return $info; + $process = proc_open($command, $descriptorspec, $pipes, null, null, ['suppress_errors' => true]); + if (!\is_resource($process)) { + return null; } + + $info = stream_get_contents($pipes[1]); + fclose($pipes[1]); + fclose($pipes[2]); + proc_close($process); + + return $info; } } diff --git a/src/Symfony/Component/DependencyInjection/Compiler/AutowirePass.php b/src/Symfony/Component/DependencyInjection/Compiler/AutowirePass.php index c8e7a0f575..f2a5b46993 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/AutowirePass.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/AutowirePass.php @@ -318,7 +318,7 @@ class AutowirePass extends AbstractRecursivePass } if (!$reference->canBeAutoregistered() || isset($this->types[$type]) || isset($this->ambiguousServiceTypes[$type])) { - return; + return null; } if (isset($this->autowired[$type])) { @@ -328,6 +328,8 @@ class AutowirePass extends AbstractRecursivePass if (!$this->strictMode) { return $this->createAutowiredDefinition($type); } + + return null; } /** @@ -425,7 +427,7 @@ class AutowirePass extends AbstractRecursivePass private function createAutowiredDefinition($type) { if (!($typeHint = $this->container->getReflectionClass($type, false)) || !$typeHint->isInstantiable()) { - return; + return null; } $currentId = $this->currentId; @@ -445,7 +447,7 @@ class AutowirePass extends AbstractRecursivePass $this->lastFailure = $e->getMessage(); $this->container->log($this, $this->lastFailure); - return; + return null; } finally { $this->throwOnAutowiringException = $originalThrowSetting; $this->currentId = $currentId; @@ -518,7 +520,7 @@ class AutowirePass extends AbstractRecursivePass } elseif ($reference->getRequiringClass() && !$reference->canBeAutoregistered() && !$this->strictMode) { return ' It cannot be auto-registered because it is from a different root namespace.'; } else { - return; + return ''; } return sprintf(' You should maybe alias this %s to %s.', class_exists($type, false) ? 'class' : 'interface', $message); @@ -572,5 +574,7 @@ class AutowirePass extends AbstractRecursivePass if ($aliases) { return sprintf('Try changing the type-hint%s to "%s" instead.', $extraContext, $aliases[0]); } + + return null; } } diff --git a/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php b/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php index 718592d8ec..60102eaa8c 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php +++ b/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php @@ -211,7 +211,7 @@ class XmlFileLoader extends FileLoader $alias->setPublic($defaults['public']); } - return; + return null; } if ($this->isLoadingInstanceof) { diff --git a/src/Symfony/Component/HttpKernel/HttpCache/Store.php b/src/Symfony/Component/HttpKernel/HttpCache/Store.php index ffd4f01aea..d0eeb16529 100644 --- a/src/Symfony/Component/HttpKernel/HttpCache/Store.php +++ b/src/Symfony/Component/HttpKernel/HttpCache/Store.php @@ -134,7 +134,7 @@ class Store implements StoreInterface $key = $this->getCacheKey($request); if (!$entries = $this->getMetadata($key)) { - return; + return null; } // find a cached entry that matches the request. @@ -148,7 +148,7 @@ class Store implements StoreInterface } if (null === $match) { - return; + return null; } $headers = $match[1]; @@ -159,6 +159,7 @@ class Store implements StoreInterface // TODO the metaStore referenced an entity that doesn't exist in // the entityStore. We definitely want to return nil but we should // also purge the entry from the meta-store when this is detected. + return null; } /** @@ -180,7 +181,7 @@ class Store implements StoreInterface if (!$response->headers->has('X-Content-Digest')) { $digest = $this->generateContentDigest($response); - if (false === $this->save($digest, $response->getContent())) { + if (!$this->save($digest, $response->getContent())) { throw new \RuntimeException('Unable to store the entity.'); } @@ -209,7 +210,7 @@ class Store implements StoreInterface array_unshift($entries, [$storedEnv, $headers]); - if (false === $this->save($key, serialize($entries))) { + if (!$this->save($key, serialize($entries))) { throw new \RuntimeException('Unable to store the metadata.'); } @@ -248,7 +249,7 @@ class Store implements StoreInterface } } - if ($modified && false === $this->save($key, serialize($entries))) { + if ($modified && !$this->save($key, serialize($entries))) { throw new \RuntimeException('Unable to store the metadata.'); } } @@ -408,6 +409,8 @@ class Store implements StoreInterface } @chmod($path, 0666 & ~umask()); + + return true; } public function getPath($key) diff --git a/src/Symfony/Component/PropertyAccess/PropertyAccessor.php b/src/Symfony/Component/PropertyAccess/PropertyAccessor.php index 83b0f1ce13..e36211bd65 100644 --- a/src/Symfony/Component/PropertyAccess/PropertyAccessor.php +++ b/src/Symfony/Component/PropertyAccess/PropertyAccessor.php @@ -840,6 +840,8 @@ class PropertyAccessor implements PropertyAccessorInterface return [$addMethod, $removeMethod]; } } + + return null; } /** diff --git a/src/Symfony/Component/Routing/Loader/XmlFileLoader.php b/src/Symfony/Component/Routing/Loader/XmlFileLoader.php index 444a08a776..c114310fc3 100644 --- a/src/Symfony/Component/Routing/Loader/XmlFileLoader.php +++ b/src/Symfony/Component/Routing/Loader/XmlFileLoader.php @@ -261,7 +261,7 @@ class XmlFileLoader extends FileLoader private function parseDefaultsConfig(\DOMElement $element, $path) { if ($this->isElementValueNull($element)) { - return; + return null; } // Check for existing element nodes in the default element. There can @@ -298,7 +298,7 @@ class XmlFileLoader extends FileLoader private function parseDefaultNode(\DOMElement $node, $path) { if ($this->isElementValueNull($node)) { - return; + return null; } switch ($node->localName) { diff --git a/src/Symfony/Component/Serializer/Serializer.php b/src/Symfony/Component/Serializer/Serializer.php index f63cf67bdf..fd6b7dd059 100644 --- a/src/Symfony/Component/Serializer/Serializer.php +++ b/src/Symfony/Component/Serializer/Serializer.php @@ -243,6 +243,8 @@ class Serializer implements SerializerInterface, NormalizerInterface, Denormaliz return $normalizer; } } + + return null; } /** @@ -262,6 +264,8 @@ class Serializer implements SerializerInterface, NormalizerInterface, Denormaliz return $normalizer; } } + + return null; } /**