Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. XdebugHandler.php

function XdebugHandler::prepareRestart

Returns the command line array if everything was written for the restart

If any of the following fails (however unlikely) we must return false to stop potential recursion:

  • tmp ini file creation
  • environment variable creation

Return value

non-empty-list<string>|null

1 call to XdebugHandler::prepareRestart()
XdebugHandler::check in vendor/composer/xdebug-handler/src/XdebugHandler.php
Checks if Xdebug is loaded and the process needs to be restarted

File

vendor/composer/xdebug-handler/src/XdebugHandler.php, line 332

Class

XdebugHandler
@author John Stevenson <john-stevenson@blueyonder.co.uk>

Namespace

Composer\XdebugHandler

Code

private function prepareRestart() : ?array {
    if (!$this->cli) {
        $this->notify(Status::ERROR, 'Unsupported SAPI: ' . PHP_SAPI);
        return null;
    }
    if (($argv = $this->checkServerArgv()) === null) {
        $this->notify(Status::ERROR, '$_SERVER[argv] is not as expected');
        return null;
    }
    if (!$this->checkConfiguration($info)) {
        $this->notify(Status::ERROR, $info);
        return null;
    }
    $mainScript = (string) $this->script;
    if (!$this->checkMainScript($mainScript, $argv)) {
        $this->notify(Status::ERROR, 'Unable to access main script: ' . $mainScript);
        return null;
    }
    $tmpDir = sys_get_temp_dir();
    $iniError = 'Unable to create temp ini file at: ' . $tmpDir;
    if (($tmpfile = @tempnam($tmpDir, '')) === false) {
        $this->notify(Status::ERROR, $iniError);
        return null;
    }
    $error = null;
    $iniFiles = self::getAllIniFiles();
    $scannedInis = count($iniFiles) > 1;
    if (!$this->writeTmpIni($tmpfile, $iniFiles, $error)) {
        $this->notify(Status::ERROR, $error ?? $iniError);
        @unlink($tmpfile);
        return null;
    }
    if (!$this->setEnvironment($scannedInis, $iniFiles, $tmpfile)) {
        $this->notify(Status::ERROR, 'Unable to set environment variables');
        @unlink($tmpfile);
        return null;
    }
    $this->tmpIni = $tmpfile;
    return $this->getCommand($argv, $tmpfile, $mainScript);
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal