Skip to content

Space inside working directory's name #644

Closed
@toto975

Description

@toto975
Q A
Bug report? yes
Feature request? no
Library version 2.8

If the working directory has a space inside its name, there is this error :


  Syntax error

  at D:\Sites\working directory with space\vendor\nunomaduro\phpinsights\src\Domain\Insights\SyntaxCheck.php:56
     52▕             $process->setWorkingDirectory($this->collector->getCommonPath());
     53▕         }
     54▕         $process->run();
     55▕
  ➜  56▕         $output = json_decode($process->getOutput(), true, 512, JSON_THROW_ON_ERROR);
     57▕         $errors = $output['results']['errors'] ?? [];
     58▕
     59▕         foreach ($errors as $error) {
     60▕             if (preg_match('/^.*error:(.*) in .* on line [\d]+/m', $error['message'], $matches) === 1) {

  1   D:\Sites\working directory with space\vendor\nunomaduro\phpinsights\src\Domain\Insights\SyntaxCheck.php:56
      json_decode("")

  2   D:\Sites\working directory with space\vendor\nunomaduro\phpinsights\src\Domain\Runner.php:164
      NunoMaduro\PhpInsights\Domain\Insights\SyntaxCheck::process()

In phpinsights\src\Domain\Insights\SyntaxCheck.php, it can be fixed with

...
    public function process(): void
    {
        $toAnalyse = $this->getTarget();

        $cmdLine = sprintf(
            '"%s" --no-colors --no-progress --json %s %s', <==== add double quotes here with the the first %s
            $this->getBinary(),
            implode(' ', $this->getShellExcludeArgs()),
            $toAnalyse
        );
        $process = Process::fromShellCommandline($cmdLine);
...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions