Skip to content

Commit

Permalink
fixed rootDir detection in older Composer
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed May 8, 2024
1 parent df677d9 commit 35dbb95
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/Bootstrap/Configurator.php
Original file line number Diff line number Diff line change
Expand Up @@ -169,13 +169,14 @@ protected function getDefaultParameters(): array
$loaderRc = class_exists(ClassLoader::class)
? new \ReflectionClass(ClassLoader::class)
: null;
$rootDir = class_exists(InstalledVersions::class) && ($tmp = InstalledVersions::getRootPackage()['install_path'] ?? null)

Check failure on line 172 in src/Bootstrap/Configurator.php

View workflow job for this annotation

GitHub Actions / PHPStan

Offset 'install_path' on array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: array<string>, dev: bool} on left side of ?? always exists and is not nullable.
? rtrim(Nette\Utils\FileSystem::normalizePath($tmp), '\\/')
: null;
return [
'appDir' => isset($trace[1]['file']) ? dirname($trace[1]['file']) : null,
'wwwDir' => isset($last['file']) ? dirname($last['file']) : null,
'vendorDir' => $loaderRc ? dirname($loaderRc->getFileName(), 2) : null,
'rootDir' => class_exists(InstalledVersions::class)
? rtrim(Nette\Utils\FileSystem::normalizePath(InstalledVersions::getRootPackage()['install_path']), '\\/')
: null,
'rootDir' => $rootDir,
'debugMode' => $debugMode,
'productionMode' => !$debugMode,
'consoleMode' => PHP_SAPI === 'cli',
Expand Down

0 comments on commit 35dbb95

Please sign in to comment.