parts = $parts; } /** * Append a child path to this parent path without caring that the child is inside the parent * * @param \core\Path | \string $path Child path */ public function append(path: \core\Path | \string: $path) : self { if (\is_string($path)) { $path = \core\Path($path); } $this->parts = \array_merge($this->parts, $path->parts); return $this; } /** * Append a child path to this parent path, checking if the result path is inside the parent path as it should * * @param \core\Path | \string $path Child path */ public function safe_append(path: \core\Path | \string $path) : self { $old_realpath = \realpath($this->__tostring()); $new_realpath = \realpath($this->append($path)->__tostring()); if (\strpos($new_realpath, $old_realpath) !== 0) { $this = \core\Path($old_realpath); } return $this; } public function __toString() : \string { return \DIRECTORY_SEPARATOR . \implode(\DIRECTORY_SEPARATOR, $this->parts); } } ?>