Repository: symfony/symfony
File: src/Symfony/Component/Config/Definition/Builder/ArrayNodeDefinition.php (PHP)

Code before:
     * enableableArrayNode: {other: value, ...}    # The config is enabled & default values get overridden
     * enableableArrayNode: {enabled: false, ...}  # The config is disabled
     * enableableArrayNode: false                  # The config is disabled
     *
     * @param string|null $info A description of what happens when the node is enabled or disabled
     *
     * @return $this
     */
    public function canBeEnabled(/* ?string $info = null */): static
    {
        $disabledNode = $this
            ->addDefaultsIfNotSet()
            ->treatFalseLike(['enabled' => false])
            ->treatTrueLike(['enabled' => true])
            ->treatNullLike(['enabled' => true])
            ->children()
                ->booleanNode('enabled')
                    ->defaultFalse()
        ;

        $info = 1 <= \func_num_args() ? func_get_arg(0) : null;
        if ($info) {
            $disabledNode->info($info);
        }

        return $this->attribute('auto_enable', true);
    }

    /**
     * Adds an "enabled" boolean to enable the current section.
     *
     * By default, the section is enabled.
     *
     * @param string|null $info A description of what happens when the node is enabled or disabled
     *
     * @return $this
     */
    public function canBeDisabled(/* ?string $info = null */): static
    {
        $enabledNode = $this
            ->addDefaultsIfNotSet()
            ->treatFalseLike(['enabled' => false])
            ->treatTrueLike(['enabled' => true])
            ->treatNullLike(['enabled' => true])
            ->children()
                ->booleanNode('enabled')
                    ->defaultTrue()
        ;

        $info = 1 <= \func_num_args() ? func_get_arg(0) : null;
        if ($info) {

Review comment (suggestion):
I would put the `attribute ` call in the existing chain on configuration calls instead of putting it on the return statement for the fluent API.

Code after:
     * enableableArrayNode: {other: value, ...}    # The config is enabled & default values get overridden
     * enableableArrayNode: {enabled: false, ...}  # The config is disabled
     * enableableArrayNode: false                  # The config is disabled
     *
     * @param string|null $info A description of what happens when the node is enabled or disabled
     *
     * @return $this
     */
    public function canBeEnabled(/* ?string $info = null */): static
    {
        $disabledNode = $this
            ->attribute('auto_enable', true)
            ->addDefaultsIfNotSet()
            ->treatFalseLike(['enabled' => false])
            ->treatTrueLike(['enabled' => true])
            ->treatNullLike(['enabled' => true])
            ->children()
                ->booleanNode('enabled')
                    ->defaultFalse()
        ;

        $info = 1 <= \func_num_args() ? func_get_arg(0) : null;
        if ($info) {
            $disabledNode->info($info);
        }

        return $this;
    }

    /**
     * Adds an "enabled" boolean to enable the current section.
     *
     * By default, the section is enabled.
     *
     * @param string|null $info A description of what happens when the node is enabled or disabled
     *
     * @return $this
     */
    public function canBeDisabled(/* ?string $info = null */): static
    {
        $enabledNode = $this
            ->attribute('auto_enable', true)
            ->addDefaultsIfNotSet()
            ->treatFalseLike(['enabled' => false])
            ->treatTrueLike(['enabled' => true])
            ->treatNullLike(['enabled' => true])
            ->children()
                ->booleanNode('enabled')
                    ->defaultTrue()
        ;