diff --git a/.travis.yml b/.travis.yml index b5e7eb9ecd..373a61f732 100644 --- a/.travis.yml +++ b/.travis.yml @@ -190,7 +190,7 @@ install: export SYMFONY_DEPRECATIONS_HELPER=weak && cp composer.json composer.json.orig && echo -e '{\n"require":{'"$(grep phpunit-bridge composer.json)"'"php":"*"},"minimum-stability":"dev"}' > composer.json && - php .github/build-packages.php HEAD^ $COMPONENTS && + php .github/build-packages.php HEAD^ $(find src/Symfony -mindepth 3 -type f -name composer.json -printf '%h\n') && mv composer.json composer.json.phpunit && mv composer.json.orig composer.json fi diff --git a/src/Symfony/Bridge/Twig/AppVariable.php b/src/Symfony/Bridge/Twig/AppVariable.php index 7c1a8f18f2..44fc3d41d5 100644 --- a/src/Symfony/Bridge/Twig/AppVariable.php +++ b/src/Symfony/Bridge/Twig/AppVariable.php @@ -112,10 +112,9 @@ class AppVariable if (null === $this->requestStack) { throw new \RuntimeException('The "app.session" variable is not available.'); } + $request = $this->getRequest(); - if ($request = $this->getRequest()) { - return $request->getSession(); - } + return $request && $request->hasSession() ? $request->getSession() : null; } /** @@ -157,8 +156,7 @@ class AppVariable public function getFlashes($types = null) { try { - $session = $this->getSession(); - if (null === $session) { + if (null === $session = $this->getSession()) { return []; } } catch (\RuntimeException $e) { diff --git a/src/Symfony/Bridge/Twig/Tests/AppVariableTest.php b/src/Symfony/Bridge/Twig/Tests/AppVariableTest.php index 53b84b2d1b..b6699e5cdc 100644 --- a/src/Symfony/Bridge/Twig/Tests/AppVariableTest.php +++ b/src/Symfony/Bridge/Twig/Tests/AppVariableTest.php @@ -51,6 +51,7 @@ class AppVariableTest extends TestCase public function testGetSession() { $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock(); + $request->method('hasSession')->willReturn(true); $request->method('getSession')->willReturn($session = new Session()); $this->setRequestStack($request); @@ -267,6 +268,7 @@ class AppVariableTest extends TestCase $session->method('getFlashBag')->willReturn($flashBag); $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock(); + $request->method('hasSession')->willReturn(true); $request->method('getSession')->willReturn($session); $this->setRequestStack($request); diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php index 6765f66e6c..b1da089cfd 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php @@ -1016,7 +1016,7 @@ class FrameworkExtension extends Extension } $defaultDir = $container->getParameterBag()->resolveValue($config['default_path']); foreach ($container->getParameter('kernel.bundles_metadata') as $name => $bundle) { - if (is_dir($dir = $bundle['path'].'/Resources/translations')) { + if ($container->fileExists($dir = $bundle['path'].'/Resources/translations')) { $dirs[] = $dir; } else { $nonExistingDirs[] = $dir; @@ -1024,7 +1024,7 @@ class FrameworkExtension extends Extension } foreach ($config['paths'] as $dir) { - if (is_dir($dir)) { + if ($container->fileExists($dir)) { $dirs[] = $transPaths[] = $dir; } else { throw new \UnexpectedValueException(sprintf('%s defined in translator.paths does not exist or is not a directory', $dir)); @@ -1039,7 +1039,7 @@ class FrameworkExtension extends Extension $container->getDefinition('console.command.translation_update')->replaceArgument(6, $transPaths); } - if (is_dir($defaultDir)) { + if ($container->fileExists($defaultDir)) { $dirs[] = $defaultDir; } else { $nonExistingDirs[] = $defaultDir; diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php index e75dbf359f..220bff1764 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php @@ -26,8 +26,6 @@ use Symfony\Component\Cache\Adapter\FilesystemAdapter; use Symfony\Component\Cache\Adapter\ProxyAdapter; use Symfony\Component\Cache\Adapter\RedisAdapter; use Symfony\Component\Cache\DependencyInjection\CachePoolPass; -use Symfony\Component\Config\Resource\DirectoryResource; -use Symfony\Component\Config\Resource\FileExistenceResource; use Symfony\Component\DependencyInjection\ChildDefinition; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use Symfony\Component\DependencyInjection\Compiler\ResolveInstanceofConditionalsPass; @@ -745,17 +743,6 @@ abstract class FrameworkExtensionTest extends TestCase ); $this->assertNotEmpty($nonExistingDirectories, 'FrameworkBundle should pass non existing directories to Translator'); - - $resources = $container->getResources(); - foreach ($resources as $resource) { - if ($resource instanceof DirectoryResource) { - $this->assertNotContains('translations', $resource->getResource()); - } - - if ($resource instanceof FileExistenceResource) { - $this->assertNotContains('translations', $resource->getResource()); - } - } } public function testTranslatorMultipleFallbacks() diff --git a/src/Symfony/Bundle/WebProfilerBundle/Controller/ProfilerController.php b/src/Symfony/Bundle/WebProfilerBundle/Controller/ProfilerController.php index be067b7af2..fde54c9b65 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Controller/ProfilerController.php +++ b/src/Symfony/Bundle/WebProfilerBundle/Controller/ProfilerController.php @@ -117,7 +117,7 @@ class ProfilerController throw new NotFoundHttpException('The profiler must be enabled.'); } - if ($request->hasSession() && ($session = $request->getSession()) && $session->isStarted() && $session->getFlashBag() instanceof AutoExpireFlashBag) { + if ($request->hasSession() && ($session = $request->getSession())->isStarted() && $session->getFlashBag() instanceof AutoExpireFlashBag) { // keep current flashes for one more request if using AutoExpireFlashBag $session->getFlashBag()->setAll($session->getFlashBag()->peekAll()); } diff --git a/src/Symfony/Bundle/WebProfilerBundle/EventListener/WebDebugToolbarListener.php b/src/Symfony/Bundle/WebProfilerBundle/EventListener/WebDebugToolbarListener.php index 075891c81d..e960d9b38b 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/EventListener/WebDebugToolbarListener.php +++ b/src/Symfony/Bundle/WebProfilerBundle/EventListener/WebDebugToolbarListener.php @@ -88,8 +88,7 @@ class WebDebugToolbarListener implements EventSubscriberInterface } if ($response->headers->has('X-Debug-Token') && $response->isRedirect() && $this->interceptRedirects && 'html' === $request->getRequestFormat()) { - $session = $request->getSession(); - if (null !== $session && $session->isStarted() && $session->getFlashBag() instanceof AutoExpireFlashBag) { + if ($request->hasSession() && ($session = $request->getSession())->isStarted() && $session->getFlashBag() instanceof AutoExpireFlashBag) { // keep current flashes for one more request if using AutoExpireFlashBag $session->getFlashBag()->setAll($session->getFlashBag()->peekAll()); } diff --git a/src/Symfony/Component/Cache/Adapter/AbstractAdapter.php b/src/Symfony/Component/Cache/Adapter/AbstractAdapter.php index 7d54922f39..2f91434575 100644 --- a/src/Symfony/Component/Cache/Adapter/AbstractAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/AbstractAdapter.php @@ -44,7 +44,7 @@ abstract class AbstractAdapter implements AdapterInterface, CacheInterface, Logg throw new InvalidArgumentException(sprintf('Namespace must be %d chars max, %d given ("%s")', $this->maxIdLength - 24, \strlen($namespace), $namespace)); } $this->createCacheItem = \Closure::bind( - function ($key, $value, $isHit) use ($defaultLifetime) { + static function ($key, $value, $isHit) use ($defaultLifetime) { $item = new CacheItem(); $item->key = $key; $item->value = $v = $value; @@ -67,7 +67,7 @@ abstract class AbstractAdapter implements AdapterInterface, CacheInterface, Logg ); $getId = \Closure::fromCallable([$this, 'getId']); $this->mergeByLifetime = \Closure::bind( - function ($deferred, $namespace, &$expiredIds) use ($getId) { + static function ($deferred, $namespace, &$expiredIds) use ($getId) { $byLifetime = []; $now = microtime(true); $expiredIds = []; diff --git a/src/Symfony/Component/Cache/Adapter/ArrayAdapter.php b/src/Symfony/Component/Cache/Adapter/ArrayAdapter.php index 3a237bb30a..b7d7151121 100644 --- a/src/Symfony/Component/Cache/Adapter/ArrayAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/ArrayAdapter.php @@ -37,7 +37,7 @@ class ArrayAdapter implements AdapterInterface, CacheInterface, LoggerAwareInter { $this->storeSerialized = $storeSerialized; $this->createCacheItem = \Closure::bind( - function ($key, $value, $isHit) use ($defaultLifetime) { + static function ($key, $value, $isHit) use ($defaultLifetime) { $item = new CacheItem(); $item->key = $key; $item->value = $value; diff --git a/src/Symfony/Component/Cache/Adapter/ChainAdapter.php b/src/Symfony/Component/Cache/Adapter/ChainAdapter.php index 2ab47f47ea..d023aeedbd 100644 --- a/src/Symfony/Component/Cache/Adapter/ChainAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/ChainAdapter.php @@ -61,7 +61,7 @@ class ChainAdapter implements AdapterInterface, CacheInterface, PruneableInterfa $this->adapterCount = \count($this->adapters); $this->syncItem = \Closure::bind( - function ($sourceItem, $item) use ($defaultLifetime) { + static function ($sourceItem, $item) use ($defaultLifetime) { $item->value = $sourceItem->value; $item->expiry = $sourceItem->expiry; $item->isHit = $sourceItem->isHit; diff --git a/src/Symfony/Component/Cache/Adapter/PhpArrayAdapter.php b/src/Symfony/Component/Cache/Adapter/PhpArrayAdapter.php index ca4294e646..7b9a4a426a 100644 --- a/src/Symfony/Component/Cache/Adapter/PhpArrayAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/PhpArrayAdapter.php @@ -48,7 +48,7 @@ class PhpArrayAdapter implements AdapterInterface, CacheInterface, PruneableInte $this->file = $file; $this->pool = $fallbackPool; $this->createCacheItem = \Closure::bind( - function ($key, $value, $isHit) { + static function ($key, $value, $isHit) { $item = new CacheItem(); $item->key = $key; $item->value = $value; diff --git a/src/Symfony/Component/Cache/Adapter/ProxyAdapter.php b/src/Symfony/Component/Cache/Adapter/ProxyAdapter.php index 75d0d60a45..e0404d054a 100644 --- a/src/Symfony/Component/Cache/Adapter/ProxyAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/ProxyAdapter.php @@ -41,7 +41,7 @@ class ProxyAdapter implements AdapterInterface, CacheInterface, PruneableInterfa $this->namespace = '' === $namespace ? '' : CacheItem::validateKey($namespace); $this->namespaceLen = \strlen($namespace); $this->createCacheItem = \Closure::bind( - function ($key, $innerItem) use ($defaultLifetime, $poolHash) { + static function ($key, $innerItem) use ($defaultLifetime, $poolHash) { $item = new CacheItem(); $item->key = $key; @@ -77,7 +77,7 @@ class ProxyAdapter implements AdapterInterface, CacheInterface, PruneableInterfa /** * @param array $item A CacheItem cast to (array); accessing protected properties requires adding the "\0*\0" PHP prefix */ - function (CacheItemInterface $innerItem, array $item) { + static function (CacheItemInterface $innerItem, array $item) { // Tags are stored separately, no need to account for them when considering this item's newly set metadata if (isset(($metadata = $item["\0*\0newMetadata"])[CacheItem::METADATA_TAGS])) { unset($metadata[CacheItem::METADATA_TAGS]); diff --git a/src/Symfony/Component/Cache/Adapter/TagAwareAdapter.php b/src/Symfony/Component/Cache/Adapter/TagAwareAdapter.php index 3a04dc01f1..f17bd3b73c 100644 --- a/src/Symfony/Component/Cache/Adapter/TagAwareAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/TagAwareAdapter.php @@ -45,7 +45,7 @@ class TagAwareAdapter implements TagAwareAdapterInterface, TagAwareCacheInterfac $this->tags = $tagsPool ?: $itemsPool; $this->knownTagVersionsTtl = $knownTagVersionsTtl; $this->createCacheItem = \Closure::bind( - function ($key, $value, CacheItem $protoItem) { + static function ($key, $value, CacheItem $protoItem) { $item = new CacheItem(); $item->key = $key; $item->value = $value; @@ -59,7 +59,7 @@ class TagAwareAdapter implements TagAwareAdapterInterface, TagAwareCacheInterfac CacheItem::class ); $this->setCacheItemTags = \Closure::bind( - function (CacheItem $item, $key, array &$itemTags) { + static function (CacheItem $item, $key, array &$itemTags) { $item->isTaggable = true; if (!$item->isHit) { return $item; @@ -80,7 +80,7 @@ class TagAwareAdapter implements TagAwareAdapterInterface, TagAwareCacheInterfac CacheItem::class ); $this->getTagsByKey = \Closure::bind( - function ($deferred) { + static function ($deferred) { $tagsByKey = []; foreach ($deferred as $key => $item) { $tagsByKey[$key] = $item->newMetadata[CacheItem::METADATA_TAGS] ?? []; @@ -92,7 +92,7 @@ class TagAwareAdapter implements TagAwareAdapterInterface, TagAwareCacheInterfac CacheItem::class ); $this->invalidateTags = \Closure::bind( - function (AdapterInterface $tagsAdapter, array $tags) { + static function (AdapterInterface $tagsAdapter, array $tags) { foreach ($tags as $v) { $v->defaultLifetime = 0; $v->expiry = null; diff --git a/src/Symfony/Component/Cache/Psr16Cache.php b/src/Symfony/Component/Cache/Psr16Cache.php index 589ffa0d8b..d67615eb77 100644 --- a/src/Symfony/Component/Cache/Psr16Cache.php +++ b/src/Symfony/Component/Cache/Psr16Cache.php @@ -42,7 +42,7 @@ class Psr16Cache implements CacheInterface, PruneableInterface, ResettableInterf } $cacheItemPrototype = &$this->cacheItemPrototype; $createCacheItem = \Closure::bind( - function ($key, $value, $allowInt = false) use (&$cacheItemPrototype) { + static function ($key, $value, $allowInt = false) use (&$cacheItemPrototype) { $item = clone $cacheItemPrototype; $item->key = $allowInt && \is_int($key) ? (string) $key : CacheItem::validateKey($key); $item->value = $value; diff --git a/src/Symfony/Component/Cache/Traits/ContractsTrait.php b/src/Symfony/Component/Cache/Traits/ContractsTrait.php index d9514d3965..7f99f65fdf 100644 --- a/src/Symfony/Component/Cache/Traits/ContractsTrait.php +++ b/src/Symfony/Component/Cache/Traits/ContractsTrait.php @@ -58,7 +58,7 @@ trait ContractsTrait static $setMetadata; $setMetadata = $setMetadata ?? \Closure::bind( - function (CacheItem $item, float $startTime, ?array &$metadata) { + static function (CacheItem $item, float $startTime, ?array &$metadata) { if ($item->expiry > $endTime = microtime(true)) { $item->newMetadata[CacheItem::METADATA_EXPIRY] = $metadata[CacheItem::METADATA_EXPIRY] = $item->expiry; $item->newMetadata[CacheItem::METADATA_CTIME] = $metadata[CacheItem::METADATA_CTIME] = 1000 * (int) ($endTime - $startTime); diff --git a/src/Symfony/Component/Config/Resource/ReflectionClassResource.php b/src/Symfony/Component/Config/Resource/ReflectionClassResource.php index 78a0abfceb..87b99af749 100644 --- a/src/Symfony/Component/Config/Resource/ReflectionClassResource.php +++ b/src/Symfony/Component/Config/Resource/ReflectionClassResource.php @@ -138,7 +138,7 @@ class ReflectionClassResource implements SelfCheckingResourceInterface foreach ($class->getProperties(\ReflectionProperty::IS_PUBLIC | \ReflectionProperty::IS_PROTECTED) as $p) { yield $p->getDocComment().$p; - yield print_r(isset($defaults[$p->name]) ? $defaults[$p->name] : null, true); + yield print_r(isset($defaults[$p->name]) && !\is_object($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 1cf8398a29..43a077f56c 100644 --- a/src/Symfony/Component/Config/Tests/Resource/ReflectionClassResourceTest.php +++ b/src/Symfony/Component/Config/Tests/Resource/ReflectionClassResourceTest.php @@ -185,6 +185,15 @@ EOPHP; $res = new ReflectionClassResource(new \ReflectionClass(TestServiceSubscriber::class)); $this->assertTrue($res->isFresh(0)); } + + public function testIgnoresObjectsInSignature() + { + $res = new ReflectionClassResource(new \ReflectionClass(TestServiceWithStaticProperty::class)); + $this->assertTrue($res->isFresh(0)); + + TestServiceWithStaticProperty::$initializedObject = new TestServiceWithStaticProperty(); + $this->assertTrue($res->isFresh(0)); + } } interface DummyInterface @@ -224,3 +233,8 @@ class TestServiceSubscriber implements ServiceSubscriberInterface return self::$subscribedServices; } } + +class TestServiceWithStaticProperty +{ + public static $initializedObject; +} diff --git a/src/Symfony/Component/Console/Input/ArrayInput.php b/src/Symfony/Component/Console/Input/ArrayInput.php index b409960440..ca51a48502 100644 --- a/src/Symfony/Component/Console/Input/ArrayInput.php +++ b/src/Symfony/Component/Console/Input/ArrayInput.php @@ -132,7 +132,7 @@ class ArrayInput extends Input } if (0 === strpos($key, '--')) { $this->addLongOption(substr($key, 2), $value); - } elseif ('-' === $key[0]) { + } elseif (0 === strpos($key, '-')) { $this->addShortOption(substr($key, 1), $value); } else { $this->addArgument($key, $value); diff --git a/src/Symfony/Component/DependencyInjection/Compiler/PassConfig.php b/src/Symfony/Component/DependencyInjection/Compiler/PassConfig.php index f11b148ea4..edb3032090 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/PassConfig.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/PassConfig.php @@ -51,15 +51,15 @@ class PassConfig $this->optimizationPasses = [[ new ValidateEnvPlaceholdersPass(), new ResolveChildDefinitionsPass(), - new ServiceLocatorTagPass(), new RegisterServiceSubscribersPass(), new DecoratorServicePass(), new ResolveParameterPlaceHoldersPass(false), new ResolveFactoryClassPass(), - new CheckDefinitionValidityPass(), new ResolveNamedArgumentsPass(), new AutowireRequiredMethodsPass(), new ResolveBindingsPass(), + new ServiceLocatorTagPass(), + new CheckDefinitionValidityPass(), new AutowirePass(false), new ResolveTaggedIteratorArgumentPass(), new ResolveServiceSubscribersPass(), diff --git a/src/Symfony/Component/HttpFoundation/File/UploadedFile.php b/src/Symfony/Component/HttpFoundation/File/UploadedFile.php index baf9c3a449..b7cd6a4e00 100644 --- a/src/Symfony/Component/HttpFoundation/File/UploadedFile.php +++ b/src/Symfony/Component/HttpFoundation/File/UploadedFile.php @@ -219,13 +219,26 @@ class UploadedFile extends File */ public static function getMaxFilesize() { - $iniMax = strtolower(ini_get('upload_max_filesize')); + $sizePostMax = self::parseFilesize(ini_get('post_max_size')); + $sizeUploadMax = self::parseFilesize(ini_get('upload_max_filesize')); - if ('' === $iniMax) { - return PHP_INT_MAX; + return min([$sizePostMax, $sizeUploadMax]); + } + + /** + * Returns the given size from an ini value in bytes. + * + * @return int The given size in bytes + */ + private static function parseFilesize($size) + { + if ('' === $size) { + return 0; } - $max = ltrim($iniMax, '+'); + $size = strtolower($size); + + $max = ltrim($size, '+'); if (0 === strpos($max, '0x')) { $max = \intval($max, 16); } elseif (0 === strpos($max, '0')) { @@ -234,7 +247,7 @@ class UploadedFile extends File $max = (int) $max; } - switch (substr($iniMax, -1)) { + switch (substr($size, -1)) { case 't': $max *= 1024; // no break case 'g': $max *= 1024; diff --git a/src/Symfony/Component/HttpKernel/EventListener/AbstractTestSessionListener.php b/src/Symfony/Component/HttpKernel/EventListener/AbstractTestSessionListener.php index b5d0f148cc..fa1e8a5fda 100644 --- a/src/Symfony/Component/HttpKernel/EventListener/AbstractTestSessionListener.php +++ b/src/Symfony/Component/HttpKernel/EventListener/AbstractTestSessionListener.php @@ -46,8 +46,7 @@ abstract class AbstractTestSessionListener implements EventSubscriberInterface } // bootstrap the session - $session = $this->getSession(); - if (!$session) { + if (!$session = $this->getSession()) { return; } diff --git a/src/Symfony/Component/HttpKernel/Fragment/InlineFragmentRenderer.php b/src/Symfony/Component/HttpKernel/Fragment/InlineFragmentRenderer.php index 6493fc86f6..3bbdbd3ce8 100644 --- a/src/Symfony/Component/HttpKernel/Fragment/InlineFragmentRenderer.php +++ b/src/Symfony/Component/HttpKernel/Fragment/InlineFragmentRenderer.php @@ -121,7 +121,7 @@ class InlineFragmentRenderer extends RoutableFragmentRenderer static $setSession; if (null === $setSession) { - $setSession = \Closure::bind(function ($subRequest, $request) { $subRequest->session = $request->session; }, null, Request::class); + $setSession = \Closure::bind(static function ($subRequest, $request) { $subRequest->session = $request->session; }, null, Request::class); } $setSession($subRequest, $request); diff --git a/src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php b/src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php index 982e8cdb9a..eb128b0521 100644 --- a/src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php +++ b/src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php @@ -98,8 +98,8 @@ class HttpCache implements HttpKernelInterface, TerminableInterface 'trace_header' => 'X-Symfony-Cache', ], $options); - if (!isset($options['trace_level']) && $this->options['debug']) { - $this->options['trace_level'] = 'full'; + if (!isset($options['trace_level'])) { + $this->options['trace_level'] = $this->options['debug'] ? 'full' : 'none'; } } diff --git a/src/Symfony/Component/Lock/BlockingStoreInterface.php b/src/Symfony/Component/Lock/BlockingStoreInterface.php index 162c9b3d41..15efaa2bdf 100644 --- a/src/Symfony/Component/Lock/BlockingStoreInterface.php +++ b/src/Symfony/Component/Lock/BlockingStoreInterface.php @@ -16,7 +16,7 @@ use Symfony\Component\Lock\Exception\LockConflictedException; /** * @author Hamza Amrouche */ -interface BlockingStoreInterface +interface BlockingStoreInterface extends PersistingStoreInterface { /** * Waits until a key becomes free, then stores the resource. diff --git a/src/Symfony/Component/Lock/Store/RetryTillSaveStore.php b/src/Symfony/Component/Lock/Store/RetryTillSaveStore.php index 81185f59eb..9a412810c2 100644 --- a/src/Symfony/Component/Lock/Store/RetryTillSaveStore.php +++ b/src/Symfony/Component/Lock/Store/RetryTillSaveStore.php @@ -26,7 +26,7 @@ use Symfony\Component\Lock\StoreInterface; * * @author Jérémy Derussé */ -class RetryTillSaveStore implements PersistingStoreInterface, BlockingStoreInterface, StoreInterface, LoggerAwareInterface +class RetryTillSaveStore implements BlockingStoreInterface, StoreInterface, LoggerAwareInterface { use LoggerAwareTrait; diff --git a/src/Symfony/Component/Lock/Tests/LockTest.php b/src/Symfony/Component/Lock/Tests/LockTest.php index 87331a64cf..1239ddba0f 100644 --- a/src/Symfony/Component/Lock/Tests/LockTest.php +++ b/src/Symfony/Component/Lock/Tests/LockTest.php @@ -97,7 +97,7 @@ class LockTest extends TestCase public function testAcquireBlocking() { $key = new Key(uniqid(__METHOD__, true)); - $store = $this->getMockBuilder([PersistingStoreInterface::class, BlockingStoreInterface::class])->getMock(); + $store = $this->createMock(BlockingStoreInterface::class); $lock = new Lock($key, $store); $store @@ -213,7 +213,7 @@ class LockTest extends TestCase public function testReleaseOnDestruction() { $key = new Key(uniqid(__METHOD__, true)); - $store = $this->getMockBuilder([PersistingStoreInterface::class, BlockingStoreInterface::class])->getMock(); + $store = $this->createMock(BlockingStoreInterface::class); $lock = new Lock($key, $store, 10); $store @@ -232,7 +232,7 @@ class LockTest extends TestCase public function testNoAutoReleaseWhenNotConfigured() { $key = new Key(uniqid(__METHOD__, true)); - $store = $this->getMockBuilder([PersistingStoreInterface::class, BlockingStoreInterface::class])->getMock(); + $store = $this->createMock(BlockingStoreInterface::class); $lock = new Lock($key, $store, 10, false); $store diff --git a/src/Symfony/Component/Lock/Tests/Store/CombinedStoreTest.php b/src/Symfony/Component/Lock/Tests/Store/CombinedStoreTest.php index 0f77d103d5..15ceb42bb5 100644 --- a/src/Symfony/Component/Lock/Tests/Store/CombinedStoreTest.php +++ b/src/Symfony/Component/Lock/Tests/Store/CombinedStoreTest.php @@ -62,8 +62,8 @@ class CombinedStoreTest extends AbstractStoreTest protected function setUp() { $this->strategy = $this->getMockBuilder(StrategyInterface::class)->getMock(); - $this->store1 = $this->getMockBuilder([PersistingStoreInterface::class, BlockingStoreInterface::class])->getMock(); - $this->store2 = $this->getMockBuilder([PersistingStoreInterface::class, BlockingStoreInterface::class])->getMock(); + $this->store1 = $this->createMock(BlockingStoreInterface::class); + $this->store2 = $this->createMock(BlockingStoreInterface::class); $this->store = new CombinedStore([$this->store1, $this->store2], $this->strategy); } diff --git a/src/Symfony/Component/Routing/Loader/PhpFileLoader.php b/src/Symfony/Component/Routing/Loader/PhpFileLoader.php index 7af543744e..31fe88ddd8 100644 --- a/src/Symfony/Component/Routing/Loader/PhpFileLoader.php +++ b/src/Symfony/Component/Routing/Loader/PhpFileLoader.php @@ -40,7 +40,7 @@ class PhpFileLoader extends FileLoader // the closure forbids access to the private scope in the included file $loader = $this; - $load = \Closure::bind(function ($file) use ($loader) { + $load = \Closure::bind(static function ($file) use ($loader) { return include $file; }, null, ProtectedPhpFileLoader::class); diff --git a/src/Symfony/Component/Security/Http/Authentication/AuthenticationUtils.php b/src/Symfony/Component/Security/Http/Authentication/AuthenticationUtils.php index fbdc0bc5eb..af7e4919c3 100644 --- a/src/Symfony/Component/Security/Http/Authentication/AuthenticationUtils.php +++ b/src/Symfony/Component/Security/Http/Authentication/AuthenticationUtils.php @@ -38,12 +38,11 @@ class AuthenticationUtils public function getLastAuthenticationError($clearSession = true) { $request = $this->getRequest(); - $session = $request->getSession(); $authenticationException = null; if ($request->attributes->has(Security::AUTHENTICATION_ERROR)) { $authenticationException = $request->attributes->get(Security::AUTHENTICATION_ERROR); - } elseif (null !== $session && $session->has(Security::AUTHENTICATION_ERROR)) { + } elseif ($request->hasSession() && ($session = $request->getSession())->has(Security::AUTHENTICATION_ERROR)) { $authenticationException = $session->get(Security::AUTHENTICATION_ERROR); if ($clearSession) { @@ -65,9 +64,7 @@ class AuthenticationUtils return $request->attributes->get(Security::LAST_USERNAME, ''); } - $session = $request->getSession(); - - return null === $session ? '' : $session->get(Security::LAST_USERNAME, ''); + return $request->hasSession() ? $request->getSession()->get(Security::LAST_USERNAME, '') : ''; } /** diff --git a/src/Symfony/Component/Security/Http/Firewall/ContextListener.php b/src/Symfony/Component/Security/Http/Firewall/ContextListener.php index 470d2a8dc4..09f170bf45 100644 --- a/src/Symfony/Component/Security/Http/Firewall/ContextListener.php +++ b/src/Symfony/Component/Security/Http/Firewall/ContextListener.php @@ -75,7 +75,7 @@ class ContextListener } $request = $event->getRequest(); - $session = $request->hasPreviousSession() ? $request->getSession() : null; + $session = $request->hasPreviousSession() && $request->hasSession() ? $request->getSession() : null; if (null === $session || null === $token = $session->get($this->sessionKey)) { $this->tokenStorage->setToken(null); @@ -122,14 +122,14 @@ class ContextListener $this->dispatcher->removeListener(KernelEvents::RESPONSE, [$this, 'onKernelResponse']); $this->registered = false; - $session = $request->getSession(); + $token = $this->tokenStorage->getToken(); - if ((null === $token = $this->tokenStorage->getToken()) || $this->trustResolver->isAnonymous($token)) { - if ($request->hasPreviousSession()) { - $session->remove($this->sessionKey); + if (null === $token || $this->trustResolver->isAnonymous($token)) { + if ($request->hasPreviousSession() && $request->hasSession()) { + $request->getSession()->remove($this->sessionKey); } } else { - $session->set($this->sessionKey, serialize($token)); + $request->getSession()->set($this->sessionKey, serialize($token)); if (null !== $this->logger) { $this->logger->debug('Stored the security token in the session.', ['key' => $this->sessionKey]); diff --git a/src/Symfony/Component/Security/Http/HttpUtils.php b/src/Symfony/Component/Security/Http/HttpUtils.php index b70ba80b78..b31117a06f 100644 --- a/src/Symfony/Component/Security/Http/HttpUtils.php +++ b/src/Symfony/Component/Security/Http/HttpUtils.php @@ -87,7 +87,7 @@ class HttpUtils static $setSession; if (null === $setSession) { - $setSession = \Closure::bind(function ($newRequest, $request) { $newRequest->session = $request->session; }, null, Request::class); + $setSession = \Closure::bind(static function ($newRequest, $request) { $newRequest->session = $request->session; }, null, Request::class); } $setSession($newRequest, $request); diff --git a/src/Symfony/Component/Yaml/Parser.php b/src/Symfony/Component/Yaml/Parser.php index 4a84b39521..c117ee470f 100644 --- a/src/Symfony/Component/Yaml/Parser.php +++ b/src/Symfony/Component/Yaml/Parser.php @@ -386,6 +386,9 @@ class Parser $value = ''; foreach ($this->lines as $line) { + if ('' !== ltrim($line) && '#' === ltrim($line)[0]) { + continue; + } // If the indentation is not consistent at offset 0, it is to be considered as a ParseError if (0 === $this->offset && !$deprecatedUsage && isset($line[0]) && ' ' === $line[0]) { throw new ParseException('Unable to parse.', $this->getRealCurrentLineNb() + 1, $this->currentLine, $this->filename); diff --git a/src/Symfony/Component/Yaml/Tests/ParserTest.php b/src/Symfony/Component/Yaml/Tests/ParserTest.php index 1bfd22cfe3..1626b54cd3 100644 --- a/src/Symfony/Component/Yaml/Tests/ParserTest.php +++ b/src/Symfony/Component/Yaml/Tests/ParserTest.php @@ -2152,6 +2152,18 @@ YAML; return $tests; } + + public function testMultiLineComment() + { + $yaml = <<assertSame(['parameters' => 'abc'], $this->parser->parse($yaml)); + } } class B