src/UnixEnvironment.php
private function isValidHomeDirectory(string $path): bool
    {
        $valid = false;
        if ('~/' === substr($path, 0, 2)) {
            $valid = $this->isValidFullPath(
                $this->expandHomeDirectory($path)
            );
        }

        return $valid;
    }
private function isValidHomeDirectory(string $path): bool
    {
        $valid = false;
        if ('~/' === substr($path, 0, 2)) {
            $valid = $this->isValidFullPath(
                $this->expandHomeDirectory($path)
            );
        }

        return $valid;
    }
Returns true if the path is relative to the users home directory.

The home directory receives special attention due to the fact that chdir (and pals) don't expand '~' to the users
home directory - this is a function of the shell on UNIX systems so we must replicate the behaviour here.