src/ProjectLoader.php
private function findProjectRoot(string $dir) : ?string
    {
        do {
            $path = $dir . '/composer.json';

            if (file_exists($path)) {
                return $dir;
            }

            $prev = $dir;
            $dir = dirname($dir);
        } while ($dir !== $prev);

        return null;
    }
private function findProjectRoot(string $dir) : ?string
    {
        do {
            $path = $dir . '/composer.json';

            if (file_exists($path)) {
                return $dir;
            }

            $prev = $dir;
            $dir = dirname($dir);
        } while ($dir !== $prev);

        return null;
    }
private function findProjectRoot ( string $ dir ) : ? string { do { $ path = $ dir . '/composer.json' ; if ( file_exists ( $ path ) ) { return $ dir ; } $ prev = $ dir ; $ dir = dirname ( $ dir ) ; } while ( $ dir !== $ prev ) ; return null ; }
Finds project root by locating composer.json located in the current working directory or its closest parent

@param string $dir Current working directory
@return string|null
Finds project root by locating composer . json located in the current working directory or its closest parent