DX: apply rector rulesset up to PHP72

This commit is contained in:
2023-03-29 22:32:52 +02:00
parent 64b8ae3df1
commit b9a7530f7a
110 changed files with 194 additions and 229 deletions

View File

@@ -38,11 +38,7 @@ class MenuCompilerPass implements CompilerPassInterface
}
usort($services, static function ($a, $b) {
if ($a['priority'] === $b['priority']) {
return 0;
}
return ($a['priority'] < $b['priority']) ? -1 : 1;
return $a['priority'] <=> $b['priority'];
});
foreach ($services as $service) {

View File

@@ -34,7 +34,7 @@ class ShortMessageCompilerPass implements CompilerPassInterface
{
public function process(ContainerBuilder $container)
{
$config = $container->resolveEnvPlaceholders($container->getParameter('chill_main.short_messages', null), true);
$config = $container->resolveEnvPlaceholders($container->getParameter('chill_main.short_messages'), true);
// weird fix for special characters
$config['dsn'] = str_replace(['%%'], ['%'], $config['dsn']);
$dsn = parse_url($config['dsn']);
@@ -43,7 +43,7 @@ class ShortMessageCompilerPass implements CompilerPassInterface
if ('null' === $dsn['scheme'] || false === $config['enabled']) {
$defaultTransporter = new Reference(NullShortMessageSender::class);
} elseif ('ovh' === $dsn['scheme']) {
if (!class_exists('\Ovh\Api')) {
if (!class_exists('\\' . \Ovh\Api::class)) {
throw new RuntimeException('Class \\Ovh\\Api not found');
}
@@ -66,17 +66,17 @@ class ShortMessageCompilerPass implements CompilerPassInterface
$ovh = new Definition();
$ovh
->setClass('\Ovh\Api')
->setClass('\\' . \Ovh\Api::class)
->setArgument(0, $dsn['user'])
->setArgument(1, $dsn['pass'])
->setArgument(2, $dsn['host'])
->setArgument(3, $dsn['queries']['consumer_key']);
$container->setDefinition('Ovh\Api', $ovh);
$container->setDefinition(\Ovh\Api::class, $ovh);
$ovhSender = new Definition();
$ovhSender
->setClass(OvhShortMessageSender::class)
->setArgument(0, new Reference('Ovh\Api'))
->setArgument(0, new Reference(\Ovh\Api::class))
->setArgument(1, $dsn['queries']['service_name'])
->setArgument(2, $dsn['queries']['sender'])
->setArgument(3, new Reference(LoggerInterface::class))

View File

@@ -37,7 +37,7 @@ class Configuration implements ConfigurationInterface
public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder('chill_main');
$rootNode = $treeBuilder->getRootNode('chill_main');
$rootNode = $treeBuilder->getRootNode();
$rootNode
->children()

View File

@@ -193,8 +193,7 @@ abstract class AbstractWidgetsCompilerPass implements CompilerPassInterface
/** @var WidgetFactoryInterface $factory */
$factory = $this->widgetServices[$alias];
// get the config (under the key which equals to widget_alias
$config = isset($param[$factory->getWidgetAlias()]) ?
$param[$factory->getWidgetAlias()] : [];
$config = $param[$factory->getWidgetAlias()] ?? [];
// register the service into the container
$serviceId = $this->registerServiceIntoContainer(
$container,

View File

@@ -139,7 +139,7 @@ trait AddWidgetConfigurationTrait
protected function addWidgetsConfiguration(string $place, ContainerBuilder $containerBuilder)
{
$treeBuilder = new TreeBuilder($place);
$root = $treeBuilder->getRootNode($place)
$root = $treeBuilder->getRootNode()
->canBeUnset()
->info('register widgets on place "' . $place . '"');
@@ -170,7 +170,7 @@ trait AddWidgetConfigurationTrait
// adding the possible config on each widget under the widget_alias
foreach ($this->filterWidgetByPlace($place) as $factory) {
$builder = new TreeBuilder($factory->getWidgetAlias());
$widgetOptionsRoot = $builder->getRootNode($factory->getWidgetAlias());
$widgetOptionsRoot = $builder->getRootNode();
$widgetOptionsRoot->canBeUnset()
->info(sprintf(
'the configuration for the widget "%s" (only required if this widget is set in widget_alias)',