src/Psalm/Config.php
public static function locateConfigFile(string $path)
    {
        $dir_path = realpath($path);

        if ($dir_path === false) {
            throw new ConfigException('Config not found for path ' . $path);
        }

        if (!is_dir($dir_path)) {
            $dir_path = dirname($dir_path);
        }

        do {
            $maybe_path = $dir_path . DIRECTORY_SEPARATOR . Config::DEFAULT_FILE_NAME;

            if (file_exists($maybe_path) || file_exists($maybe_path .= '.dist')) {
                return $maybe_path;
            }

            $dir_path = dirname($dir_path);
        } while (dirname($dir_path) !== $dir_path);
        return null;
    }
public static function locateConfigFile(string $path)
    {
        $dir_path = realpath($path);

        if ($dir_path === false) {
            throw new ConfigException('Config not found for path ' . $path);
        }

        if (!is_dir($dir_path)) {
            $dir_path = dirname($dir_path);
        }

        do {
            $maybe_path = $dir_path . DIRECTORY_SEPARATOR . Config::DEFAULT_FILE_NAME;

            if (file_exists($maybe_path) || file_exists($maybe_path .= '.dist')) {
                return $maybe_path;
            }

            $dir_path = dirname($dir_path);
        } while (dirname($dir_path) !== $dir_path);
        return null;
    }
public static function locateConfigFile ( string $ path ) { $ dir_path = realpath ( $ path ) ; if ( $ dir_path === false ) { throw new ConfigException ( 'Config not found for path ' . $ path ) ; } if ( ! is_dir ( $ dir_path ) ) { $ dir_path = dirname ( $ dir_path ) ; } do { $ maybe_path = $ dir_path . DIRECTORY_SEPARATOR . Config :: DEFAULT_FILE_NAME ; if ( file_exists ( $ maybe_path ) || file_exists ( $ maybe_path .= '.dist' ) ) { return $ maybe_path ; } $ dir_path = dirname ( $ dir_path ) ; } while ( dirname ( $ dir_path ) !== $ dir_path ) ; return null ; }
Searches up a folder hierarchy for the most immediate config.

@throws ConfigException
@return ?string
Searches up a folder hierarchy for the most immediate config .