updateConfigVariable() public méthode

By default it saves string in single quotes. See $usePlainValue.
public updateConfigVariable ( $variableName, string | number | boolean $value, boolean $usePlainValue = false )
$variableName
$value string | number | boolean
$usePlainValue boolean The value is used as-is, without quoting.
    /**
     * @test
     */
    public function editorUpdatesOnlyDesiredValueInWpConfig()
    {
        file_put_contents($this->commonConfigPath, '<?php
// ** MySQL settings ** //
/** The name of the database for WordPress */
define(\'DB_NAME\', \'vp01\');

$table_prefix = \'wp_\';


$my_variable = \'value\';
$test = \'value\';
/* That\'s all, stop editing! Happy blogging. */

/** Absolute path to the WordPress directory. */
if ( !defined(\'ABSPATH\') )
    define(\'ABSPATH\', dirname(__FILE__) . \'/\');

/** Sets up WordPress vars and included files. */
require_once(ABSPATH . \'wp-settings.php\');
');
        $a = new WpConfigEditor($this->commonConfigPath, false);
        $a->updateConfigVariable('my_variable', 'another value');
        $expectedContent = '<?php
// ** MySQL settings ** //
/** The name of the database for WordPress */
define(\'DB_NAME\', \'vp01\');

$table_prefix = \'wp_\';


$my_variable = \'another value\';
$test = \'value\';
/* That\'s all, stop editing! Happy blogging. */

/** Absolute path to the WordPress directory. */
if ( !defined(\'ABSPATH\') )
    define(\'ABSPATH\', dirname(__FILE__) . \'/\');

/** Sets up WordPress vars and included files. */
require_once(ABSPATH . \'wp-settings.php\');
';
        $this->assertEquals($expectedContent, file_get_contents($this->commonConfigPath));
    }
 /**
  * Sets or updates constant or variable in wp-config.php
  *
  * ## OPTIONS
  *
  * <constant>
  * : Name of constant or variable that will be changed.
  *
  * <value>
  * : Desired value. Supported types are: string, int, float and bool.
  *
  * [--plain]
  * : The value will be used as is - without type detection, quoting etc.
  *
  * [--variable]
  * : Will set a variable instead of constant. Useful for $table_prefix.
  *
  * [--common]
  * : The constant / variable will be set in wp-config.common.php.
  *
  * @subcommand update-config
  *
  *
  * @when before_wp_load
  */
 public function updateConfig($args = [], $assoc_args = [])
 {
     require_once __DIR__ . '/VPCommandUtils.php';
     require_once __DIR__ . '/../Initialization/WpConfigSplitter.php';
     require_once __DIR__ . '/../Utils/WpConfigEditor.php';
     require_once __DIR__ . '/../Utils/WordPressMissingFunctions.php';
     $wpConfigPath = WordPressMissingFunctions::getWpConfigPath();
     $updateCommonConfig = isset($assoc_args['common']);
     if ($updateCommonConfig) {
         $wpConfigPath = dirname($wpConfigPath) . '/' . WpConfigSplitter::COMMON_CONFIG_NAME;
     }
     if ($wpConfigPath === false) {
         WP_CLI::error('Config file does not exist. Please run `wp core config` first.');
     }
     $constantOrVariableName = $args[0];
     $isVariable = isset($assoc_args['variable']);
     $usePlainValue = isset($assoc_args['plain']);
     $value = $usePlainValue ? $args[1] : VPCommandUtils::fixTypeOfValue($args[1]);
     $wpConfigEditor = new WpConfigEditor($wpConfigPath, $updateCommonConfig);
     try {
         if ($isVariable) {
             $wpConfigEditor->updateConfigVariable($constantOrVariableName, $value, $usePlainValue);
         } else {
             $wpConfigEditor->updateConfigConstant($constantOrVariableName, $value, $usePlainValue);
         }
     } catch (\Exception $e) {
         WP_CLI::error('Cannot find place for defining the ' . ($isVariable ? 'variable' : 'constant') . '. Config was probably edited manually.');
     }
 }