From 234d4053307da970ea57c711a969b600fa8107d9 Mon Sep 17 00:00:00 2001 From: connor Date: Sat, 23 Mar 2024 07:22:02 +0100 Subject: [PATCH 1/7] [action] improvement: use null coalescing operator --- lib/action/sfAction.class.php | 10 +--------- lib/action/sfActionStack.class.php | 25 +++---------------------- 2 files changed, 4 insertions(+), 31 deletions(-) diff --git a/lib/action/sfAction.class.php b/lib/action/sfAction.class.php index cabab27f0..d2fb5f86c 100644 --- a/lib/action/sfAction.class.php +++ b/lib/action/sfAction.class.php @@ -388,15 +388,7 @@ public function getSecurityValue($name, $default = null) { $actionName = strtolower($this->getActionName()); - if (isset($this->security[$actionName][$name])) { - return $this->security[$actionName][$name]; - } - - if (isset($this->security['all'][$name])) { - return $this->security['all'][$name]; - } - - return $default; + return $this->security[$actionName][$name] ?? $this->security['all'][$name] ?? $default; } /** diff --git a/lib/action/sfActionStack.class.php b/lib/action/sfActionStack.class.php index 09242f6ef..9952a6694 100644 --- a/lib/action/sfActionStack.class.php +++ b/lib/action/sfActionStack.class.php @@ -49,13 +49,7 @@ public function addEntry($moduleName, $actionName, $actionInstance) */ public function getEntry($index) { - $retval = null; - - if ($index > -1 && $index < count($this->stack)) { - $retval = $this->stack[$index]; - } - - return $retval; + return $this->stack[$index] ?? null; } /** @@ -75,13 +69,7 @@ public function popEntry() */ public function getFirstEntry() { - $retval = null; - - if (isset($this->stack[0])) { - $retval = $this->stack[0]; - } - - return $retval; + return $this->stack[0] ?? null; } /** @@ -91,14 +79,7 @@ public function getFirstEntry() */ public function getLastEntry() { - $count = count($this->stack); - $retval = null; - - if (isset($this->stack[0])) { - $retval = $this->stack[$count - 1]; - } - - return $retval; + return $this->stack[count($this->stack) - 1] ?? null; } /** From 2ddb388529892f951db6f04501d8ed499eaaad78 Mon Sep 17 00:00:00 2001 From: connor Date: Sat, 23 Mar 2024 07:45:37 +0100 Subject: [PATCH 2/7] [rector] improvement: use null coalescing operator --- lib/action/sfAction.class.php | 8 ++-- lib/autoload/sfAutoload.class.php | 2 +- lib/autoload/sfSimpleAutoload.class.php | 2 +- lib/cache/sfCache.class.php | 4 +- lib/cache/sfMemcacheCache.class.php | 6 +-- lib/cache/sfSQLiteCache.class.php | 6 +-- lib/command/sfCommandApplication.class.php | 12 ++--- lib/command/sfCommandLogger.class.php | 2 +- lib/config/sfAutoloadConfigHandler.class.php | 6 +-- lib/config/sfConfig.class.php | 2 +- lib/config/sfFactoryConfigHandler.class.php | 2 +- lib/config/sfFilterConfigHandler.class.php | 2 +- lib/config/sfGeneratorConfigHandler.class.php | 8 ++-- lib/config/sfPluginConfiguration.class.php | 2 +- lib/config/sfProjectConfiguration.class.php | 2 +- lib/config/sfRoutingConfigHandler.class.php | 14 +++--- lib/config/sfYamlConfigHandler.class.php | 2 +- lib/debug/sfWebDebug.class.php | 4 +- lib/debug/sfWebDebugPanel.class.php | 10 ++--- .../sfOutputEscaperArrayDecorator.class.php | 2 +- lib/exception/data/error.html.php | 2 +- lib/exception/data/unavailable.php | 2 +- lib/exception/sfError404Exception.class.php | 2 +- lib/exception/sfException.class.php | 14 +++--- lib/filter/sfExecutionFilter.class.php | 2 +- lib/form/sfForm.class.php | 16 +++---- lib/form/sfFormField.class.php | 2 +- lib/form/sfFormFieldSchema.class.php | 4 +- lib/generator/sfModelGenerator.class.php | 14 +++--- .../sfModelGeneratorConfiguration.class.php | 44 +++++++++---------- ...ModelGeneratorConfigurationField.class.php | 12 ++--- lib/helper/AssetHelper.php | 6 +-- lib/helper/I18NHelper.php | 8 ++-- lib/helper/JavascriptBaseHelper.php | 2 +- lib/helper/PartialHelper.php | 2 +- lib/helper/UrlHelper.php | 8 ++-- lib/i18n/sfI18N.class.php | 14 +++--- lib/log/sfFileLogger.class.php | 4 +- lib/log/sfLogger.class.php | 2 +- lib/log/sfVarLogger.class.php | 4 +- lib/log/sfWebDebugLogger.class.php | 2 +- lib/mailer/sfMailer.class.php | 2 +- lib/plugin/sfPearEnvironment.class.php | 2 +- lib/plugin/sfPearRest10.class.php | 2 +- lib/plugin/sfPearRest11.class.php | 2 +- lib/plugin/sfPearRestPlugin.class.php | 2 +- lib/plugin/sfPluginManager.class.php | 18 ++++---- lib/plugin/sfSymfonyPluginManager.class.php | 2 +- .../admin/parts/actionsConfiguration.php | 16 +++---- .../admin/parts/configuration.php | 6 +-- .../admin/parts/fieldsConfiguration.php | 20 ++++----- .../admin/parts/paginationConfiguration.php | 4 +- .../admin/parts/sortingConfiguration.php | 6 +-- .../sfDoctrineConnectionProfiler.class.php | 2 +- .../lib/form/sfFormDoctrine.class.php | 4 +- .../lib/generator/sfDoctrineColumn.class.php | 2 +- .../generator/sfDoctrineGenerator.class.php | 8 ++-- .../task/sfDoctrineBuildFiltersTask.class.php | 4 +- .../task/sfDoctrineBuildFormsTask.class.php | 4 +- .../task/sfDoctrineBuildModelTask.class.php | 4 +- .../sfDoctrineConfigureDatabaseTask.class.php | 2 +- .../lib/task/sfDoctrineDqlTask.class.php | 2 +- .../sfDoctrineGenerateAdminTask.class.php | 2 +- .../sfDoctrineGenerateModuleTask.class.php | 4 +- .../sfWidgetFormDoctrineChoice.class.php | 2 +- .../test/bootstrap/functional.php | 4 +- lib/request/sfRequest.class.php | 2 +- lib/request/sfWebRequest.class.php | 18 ++++---- lib/response/sfWebResponse.class.php | 22 +++++----- lib/routing/sfObjectRoute.class.php | 2 +- lib/routing/sfObjectRouteCollection.class.php | 2 +- lib/routing/sfRouting.class.php | 6 +-- lib/storage/sfCacheSessionStorage.class.php | 6 +-- lib/storage/sfSessionStorage.class.php | 2 +- lib/storage/sfSessionTestStorage.class.php | 2 +- .../generator/sfGenerateModuleTask.class.php | 4 +- .../generator/sfGenerateTaskTask.class.php | 2 +- lib/task/log/sfLogRotateTask.class.php | 4 +- lib/task/sfBaseTask.class.php | 2 +- lib/task/sfTask.class.php | 2 +- lib/test/sfTestBrowser.class.php | 2 +- lib/test/sfTestFunctionalBase.class.php | 14 +++--- lib/test/sfTesterResponse.class.php | 4 +- lib/user/sfUser.class.php | 2 +- lib/util/sfBrowserBase.class.php | 8 ++-- lib/util/sfContext.class.php | 16 +++---- lib/util/sfDomCssSelector.class.php | 2 +- lib/util/sfToolkit.class.php | 2 +- lib/validator/sfValidatedFile.class.php | 2 +- lib/validator/sfValidatorBase.class.php | 6 +-- lib/validator/sfValidatorDateRange.class.php | 4 +- lib/validator/sfValidatorError.class.php | 2 +- .../sfValidatorErrorSchema.class.php | 2 +- .../sfValidatorFromDescription.class.php | 4 +- lib/validator/sfValidatorSchema.class.php | 2 +- .../sfValidatorSchemaCompare.class.php | 4 +- .../sfValidatorSchemaFilter.class.php | 2 +- lib/vendor/lime/lime.php | 6 +-- lib/view/sfViewCacheManager.class.php | 12 ++--- lib/view/sfViewParameterHolder.class.php | 4 +- .../sfWidgetFormI18nChoiceCountry.class.php | 6 +-- .../sfWidgetFormI18nChoiceCurrency.class.php | 6 +-- .../sfWidgetFormI18nChoiceLanguage.class.php | 6 +-- .../sfWidgetFormI18nChoiceTimezone.class.php | 4 +- .../i18n/sfWidgetFormI18nDate.class.php | 4 +- .../i18n/sfWidgetFormI18nDateTime.class.php | 2 +- .../i18n/sfWidgetFormI18nTime.class.php | 2 +- lib/widget/sfWidget.class.php | 4 +- lib/widget/sfWidgetForm.class.php | 2 +- lib/widget/sfWidgetFormDateTime.class.php | 2 +- lib/widget/sfWidgetFormSchema.class.php | 10 ++--- .../sfWidgetFormSchemaFormatter.class.php | 2 +- lib/yaml/sfYamlParser.class.php | 2 +- test/bootstrap/functional.php | 4 +- .../templates/_anotherCacheablePartial.php | 4 +- .../cache/templates/_cacheableComponent.php | 2 +- .../cache/templates/_cacheablePartial.php | 2 +- .../modules/cache/templates/_component.php | 2 +- .../_contextualCacheableComponent.php | 2 +- .../templates/_contextualCacheablePartial.php | 2 +- .../cache/templates/_contextualComponent.php | 2 +- test/unit/cache/sfFunctionCacheTest.php | 2 +- test/unit/util/sfBrowserTest.php | 2 +- test/unit/view/sfViewCacheManagerTest.php | 2 +- 124 files changed, 322 insertions(+), 322 deletions(-) diff --git a/lib/action/sfAction.class.php b/lib/action/sfAction.class.php index d2fb5f86c..28d020e81 100644 --- a/lib/action/sfAction.class.php +++ b/lib/action/sfAction.class.php @@ -290,7 +290,7 @@ public function getPartial($templateName, $vars = null) { $this->getContext()->getConfiguration()->loadHelpers('Partial'); - $vars = null !== $vars ? $vars : $this->varHolder->getAll(); + $vars ??= $this->varHolder->getAll(); return get_partial($templateName, $vars); } @@ -333,7 +333,7 @@ public function getComponent($moduleName, $componentName, $vars = null) { $this->getContext()->getConfiguration()->loadHelpers('Partial'); - $vars = null !== $vars ? $vars : $this->varHolder->getAll(); + $vars ??= $this->varHolder->getAll(); return get_component($moduleName, $componentName, $vars); } @@ -422,7 +422,7 @@ public function getCredential() public function setTemplate($name, $module = null) { if (sfConfig::get('sf_logging_enabled')) { - $this->dispatcher->notify(new sfEvent($this, 'application.log', [sprintf('Change template to "%s/%s"', null === $module ? 'CURRENT' : $module, $name)])); + $this->dispatcher->notify(new sfEvent($this, 'application.log', [sprintf('Change template to "%s/%s"', $module ?? 'CURRENT', $name)])); } if (null !== $module) { @@ -508,6 +508,6 @@ public function getRoute() */ protected function get404Message($message = null) { - return null === $message ? sprintf('This request has been forwarded to a 404 error page by the action "%s/%s".', $this->getModuleName(), $this->getActionName()) : $message; + return $message ?? sprintf('This request has been forwarded to a 404 error page by the action "%s/%s".', $this->getModuleName(), $this->getActionName()); } } diff --git a/lib/autoload/sfAutoload.class.php b/lib/autoload/sfAutoload.class.php index de53e724c..1985b1b7d 100644 --- a/lib/autoload/sfAutoload.class.php +++ b/lib/autoload/sfAutoload.class.php @@ -90,7 +90,7 @@ public function getClassPath($class) { $class = strtolower($class); - return isset($this->classes[$class]) ? $this->classes[$class] : null; + return $this->classes[$class] ?? null; } /** diff --git a/lib/autoload/sfSimpleAutoload.class.php b/lib/autoload/sfSimpleAutoload.class.php index 85674e7a0..fad08b7b9 100755 --- a/lib/autoload/sfSimpleAutoload.class.php +++ b/lib/autoload/sfSimpleAutoload.class.php @@ -279,7 +279,7 @@ public function getClassPath($class) { $class = strtolower($class); - return isset($this->classes[$class]) ? $this->classes[$class] : null; + return $this->classes[$class] ?? null; } /** diff --git a/lib/cache/sfCache.class.php b/lib/cache/sfCache.class.php index 60b9a2858..aca6746d4 100644 --- a/lib/cache/sfCache.class.php +++ b/lib/cache/sfCache.class.php @@ -166,7 +166,7 @@ public function getMany($keys) */ public function getLifetime($lifetime) { - return null === $lifetime ? $this->getOption('lifetime') : $lifetime; + return $lifetime ?? $this->getOption('lifetime'); } /** @@ -191,7 +191,7 @@ public function getBackend() */ public function getOption($name, $default = null) { - return isset($this->options[$name]) ? $this->options[$name] : $default; + return $this->options[$name] ?? $default; } /** diff --git a/lib/cache/sfMemcacheCache.class.php b/lib/cache/sfMemcacheCache.class.php index 0caae1753..057b4d8c5 100644 --- a/lib/cache/sfMemcacheCache.class.php +++ b/lib/cache/sfMemcacheCache.class.php @@ -50,8 +50,8 @@ public function initialize($options = []) if ($this->getOption('servers')) { foreach ($this->getOption('servers') as $server) { - $port = isset($server['port']) ? $server['port'] : 11211; - if (!$this->memcache->addServer($server['host'], $port, isset($server['persistent']) ? $server['persistent'] : true)) { + $port = $server['port'] ?? 11211; + if (!$this->memcache->addServer($server['host'], $port, $server['persistent'] ?? true)) { throw new sfInitializationException(sprintf('Unable to connect to the memcache server (%s:%s).', $server['host'], $port)); } } @@ -106,7 +106,7 @@ public function has($key) */ public function set($key, $data, $lifetime = null) { - $lifetime = null === $lifetime ? $this->getOption('lifetime') : $lifetime; + $lifetime ??= $this->getOption('lifetime'); // save metadata $this->setMetadata($key, $lifetime); diff --git a/lib/cache/sfSQLiteCache.class.php b/lib/cache/sfSQLiteCache.class.php index 30484ad2d..788be5e53 100644 --- a/lib/cache/sfSQLiteCache.class.php +++ b/lib/cache/sfSQLiteCache.class.php @@ -70,7 +70,7 @@ public function get($key, $default = null) $data = $this->dbh->singleQuery(sprintf("SELECT data FROM cache WHERE key = '%s' AND timeout > %d", sqlite_escape_string($key), time())); } - return null === $data ? $default : $data; + return $data ?? $default; } /** @@ -153,7 +153,7 @@ public function getTimeout($key) if ($this->isSqLite3()) { $rs = $this->dbh->querySingle(sprintf("SELECT timeout FROM cache WHERE key = '%s' AND timeout > %d", $this->dbh->escapeString($key), time())); - return null === $rs ? 0 : $rs; + return $rs ?? 0; } $rs = $this->dbh->query(sprintf("SELECT timeout FROM cache WHERE key = '%s' AND timeout > %d", sqlite_escape_string($key), time())); @@ -169,7 +169,7 @@ public function getLastModified($key) if ($this->isSqLite3()) { $rs = $this->dbh->querySingle(sprintf("SELECT last_modified FROM cache WHERE key = '%s' AND timeout > %d", $this->dbh->escapeString($key), time())); - return null === $rs ? 0 : $rs; + return $rs ?? 0; } $rs = $this->dbh->query(sprintf("SELECT last_modified FROM cache WHERE key = '%s' AND timeout > %d", sqlite_escape_string($key), time())); diff --git a/lib/command/sfCommandApplication.class.php b/lib/command/sfCommandApplication.class.php index 15bad631d..b57ea28a6 100644 --- a/lib/command/sfCommandApplication.class.php +++ b/lib/command/sfCommandApplication.class.php @@ -63,7 +63,7 @@ abstract class sfCommandApplication public function __construct(sfEventDispatcher $dispatcher, ?sfFormatter $formatter = null, $options = []) { $this->dispatcher = $dispatcher; - $this->formatter = null === $formatter ? $this->guessBestFormatter(STDOUT) : $formatter; + $this->formatter = $formatter ?? $this->guessBestFormatter(STDOUT); $this->options = $options; $this->fixCgi(); @@ -100,7 +100,7 @@ abstract public function configure(); */ public function getOption($name) { - return isset($this->options[$name]) ? $this->options[$name] : null; + return $this->options[$name] ?? null; } /** @@ -396,11 +396,11 @@ public function renderException($e) ]); for ($i = 0, $count = count($trace); $i < $count; ++$i) { - $class = isset($trace[$i]['class']) ? $trace[$i]['class'] : ''; - $type = isset($trace[$i]['type']) ? $trace[$i]['type'] : ''; + $class = $trace[$i]['class'] ?? ''; + $type = $trace[$i]['type'] ?? ''; $function = $trace[$i]['function']; - $file = isset($trace[$i]['file']) ? $trace[$i]['file'] : 'n/a'; - $line = isset($trace[$i]['line']) ? $trace[$i]['line'] : 'n/a'; + $file = $trace[$i]['file'] ?? 'n/a'; + $line = $trace[$i]['line'] ?? 'n/a'; fwrite(STDERR, sprintf(" %s%s%s at %s:%s\n", $class, $type, $function, $this->formatter->format($file, 'INFO', STDERR), $this->formatter->format($line, 'INFO', STDERR))); } diff --git a/lib/command/sfCommandLogger.class.php b/lib/command/sfCommandLogger.class.php index 77673b5c1..ae3178853 100644 --- a/lib/command/sfCommandLogger.class.php +++ b/lib/command/sfCommandLogger.class.php @@ -33,7 +33,7 @@ public function initialize(sfEventDispatcher $dispatcher, $options = []) */ public function listenToLogEvent(sfEvent $event) { - $priority = isset($event['priority']) ? $event['priority'] : self::INFO; + $priority = $event['priority'] ?? self::INFO; $prefix = ''; if ('application.log' == $event->getName()) { diff --git a/lib/config/sfAutoloadConfigHandler.class.php b/lib/config/sfAutoloadConfigHandler.class.php index 2b7cb7a5c..20b5257e4 100755 --- a/lib/config/sfAutoloadConfigHandler.class.php +++ b/lib/config/sfAutoloadConfigHandler.class.php @@ -134,7 +134,7 @@ protected function parse(array $configFiles) } } else { // directory mapping - $ext = isset($entry['ext']) ? $entry['ext'] : '.php'; + $ext = $entry['ext'] ?? '.php'; $path = $entry['path']; // we automatically add our php classes @@ -142,7 +142,7 @@ protected function parse(array $configFiles) $finder = sfFinder::type('file')->name('*'.$ext)->follow_link(); // recursive mapping? - $recursive = isset($entry['recursive']) ? $entry['recursive'] : false; + $recursive = $entry['recursive'] ?? false; if (!$recursive) { $finder->maxdepth(0); } @@ -154,7 +154,7 @@ protected function parse(array $configFiles) if ($matches = glob($path)) { foreach ($finder->in($matches) as $file) { - $mapping = array_merge($mapping, $this->parseFile($path, $file, isset($entry['prefix']) ? $entry['prefix'] : '')); + $mapping = array_merge($mapping, $this->parseFile($path, $file, $entry['prefix'] ?? '')); } } } diff --git a/lib/config/sfConfig.class.php b/lib/config/sfConfig.class.php index 2ad673ea7..9040d89ee 100644 --- a/lib/config/sfConfig.class.php +++ b/lib/config/sfConfig.class.php @@ -27,7 +27,7 @@ class sfConfig */ public static function get($name, $default = null) { - return isset(self::$config[$name]) ? self::$config[$name] : $default; + return self::$config[$name] ?? $default; } /** diff --git a/lib/config/sfFactoryConfigHandler.class.php b/lib/config/sfFactoryConfigHandler.class.php index 95e067f7b..548095b00 100644 --- a/lib/config/sfFactoryConfigHandler.class.php +++ b/lib/config/sfFactoryConfigHandler.class.php @@ -97,7 +97,7 @@ public function execute($configFiles) $defaultParameters = []; $defaultParameters[] = sprintf("'auto_shutdown' => false, 'session_id' => \$this->getRequest()->getParameter('%s'),", $parameters['session_name']); if (is_subclass_of($class, 'sfDatabaseSessionStorage')) { - $defaultParameters[] = sprintf("'database' => \$this->getDatabaseManager()->getDatabase('%s'),", isset($parameters['database']) ? $parameters['database'] : 'default'); + $defaultParameters[] = sprintf("'database' => \$this->getDatabaseManager()->getDatabase('%s'),", $parameters['database'] ?? 'default'); unset($parameters['database']); } diff --git a/lib/config/sfFilterConfigHandler.class.php b/lib/config/sfFilterConfigHandler.class.php index d9d221e27..8461b4668 100644 --- a/lib/config/sfFilterConfigHandler.class.php +++ b/lib/config/sfFilterConfigHandler.class.php @@ -68,7 +68,7 @@ public function execute($configFiles) unset($keys['param']['condition']); } - $type = isset($keys['param']['type']) ? $keys['param']['type'] : null; + $type = $keys['param']['type'] ?? null; unset($keys['param']['type']); if ($condition) { diff --git a/lib/config/sfGeneratorConfigHandler.class.php b/lib/config/sfGeneratorConfigHandler.class.php index 32279c9c1..3b5f28397 100644 --- a/lib/config/sfGeneratorConfigHandler.class.php +++ b/lib/config/sfGeneratorConfigHandler.class.php @@ -35,18 +35,18 @@ public function execute($configFiles) } if (!isset($config['generator'])) { - throw new sfParseException(sprintf('Configuration file "%s" must specify a generator section.', isset($configFiles[1]) ? $configFiles[1] : $configFiles[0])); + throw new sfParseException(sprintf('Configuration file "%s" must specify a generator section.', $configFiles[1] ?? $configFiles[0])); } $config = $config['generator']; if (!isset($config['class'])) { - throw new sfParseException(sprintf('Configuration file "%s" must specify a generator class section under the generator section.', isset($configFiles[1]) ? $configFiles[1] : $configFiles[0])); + throw new sfParseException(sprintf('Configuration file "%s" must specify a generator class section under the generator section.', $configFiles[1] ?? $configFiles[0])); } foreach (['fields', 'list', 'edit'] as $section) { if (isset($config[$section])) { - throw new sfParseException(sprintf('Configuration file "%s" can specify a "%s" section but only under the param section.', isset($configFiles[1]) ? $configFiles[1] : $configFiles[0], $section)); + throw new sfParseException(sprintf('Configuration file "%s" can specify a "%s" section but only under the param section.', $configFiles[1] ?? $configFiles[0], $section)); } } @@ -54,7 +54,7 @@ public function execute($configFiles) $generatorManager = new sfGeneratorManager(sfContext::getInstance()->getConfiguration()); // generator parameters - $generatorParam = (isset($config['param']) ? $config['param'] : []); + $generatorParam = ($config['param'] ?? []); // hack to find the module name (look for the last /modules/ in path) preg_match('#.*/modules/([^/]+)/#', str_replace('\\', '/', $configFiles[0]), $match); diff --git a/lib/config/sfPluginConfiguration.class.php b/lib/config/sfPluginConfiguration.class.php index aa80e077d..5d1ba422c 100644 --- a/lib/config/sfPluginConfiguration.class.php +++ b/lib/config/sfPluginConfiguration.class.php @@ -32,7 +32,7 @@ public function __construct(sfProjectConfiguration $configuration, $rootDir = nu $this->configuration = $configuration; $this->dispatcher = $configuration->getEventDispatcher(); $this->rootDir = null === $rootDir ? $this->guessRootDir() : realpath($rootDir); - $this->name = null === $name ? $this->guessName() : $name; + $this->name = $name ?? $this->guessName(); $this->setup(); $this->configure(); diff --git a/lib/config/sfProjectConfiguration.class.php b/lib/config/sfProjectConfiguration.class.php index 68f006e20..17aea4eff 100644 --- a/lib/config/sfProjectConfiguration.class.php +++ b/lib/config/sfProjectConfiguration.class.php @@ -56,7 +56,7 @@ public function __construct($rootDir = null, ?sfEventDispatcher $dispatcher = nu $this->rootDir = null === $rootDir ? static::guessRootDir() : realpath($rootDir); $this->symfonyLibDir = realpath(__DIR__.'/..'); - $this->dispatcher = null === $dispatcher ? new sfEventDispatcher() : $dispatcher; + $this->dispatcher = $dispatcher ?? new sfEventDispatcher(); ini_set('magic_quotes_runtime', 'off'); diff --git a/lib/config/sfRoutingConfigHandler.class.php b/lib/config/sfRoutingConfigHandler.class.php index f917bd4ab..91541962e 100644 --- a/lib/config/sfRoutingConfigHandler.class.php +++ b/lib/config/sfRoutingConfigHandler.class.php @@ -91,17 +91,17 @@ protected function parse($configFiles) (isset($params['type']) && 'collection' == $params['type']) || (isset($params['class']) && false !== strpos($params['class'], 'Collection')) ) { - $options = isset($params['options']) ? $params['options'] : []; + $options = $params['options'] ?? []; $options['name'] = $name; - $options['requirements'] = isset($params['requirements']) ? $params['requirements'] : []; + $options['requirements'] = $params['requirements'] ?? []; - $routes[$name] = [isset($params['class']) ? $params['class'] : 'sfRouteCollection', [$options]]; + $routes[$name] = [$params['class'] ?? 'sfRouteCollection', [$options]]; } else { - $routes[$name] = [isset($params['class']) ? $params['class'] : 'sfRoute', [ + $routes[$name] = [$params['class'] ?? 'sfRoute', [ $params['url'] ?: '/', - isset($params['params']) ? $params['params'] : (isset($params['param']) ? $params['param'] : []), - isset($params['requirements']) ? $params['requirements'] : [], - isset($params['options']) ? $params['options'] : [], + $params['params'] ?? $params['param'] ?? [], + $params['requirements'] ?? [], + $params['options'] ?? [], ]]; } } diff --git a/lib/config/sfYamlConfigHandler.class.php b/lib/config/sfYamlConfigHandler.class.php index d1ea1e798..018435c46 100644 --- a/lib/config/sfYamlConfigHandler.class.php +++ b/lib/config/sfYamlConfigHandler.class.php @@ -69,7 +69,7 @@ public static function parseYaml($configFile) throw new sfParseException(sprintf('Configuration file "%s" could not be parsed', $configFile)); } - return null === $config ? [] : $config; + return $config ?? []; } public static function flattenConfiguration($config) diff --git a/lib/debug/sfWebDebug.class.php b/lib/debug/sfWebDebug.class.php index 3e1d2258b..0a83f0614 100644 --- a/lib/debug/sfWebDebug.class.php +++ b/lib/debug/sfWebDebug.class.php @@ -134,7 +134,7 @@ public function removePanel($name) */ public function getOption($name, $default = null) { - return isset($this->options[$name]) ? $this->options[$name] : $default; + return $this->options[$name] ?? $default; } /** @@ -178,7 +178,7 @@ public function injectToolbar($content) */ public function asHtml() { - $current = isset($this->options['request_parameters']['sfWebDebugPanel']) ? $this->options['request_parameters']['sfWebDebugPanel'] : null; + $current = $this->options['request_parameters']['sfWebDebugPanel'] ?? null; $titles = []; $panels = []; diff --git a/lib/debug/sfWebDebugPanel.class.php b/lib/debug/sfWebDebugPanel.class.php index 487feac49..c1399e843 100644 --- a/lib/debug/sfWebDebugPanel.class.php +++ b/lib/debug/sfWebDebugPanel.class.php @@ -112,8 +112,8 @@ public function getToggleableDebugStack($debugStack) $html = $this->getToggler($element, 'Toggle debug stack'); $html .= '