title: Escaping a PHP function as an Array value
body: <p>I'm working on a Drupal 8 starter kit with Composer, similar to <a href="https://github.com/drupal-composer/drupal-project" rel="nofollow noreferrer">drupal-composer/drupal-project</a>.</p>
  
  <p>In my post-install script, I want to re-generate a <code>settings.php</code> file with my custom values.
  I've seen that can be done with the <a href="https://api.drupal.org/api/drupal/core%21includes%21install.inc/function/drupal_rewrite_settings/8.2.x" rel="nofollow noreferrer">drupal_rewrite_settings</a> function.</p>
  
  <p>For example, I'm rewriting the <code>config_sync_directory</code> value like that :</p>
  
  <pre class="lang-php prettyprint-override"><code>require_once $drupalRoot . '/core/includes/bootstrap.inc';
  require_once $drupalRoot . '/core/includes/install.inc';
  new Settings([]);
  $settings['settings']['config_sync_directory'] = (object) [
    'value' =&gt; '../config/sync',
    'required' =&gt; TRUE,
  ];
  drupal_rewrite_settings($settings, $drupalRoot . '/sites/default/settings.php');
  </code></pre>
  
  <p>Problem is I want my Drupal 8 project to have a Dotenv so the maintainers don't have to modify the <code>settings.php</code> but only a <code>.env</code> file in the root folder of the project. To make it work, my <code>settings.php</code> must look like this :</p>
  
  <pre class="lang-php prettyprint-override"><code>$databases['default']['default'] = [
    'database' =&gt; getenv('MYSQL_DATABASE'),
    'driver' =&gt; 'mysql',
    'host' =&gt; getenv('MYSQL_HOSTNAME'),
    'namespace' =&gt; 'Drupal\\Core\\Database\\Driver\\mysql',
    'password' =&gt; getenv('MYSQL_PASSWORD'),
    'port' =&gt; '',
    'prefix' =&gt; '',
    'username' =&gt; getenv('MYSQL_USER'),
  ];
  $settings['trusted_host_patterns'] = explode(',', '^'.getenv('SITE_URL').'$');
  </code></pre>
  
  <p>As you can see, the values are replaced by PHP functions, and I can't see a good way to print those values, to the point I'm not even sure that's possible.</p>
  
  <p>So my question is : is it possible to escape a PHP function as an Array value when declaring this variable ?</p>