Repository: symfony/symfony
File: src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php (PHP)

Code before:
                                ->end()
                                ->defaultNull()
                            ->end()
                            ->scalarNode('log_channel')
                                ->info('The channel of log message. Null to let Symfony decide.')
                                ->defaultNull()
                            ->end()
                        ->end()
                    ->end()
                ->end()
            ->end()
        ;
    }

    private function addLockSection(ArrayNodeDefinition $rootNode, callable $enableIfStandalone): void
    {
        $rootNode
            ->children()
                ->arrayNode('lock')
                    ->info('Lock configuration')
                    ->acceptAndWrap(['string'], 'resources')
                    ->{$enableIfStandalone('symfony/lock', Lock::class)}()
                    ->beforeNormalization()
                        ->ifArray()
                        ->then(static function ($v) {
                            if (!isset($v['resources']) && !isset($v['resource'])) {
                                $v = ['enabled' => $v['enabled'], 'resources' => $v];
                                unset($v['resources']['enabled']);
                            }

                            return $v;
                        })
                    ->end()
                    ->addDefaultsIfNotSet()
                    ->validate()
                        ->ifTrue(static fn ($v) => $v['enabled'] && !$v['resources'])
                        ->thenInvalid('At least one resource must be defined.')
                    ->end()
                    ->children()
                        ->arrayNode('resources', 'resource')
                            ->normalizeKeys(false)
                            ->useAttributeAsKey('name')
                            ->defaultValue(['default' => [class_exists(SemaphoreStore::class) && SemaphoreStore::isSupported() ? 'semaphore' : 'flock']])
                            ->acceptAndWrap(['string'], 'default')
                            ->beforeNormalization()
                                ->ifArray()
                                ->then(static function ($v) {
                                    if (!array_is_list($v)) {
                                        return $v;
                                    }


Review comment (suggestion):
we can rely on canBeEnabled/Disabled to set this default, but acceptAndWrap should then be moved earlier to have a proper ordering of beforeNormalization calls (adding [enabled => true] to wrapped strings)

Code after:
                                ->end()
                                ->defaultNull()
                            ->end()
                            ->scalarNode('log_channel')
                                ->info('The channel of log message. Null to let Symfony decide.')
                                ->defaultNull()
                            ->end()
                        ->end()
                    ->end()
                ->end()
            ->end()
        ;
    }

    private function addLockSection(ArrayNodeDefinition $rootNode, callable $enableIfStandalone): void
    {
        $rootNode
            ->children()
                ->arrayNode('lock')
                    ->info('Lock configuration')
                    ->acceptAndWrap(['string'], 'resources')
                    ->{$enableIfStandalone('symfony/lock', Lock::class)}()
                    ->beforeNormalization()
                        ->ifArray()
                        ->then(static function ($v) {
                            if (!isset($v['resources']) && !isset($v['resource'])) {
                                $v = ['resources' => $v];
                                if (\array_key_exists('enabled', $v['resources'])) {
                                    $v['enabled'] = $v['resources']['enabled'];
                                    unset($v['resources']['enabled']);
                                }
                            }

                            return $v;
                        })
                    ->end()
                    ->addDefaultsIfNotSet()
                    ->validate()
                        ->ifTrue(static fn ($v) => $v['enabled'] && !$v['resources'])
                        ->thenInvalid('At least one resource must be defined.')
                    ->end()
                    ->children()
                        ->arrayNode('resources', 'resource')
                            ->normalizeKeys(false)
                            ->useAttributeAsKey('name')
                            ->defaultValue(['default' => [class_exists(SemaphoreStore::class) && SemaphoreStore::isSupported() ? 'semaphore' : 'flock']])
                            ->acceptAndWrap(['string'], 'default')
                            ->beforeNormalization()
                                ->ifArray()
                                ->then(static function ($v) {
                                    if (!array_is_list($v)) {