/** * Returns whether this path is an absolute path. * * @return boolean */ public function isAbsolute() { if (realpath($this->pathname->toString()) == $this->pathname->toString()) { return true; } if ($this->pathname->length() == 0 || $this->pathname->charAt(0) == '.') { return false; } // Windows allows absolute paths like this. if ($this->pathname->match('#^[a-zA-Z]:\\\\#')) { return true; } // A path starting with / or \ is absolute; anything else is relative. return $this->pathname->charAt(0) == '/' || $this->pathname->charAt(0) == '\\'; }