diff --git a/src/Symfony/Bridge/Doctrine/ContainerAwareEventManager.php b/src/Symfony/Bridge/Doctrine/ContainerAwareEventManager.php index 1ee4f54ded8e1..48385c93ac19e 100644 --- a/src/Symfony/Bridge/Doctrine/ContainerAwareEventManager.php +++ b/src/Symfony/Bridge/Doctrine/ContainerAwareEventManager.php @@ -54,7 +54,7 @@ public function dispatchEvent($eventName, EventArgs $eventArgs = null) return; } - $eventArgs = null === $eventArgs ? EventArgs::getEmptyInstance() : $eventArgs; + $eventArgs = $eventArgs ?? EventArgs::getEmptyInstance(); if (!isset($this->initialized[$eventName])) { $this->initializeListeners($eventName); diff --git a/src/Symfony/Bridge/Doctrine/Validator/Constraints/UniqueEntityValidator.php b/src/Symfony/Bridge/Doctrine/Validator/Constraints/UniqueEntityValidator.php index 399a18d90c7fe..df17e0eedd4c8 100644 --- a/src/Symfony/Bridge/Doctrine/Validator/Constraints/UniqueEntityValidator.php +++ b/src/Symfony/Bridge/Doctrine/Validator/Constraints/UniqueEntityValidator.php @@ -163,7 +163,7 @@ public function validate($entity, Constraint $constraint) return; } - $errorPath = null !== $constraint->errorPath ? $constraint->errorPath : $fields[0]; + $errorPath = $constraint->errorPath ?? $fields[0]; $invalidValue = $criteria[$errorPath] ?? $criteria[$fields[0]]; $this->context->buildViolation($constraint->message) diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/AssetsInstallCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/AssetsInstallCommand.php index f95907ddf5f1d..b81e0be294f88 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/AssetsInstallCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/AssetsInstallCommand.php @@ -278,10 +278,6 @@ private function getPublicDirectory(ContainerInterface $container): string $composerConfig = json_decode(file_get_contents($composerFilePath), true); - if (isset($composerConfig['extra']['public-dir'])) { - return $composerConfig['extra']['public-dir']; - } - - return $defaultPublicDir; + return $composerConfig['extra']['public-dir'] ?? $defaultPublicDir; } } diff --git a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/JsonDescriptor.php b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/JsonDescriptor.php index bb723deaaf5d2..039b3bd4f4c48 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/JsonDescriptor.php +++ b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/JsonDescriptor.php @@ -134,7 +134,7 @@ protected function describeContainerAlias(Alias $alias, array $options = [], Con protected function describeEventDispatcherListeners(EventDispatcherInterface $eventDispatcher, array $options = []) { - $this->writeData($this->getEventDispatcherListenersData($eventDispatcher, \array_key_exists('event', $options) ? $options['event'] : null), $options); + $this->writeData($this->getEventDispatcherListenersData($eventDispatcher, $options['event'] ?? null), $options); } protected function describeCallable($callable, array $options = []) diff --git a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/MarkdownDescriptor.php b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/MarkdownDescriptor.php index a04402796b4c5..53485437a354a 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/MarkdownDescriptor.php +++ b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/MarkdownDescriptor.php @@ -258,7 +258,7 @@ protected function describeContainerEnvVars(array $envs, array $options = []) protected function describeEventDispatcherListeners(EventDispatcherInterface $eventDispatcher, array $options = []) { - $event = \array_key_exists('event', $options) ? $options['event'] : null; + $event = $options['event'] ?? null; $title = 'Registered listeners'; if (null !== $event) { diff --git a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php index 1e27e073658bd..c0cd375a94221 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php +++ b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php @@ -442,7 +442,7 @@ protected function describeContainerEnvVars(array $envs, array $options = []) protected function describeEventDispatcherListeners(EventDispatcherInterface $eventDispatcher, array $options = []) { - $event = \array_key_exists('event', $options) ? $options['event'] : null; + $event = $options['event'] ?? null; if (null !== $event) { $title = sprintf('Registered Listeners for "%s" Event', $event); diff --git a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/XmlDescriptor.php b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/XmlDescriptor.php index e0ea8233f16ea..2d56bbf0e25dc 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/XmlDescriptor.php +++ b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/XmlDescriptor.php @@ -88,7 +88,7 @@ protected function describeContainerAlias(Alias $alias, array $options = [], Con protected function describeEventDispatcherListeners(EventDispatcherInterface $eventDispatcher, array $options = []) { - $this->writeDocument($this->getEventDispatcherListenersDocument($eventDispatcher, \array_key_exists('event', $options) ? $options['event'] : null)); + $this->writeDocument($this->getEventDispatcherListenersDocument($eventDispatcher, $options['event'] ?? null)); } protected function describeCallable($callable, array $options = []) diff --git a/src/Symfony/Bundle/FrameworkBundle/Controller/ControllerTrait.php b/src/Symfony/Bundle/FrameworkBundle/Controller/ControllerTrait.php index 99516b5c3fac6..8845e03d9a236 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Controller/ControllerTrait.php +++ b/src/Symfony/Bundle/FrameworkBundle/Controller/ControllerTrait.php @@ -144,7 +144,7 @@ protected function json($data, int $status = 200, array $headers = [], array $co protected function file($file, string $fileName = null, string $disposition = ResponseHeaderBag::DISPOSITION_ATTACHMENT): BinaryFileResponse { $response = new BinaryFileResponse($file); - $response->setContentDisposition($disposition, null === $fileName ? $response->getFile()->getFilename() : $fileName); + $response->setContentDisposition($disposition, $fileName ?? $response->getFile()->getFilename()); return $response; } diff --git a/src/Symfony/Component/Cache/Adapter/ArrayAdapter.php b/src/Symfony/Component/Cache/Adapter/ArrayAdapter.php index 5912ddb963c10..8fba15b32fd3b 100644 --- a/src/Symfony/Component/Cache/Adapter/ArrayAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/ArrayAdapter.php @@ -141,7 +141,7 @@ public function save(CacheItemInterface $item) } $this->values[$key] = $value; - $this->expiries[$key] = null !== $expiry ? $expiry : \PHP_INT_MAX; + $this->expiries[$key] = $expiry ?? \PHP_INT_MAX; return true; } diff --git a/src/Symfony/Component/Cache/Traits/RedisTrait.php b/src/Symfony/Component/Cache/Traits/RedisTrait.php index 517650b2d9644..4d7b7c4b200ef 100644 --- a/src/Symfony/Component/Cache/Traits/RedisTrait.php +++ b/src/Symfony/Component/Cache/Traits/RedisTrait.php @@ -172,7 +172,7 @@ public static function createConnection($dsn, array $options = []) if (null === $params['class'] && !isset($params['redis_sentinel']) && \extension_loaded('redis')) { $class = $params['redis_cluster'] ? \RedisCluster::class : (1 < \count($hosts) ? \RedisArray::class : \Redis::class); } else { - $class = null === $params['class'] ? \Predis\Client::class : $params['class']; + $class = $params['class'] ?? \Predis\Client::class; } if (is_a($class, \Redis::class, true)) { diff --git a/src/Symfony/Component/Console/Event/ConsoleErrorEvent.php b/src/Symfony/Component/Console/Event/ConsoleErrorEvent.php index 25d9b88127cff..57d9b38ba0c3b 100644 --- a/src/Symfony/Component/Console/Event/ConsoleErrorEvent.php +++ b/src/Symfony/Component/Console/Event/ConsoleErrorEvent.php @@ -53,6 +53,6 @@ public function setExitCode(int $exitCode): void public function getExitCode(): int { - return null !== $this->exitCode ? $this->exitCode : (\is_int($this->error->getCode()) && 0 !== $this->error->getCode() ? $this->error->getCode() : 1); + return $this->exitCode ?? (\is_int($this->error->getCode()) && 0 !== $this->error->getCode() ? $this->error->getCode() : 1); } } diff --git a/src/Symfony/Component/DependencyInjection/Compiler/MergeExtensionConfigurationPass.php b/src/Symfony/Component/DependencyInjection/Compiler/MergeExtensionConfigurationPass.php index 7fe14a9f4ccd0..9a7ac18e67ea7 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/MergeExtensionConfigurationPass.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/MergeExtensionConfigurationPass.php @@ -143,7 +143,7 @@ public function freezeAfterProcessing(Extension $extension, ContainerBuilder $co */ public function getEnvPlaceholders(): array { - return null !== $this->processedEnvPlaceholders ? $this->processedEnvPlaceholders : parent::getEnvPlaceholders(); + return $this->processedEnvPlaceholders ?? parent::getEnvPlaceholders(); } public function getUnusedEnvPlaceholders(): array diff --git a/src/Symfony/Component/DependencyInjection/ContainerBuilder.php b/src/Symfony/Component/DependencyInjection/ContainerBuilder.php index ef3af7165dec2..ca5a367e3c3b2 100644 --- a/src/Symfony/Component/DependencyInjection/ContainerBuilder.php +++ b/src/Symfony/Component/DependencyInjection/ContainerBuilder.php @@ -1630,7 +1630,7 @@ private function callMethod($service, array $call, array &$inlineServices) */ private function shareService(Definition $definition, $service, ?string $id, array &$inlineServices) { - $inlineServices[null !== $id ? $id : spl_object_hash($definition)] = $service; + $inlineServices[$id ?? spl_object_hash($definition)] = $service; if (null !== $id && $definition->isShared()) { $this->services[$id] = $service; diff --git a/src/Symfony/Component/Form/Extension/Core/DataTransformer/IntegerToLocalizedStringTransformer.php b/src/Symfony/Component/Form/Extension/Core/DataTransformer/IntegerToLocalizedStringTransformer.php index 7e0eeea2a50b0..4c85c2e957d38 100644 --- a/src/Symfony/Component/Form/Extension/Core/DataTransformer/IntegerToLocalizedStringTransformer.php +++ b/src/Symfony/Component/Form/Extension/Core/DataTransformer/IntegerToLocalizedStringTransformer.php @@ -34,7 +34,7 @@ public function __construct($grouping = false, $roundingMode = self::ROUND_DOWN, @trigger_error(sprintf('Passing a precision as the first value to %s::__construct() is deprecated since Symfony 4.2 and support for it will be dropped in 5.0.', __CLASS__), \E_USER_DEPRECATED); $grouping = $roundingMode; - $roundingMode = null !== $locale ? $locale : self::ROUND_DOWN; + $roundingMode = $locale ?? self::ROUND_DOWN; $locale = null; } diff --git a/src/Symfony/Component/Form/Extension/Core/Type/TextType.php b/src/Symfony/Component/Form/Extension/Core/Type/TextType.php index 9b3c59db85bb4..72d21c3dd98ae 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/TextType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/TextType.php @@ -62,6 +62,6 @@ public function transform($data) */ public function reverseTransform($data) { - return null === $data ? '' : $data; + return $data ?? ''; } } diff --git a/src/Symfony/Component/HttpFoundation/Request.php b/src/Symfony/Component/HttpFoundation/Request.php index cf6ebbc0b0903..d2e0f57e79533 100644 --- a/src/Symfony/Component/HttpFoundation/Request.php +++ b/src/Symfony/Component/HttpFoundation/Request.php @@ -1371,7 +1371,7 @@ public function getRequestFormat($default = 'html') $this->format = $this->attributes->get('_format'); } - return null === $this->format ? $default : $this->format; + return $this->format ?? $default; } /** diff --git a/src/Symfony/Component/HttpFoundation/RequestStack.php b/src/Symfony/Component/HttpFoundation/RequestStack.php index 244a77d631a8f..7e45a903e32ad 100644 --- a/src/Symfony/Component/HttpFoundation/RequestStack.php +++ b/src/Symfony/Component/HttpFoundation/RequestStack.php @@ -94,10 +94,6 @@ public function getParentRequest() { $pos = \count($this->requests) - 2; - if (!isset($this->requests[$pos])) { - return null; - } - - return $this->requests[$pos]; + return $this->requests[$pos] ?? null; } } diff --git a/src/Symfony/Component/HttpFoundation/ResponseHeaderBag.php b/src/Symfony/Component/HttpFoundation/ResponseHeaderBag.php index 3c5889cacf836..3dc5a801e3fc7 100644 --- a/src/Symfony/Component/HttpFoundation/ResponseHeaderBag.php +++ b/src/Symfony/Component/HttpFoundation/ResponseHeaderBag.php @@ -176,7 +176,7 @@ public function hasCacheControlDirective($key) */ public function getCacheControlDirective($key) { - return \array_key_exists($key, $this->computedCacheControl) ? $this->computedCacheControl[$key] : null; + return $this->computedCacheControl[$key] ?? null; } public function setCookie(Cookie $cookie) diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/MetadataBag.php b/src/Symfony/Component/HttpFoundation/Session/Storage/MetadataBag.php index c3090d7378b13..0146ee259b384 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/MetadataBag.php +++ b/src/Symfony/Component/HttpFoundation/Session/Storage/MetadataBag.php @@ -163,6 +163,6 @@ private function stampCreated(int $lifetime = null): void { $timeStamp = time(); $this->meta[self::CREATED] = $this->meta[self::UPDATED] = $this->lastUsed = $timeStamp; - $this->meta[self::LIFETIME] = (null === $lifetime) ? ini_get('session.cookie_lifetime') : $lifetime; + $this->meta[self::LIFETIME] = $lifetime ?? ini_get('session.cookie_lifetime'); } } diff --git a/src/Symfony/Component/HttpKernel/EventListener/DebugHandlersListener.php b/src/Symfony/Component/HttpKernel/EventListener/DebugHandlersListener.php index cfc277e330cb6..5027bd11698dd 100644 --- a/src/Symfony/Component/HttpKernel/EventListener/DebugHandlersListener.php +++ b/src/Symfony/Component/HttpKernel/EventListener/DebugHandlersListener.php @@ -60,7 +60,7 @@ public function __construct(callable $exceptionHandler = null, LoggerInterface $ $this->exceptionHandler = $exceptionHandler; $this->logger = $logger; - $this->levels = null === $levels ? \E_ALL : $levels; + $this->levels = $levels ?? \E_ALL; $this->throwAt = \is_int($throwAt) ? $throwAt : (null === $throwAt ? null : ($throwAt ? \E_ALL : null)); $this->scream = $scream; $this->fileLinkFormat = $fileLinkFormat; diff --git a/src/Symfony/Component/HttpKernel/Profiler/Profile.php b/src/Symfony/Component/HttpKernel/Profiler/Profile.php index ac5b5044c1e79..88e82b4e2fb9e 100644 --- a/src/Symfony/Component/HttpKernel/Profiler/Profile.php +++ b/src/Symfony/Component/HttpKernel/Profiler/Profile.php @@ -156,11 +156,7 @@ public function setUrl($url) */ public function getTime() { - if (null === $this->time) { - return 0; - } - - return $this->time; + return $this->time ?? 0; } /** diff --git a/src/Symfony/Component/HttpKernel/Tests/KernelTest.php b/src/Symfony/Component/HttpKernel/Tests/KernelTest.php index 63fb4973f6566..ec57289ddeadf 100644 --- a/src/Symfony/Component/HttpKernel/Tests/KernelTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/KernelTest.php @@ -709,7 +709,7 @@ protected function getBundle($dir = null, $parent = null, $className = null, $bu $bundle ->expects($this->any()) ->method('getName') - ->willReturn(null === $bundleName ? \get_class($bundle) : $bundleName) + ->willReturn($bundleName ?? \get_class($bundle)) ; $bundle diff --git a/src/Symfony/Component/Intl/DateFormatter/IntlDateFormatter.php b/src/Symfony/Component/Intl/DateFormatter/IntlDateFormatter.php index 5011ee3321a32..bbcec903fe599 100644 --- a/src/Symfony/Component/Intl/DateFormatter/IntlDateFormatter.php +++ b/src/Symfony/Component/Intl/DateFormatter/IntlDateFormatter.php @@ -142,8 +142,8 @@ public function __construct(?string $locale, ?int $datetype, ?int $timetype, $ti throw new MethodArgumentValueNotImplementedException(__METHOD__, 'calendar', $calendar, 'Only the GREGORIAN calendar is supported'); } - $this->datetype = null !== $datetype ? $datetype : self::FULL; - $this->timetype = null !== $timetype ? $timetype : self::FULL; + $this->datetype = $datetype ?? self::FULL; + $this->timetype = $timetype ?? self::FULL; if ('' === ($pattern ?? '')) { $pattern = $this->getDefaultPattern(); diff --git a/src/Symfony/Component/Intl/Tests/DateFormatter/AbstractIntlDateFormatterTest.php b/src/Symfony/Component/Intl/Tests/DateFormatter/AbstractIntlDateFormatterTest.php index cee6b548a29fb..e6436bb0f6807 100644 --- a/src/Symfony/Component/Intl/Tests/DateFormatter/AbstractIntlDateFormatterTest.php +++ b/src/Symfony/Component/Intl/Tests/DateFormatter/AbstractIntlDateFormatterTest.php @@ -933,7 +933,7 @@ protected function getDefaultDateFormatter($pattern = null) protected function getDateTime($timestamp, $timeZone) { $dateTime = new \DateTime(); - $dateTime->setTimestamp(null === $timestamp ? time() : $timestamp); + $dateTime->setTimestamp($timestamp ?? time()); $dateTime->setTimezone(new \DateTimeZone($timeZone ?: getenv('TZ') ?: 'UTC')); return $dateTime; diff --git a/src/Symfony/Component/Intl/Util/GitRepository.php b/src/Symfony/Component/Intl/Util/GitRepository.php index 3f24c6a463736..a07419e950470 100644 --- a/src/Symfony/Component/Intl/Util/GitRepository.php +++ b/src/Symfony/Component/Intl/Util/GitRepository.php @@ -95,7 +95,7 @@ private static function exec(string $command, string $customErrorMessage = null) exec(sprintf('%s 2>&1', $command), $output, $result); if (0 !== $result) { - throw new RuntimeException(null !== $customErrorMessage ? $customErrorMessage : sprintf('The "%s" command failed.', $command)); + throw new RuntimeException($customErrorMessage ?? sprintf('The "%s" command failed.', $command)); } return $output; diff --git a/src/Symfony/Component/Messenger/Tests/WorkerTest.php b/src/Symfony/Component/Messenger/Tests/WorkerTest.php index 85f9db781be64..b5406b59ea3f6 100644 --- a/src/Symfony/Component/Messenger/Tests/WorkerTest.php +++ b/src/Symfony/Component/Messenger/Tests/WorkerTest.php @@ -260,7 +260,7 @@ public function get(): iterable { $val = array_shift($this->deliveriesOfEnvelopes); - return null === $val ? [] : $val; + return $val ?? []; } public function ack(Envelope $envelope): void diff --git a/src/Symfony/Component/PropertyInfo/Extractor/PhpDocExtractor.php b/src/Symfony/Component/PropertyInfo/Extractor/PhpDocExtractor.php index 2f36a017c5c0a..97c7b38f93836 100644 --- a/src/Symfony/Component/PropertyInfo/Extractor/PhpDocExtractor.php +++ b/src/Symfony/Component/PropertyInfo/Extractor/PhpDocExtractor.php @@ -66,9 +66,9 @@ public function __construct(DocBlockFactoryInterface $docBlockFactory = null, ar $this->docBlockFactory = $docBlockFactory ?: DocBlockFactory::createInstance(); $this->contextFactory = new ContextFactory(); $this->phpDocTypeHelper = new PhpDocTypeHelper(); - $this->mutatorPrefixes = null !== $mutatorPrefixes ? $mutatorPrefixes : ReflectionExtractor::$defaultMutatorPrefixes; - $this->accessorPrefixes = null !== $accessorPrefixes ? $accessorPrefixes : ReflectionExtractor::$defaultAccessorPrefixes; - $this->arrayMutatorPrefixes = null !== $arrayMutatorPrefixes ? $arrayMutatorPrefixes : ReflectionExtractor::$defaultArrayMutatorPrefixes; + $this->mutatorPrefixes = $mutatorPrefixes ?? ReflectionExtractor::$defaultMutatorPrefixes; + $this->accessorPrefixes = $accessorPrefixes ?? ReflectionExtractor::$defaultAccessorPrefixes; + $this->arrayMutatorPrefixes = $arrayMutatorPrefixes ?? ReflectionExtractor::$defaultArrayMutatorPrefixes; } /** diff --git a/src/Symfony/Component/PropertyInfo/Extractor/ReflectionExtractor.php b/src/Symfony/Component/PropertyInfo/Extractor/ReflectionExtractor.php index ebe9d070322e0..d3b9b721e9c5f 100644 --- a/src/Symfony/Component/PropertyInfo/Extractor/ReflectionExtractor.php +++ b/src/Symfony/Component/PropertyInfo/Extractor/ReflectionExtractor.php @@ -68,9 +68,9 @@ class ReflectionExtractor implements PropertyListExtractorInterface, PropertyTyp */ public function __construct(array $mutatorPrefixes = null, array $accessorPrefixes = null, array $arrayMutatorPrefixes = null, bool $enableConstructorExtraction = true, int $accessFlags = self::ALLOW_PUBLIC) { - $this->mutatorPrefixes = null !== $mutatorPrefixes ? $mutatorPrefixes : self::$defaultMutatorPrefixes; - $this->accessorPrefixes = null !== $accessorPrefixes ? $accessorPrefixes : self::$defaultAccessorPrefixes; - $this->arrayMutatorPrefixes = null !== $arrayMutatorPrefixes ? $arrayMutatorPrefixes : self::$defaultArrayMutatorPrefixes; + $this->mutatorPrefixes = $mutatorPrefixes ?? self::$defaultMutatorPrefixes; + $this->accessorPrefixes = $accessorPrefixes ?? self::$defaultAccessorPrefixes; + $this->arrayMutatorPrefixes = $arrayMutatorPrefixes ?? self::$defaultArrayMutatorPrefixes; $this->enableConstructorExtraction = $enableConstructorExtraction; $this->accessFlags = $accessFlags; diff --git a/src/Symfony/Component/Security/Http/Firewall/RememberMeListener.php b/src/Symfony/Component/Security/Http/Firewall/RememberMeListener.php index 441f70cc2fc05..d2df4a2bab3b9 100644 --- a/src/Symfony/Component/Security/Http/Firewall/RememberMeListener.php +++ b/src/Symfony/Component/Security/Http/Firewall/RememberMeListener.php @@ -58,7 +58,7 @@ public function __construct(TokenStorageInterface $tokenStorage, RememberMeServi } $this->catchExceptions = $catchExceptions; - $this->sessionStrategy = null === $sessionStrategy ? new SessionAuthenticationStrategy(SessionAuthenticationStrategy::MIGRATE) : $sessionStrategy; + $this->sessionStrategy = $sessionStrategy ?? new SessionAuthenticationStrategy(SessionAuthenticationStrategy::MIGRATE); } /** diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/ExceptionListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/ExceptionListenerTest.php index 46c48b6637881..27ad9897ea485 100644 --- a/src/Symfony/Component/Security/Http/Tests/Firewall/ExceptionListenerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Firewall/ExceptionListenerTest.php @@ -99,7 +99,7 @@ public function testAccessDeniedExceptionFullFledgedAndWithoutAccessDeniedHandle $listener->onKernelException($event); $this->assertNull($event->getResponse()); - $this->assertSame(null === $eventException ? $exception : $eventException, $event->getThrowable()->getPrevious()); + $this->assertSame($eventException ?? $exception, $event->getThrowable()->getPrevious()); } /** @@ -122,7 +122,7 @@ public function testAccessDeniedExceptionFullFledgedAndWithoutAccessDeniedHandle $this->assertEquals('Unauthorized', $event->getResponse()->getContent()); $this->assertEquals(401, $event->getResponse()->getStatusCode()); - $this->assertSame(null === $eventException ? $exception : $eventException, $event->getThrowable()->getPrevious()); + $this->assertSame($eventException ?? $exception, $event->getThrowable()->getPrevious()); } /** @@ -139,7 +139,7 @@ public function testAccessDeniedExceptionFullFledgedAndWithAccessDeniedHandlerAn $listener->onKernelException($event); $this->assertEquals('error', $event->getResponse()->getContent()); - $this->assertSame(null === $eventException ? $exception : $eventException, $event->getThrowable()->getPrevious()); + $this->assertSame($eventException ?? $exception, $event->getThrowable()->getPrevious()); } /** @@ -156,7 +156,7 @@ public function testAccessDeniedExceptionNotFullFledged(\Exception $exception, \ $listener->onKernelException($event); $this->assertEquals('OK', $event->getResponse()->getContent()); - $this->assertSame(null === $eventException ? $exception : $eventException, $event->getThrowable()->getPrevious()); + $this->assertSame($eventException ?? $exception, $event->getThrowable()->getPrevious()); } public function testLogoutException() diff --git a/src/Symfony/Component/Validator/Constraints/File.php b/src/Symfony/Component/Validator/Constraints/File.php index 690b873ea89b1..29844a4c95476 100644 --- a/src/Symfony/Component/Validator/Constraints/File.php +++ b/src/Symfony/Component/Validator/Constraints/File.php @@ -112,10 +112,10 @@ private function normalizeBinaryFormat($maxSize) ]; if (ctype_digit((string) $maxSize)) { $this->maxSize = (int) $maxSize; - $this->binaryFormat = null === $this->binaryFormat ? false : $this->binaryFormat; + $this->binaryFormat = $this->binaryFormat ?? false; } elseif (preg_match('/^(\d++)('.implode('|', array_keys($factors)).')$/i', $maxSize, $matches)) { $this->maxSize = $matches[1] * $factors[$unit = strtolower($matches[2])]; - $this->binaryFormat = null === $this->binaryFormat ? 2 === \strlen($unit) : $this->binaryFormat; + $this->binaryFormat = $this->binaryFormat ?? (2 === \strlen($unit)); } else { throw new ConstraintDefinitionException(sprintf('"%s" is not a valid maximum size.', $this->maxSize)); } diff --git a/src/Symfony/Component/Validator/Constraints/FileValidator.php b/src/Symfony/Component/Validator/Constraints/FileValidator.php index 3a4195ffbec54..cebb6eda29673 100644 --- a/src/Symfony/Component/Validator/Constraints/FileValidator.php +++ b/src/Symfony/Component/Validator/Constraints/FileValidator.php @@ -60,7 +60,7 @@ public function validate($value, Constraint $constraint) $binaryFormat = $constraint->binaryFormat; } else { $limitInBytes = $iniLimitSize; - $binaryFormat = null === $constraint->binaryFormat ? true : $constraint->binaryFormat; + $binaryFormat = $constraint->binaryFormat ?? true; } [, $limitAsString, $suffix] = $this->factorizeSizes(0, $limitInBytes, $binaryFormat); diff --git a/src/Symfony/Component/Validator/Mapping/ClassMetadata.php b/src/Symfony/Component/Validator/Mapping/ClassMetadata.php index beb1484f46349..55f05f59e7fa0 100644 --- a/src/Symfony/Component/Validator/Mapping/ClassMetadata.php +++ b/src/Symfony/Component/Validator/Mapping/ClassMetadata.php @@ -365,11 +365,7 @@ public function hasPropertyMetadata($property) */ public function getPropertyMetadata($property) { - if (!isset($this->members[$property])) { - return []; - } - - return $this->members[$property]; + return $this->members[$property] ?? []; } /** diff --git a/src/Symfony/Component/VarDumper/Dumper/AbstractDumper.php b/src/Symfony/Component/VarDumper/Dumper/AbstractDumper.php index eea56b599dbca..4ddaf5e74667a 100644 --- a/src/Symfony/Component/VarDumper/Dumper/AbstractDumper.php +++ b/src/Symfony/Component/VarDumper/Dumper/AbstractDumper.php @@ -63,7 +63,7 @@ public function __construct($output = null, string $charset = null, int $flags = */ public function setOutput($output) { - $prev = null !== $this->outputStream ? $this->outputStream : $this->lineDumper; + $prev = $this->outputStream ?? $this->lineDumper; if (\is_callable($output)) { $this->outputStream = null; diff --git a/src/Symfony/Component/VarDumper/Dumper/HtmlDumper.php b/src/Symfony/Component/VarDumper/Dumper/HtmlDumper.php index f1dedf6ac9f23..8409a0c741325 100644 --- a/src/Symfony/Component/VarDumper/Dumper/HtmlDumper.php +++ b/src/Symfony/Component/VarDumper/Dumper/HtmlDumper.php @@ -153,7 +153,7 @@ public function dump(Data $data, $output = null, array $extraDisplayOptions = [] */ protected function getDumpHeader() { - $this->headerIsDumped = null !== $this->outputStream ? $this->outputStream : $this->lineDumper; + $this->headerIsDumped = $this->outputStream ?? $this->lineDumper; if (null !== $this->dumpHeader) { return $this->dumpHeader; @@ -964,7 +964,7 @@ protected function dumpLine($depth, $endOfValue = false) if (-1 === $this->lastDepth) { $this->line = sprintf($this->dumpPrefix, $this->dumpId, $this->indentPad).$this->line; } - if ($this->headerIsDumped !== (null !== $this->outputStream ? $this->outputStream : $this->lineDumper)) { + if ($this->headerIsDumped !== ($this->outputStream ?? $this->lineDumper)) { $this->line = $this->getDumpHeader().$this->line; }