Remove const DS

This commit is contained in:
Giuseppe Criscione 2024-11-16 19:23:02 +01:00
parent db46c7c3ae
commit f944c313e0
6 changed files with 10 additions and 11 deletions

View File

@ -898,7 +898,7 @@ class Page extends Model implements Stringable
throw new UnexpectedValueException('Unexpected missing site path');
}
$this->relativePath = Str::prepend(Path::makeRelative($this->path, $this->site()->contentPath(), DS), DS);
$this->relativePath = Str::prepend(Path::makeRelative($this->path, $this->site()->contentPath(), DIRECTORY_SEPARATOR), DIRECTORY_SEPARATOR);
$routePath = preg_replace('~[/\\\](\d+-)~', '/', $this->relativePath)
?? throw new RuntimeException(sprintf('Replacement failed with error: %s', preg_last_error_msg()));

View File

@ -127,7 +127,7 @@ class ToolsController extends AbstractController
'jaybizzle/crawler-detect' => $dependencies['jaybizzle/crawler-detect']['version'],
],
'System' => [
'Directory Separator' => DS,
'Directory Separator' => DIRECTORY_SEPARATOR,
'EOL Symbol' => addcslashes(PHP_EOL, "\r\n"),
'Max Path Length' => FileSystem::MAX_PATH_LENGTH,
'File Creation Mask' => sprintf('0%03o', umask()),

View File

@ -43,7 +43,7 @@ class Schemes
public function loadFromPath(string $path): void
{
foreach (FileSystem::listRecursive($path) as $item) {
$id = str_replace(DS, '.', Str::beforeLast($item, '.'));
$id = str_replace(DIRECTORY_SEPARATOR, '.', Str::beforeLast($item, '.'));
$this->load($id, FileSystem::joinPaths($path, $item));
}
}

View File

@ -175,7 +175,7 @@ class Updater
if (!FileSystem::exists($destinationDirectory)) {
FileSystem::createDirectory($destinationDirectory);
}
if (!Str::endsWith($destination, DS)) {
if (!Str::endsWith($destination, DIRECTORY_SEPARATOR)) {
$contents = $zipArchive->getFromIndex($i);
if ($contents === false) {
throw new RuntimeException(sprintf('Cannot read "%s" from zip archive', $filename));

View File

@ -72,7 +72,7 @@ class FileSystem
*/
public static function normalizePath(string $path): string
{
return Path::normalize($path, DS);
return Path::normalize($path, DIRECTORY_SEPARATOR);
}
/**
@ -80,7 +80,7 @@ class FileSystem
*/
public static function joinPaths(string ...$paths): string
{
return Path::join($paths, DS);
return Path::join($paths, DIRECTORY_SEPARATOR);
}
/**
@ -88,7 +88,7 @@ class FileSystem
*/
public static function resolvePath(string $path): string
{
return Path::resolve($path, static::cwd(), DS);
return Path::resolve($path, static::cwd(), DIRECTORY_SEPARATOR);
}
/**
@ -432,7 +432,7 @@ class FileSystem
}
// On Windows symbolic links pointing to a directory have to be removed with `rmdir()`
// see https://bugs.php.net/bug.php?id=52176
if (@unlink($link) || (DS === '\\' && @rmdir($link))) {
if (@unlink($link) || (DIRECTORY_SEPARATOR === '\\' && @rmdir($link))) {
return true;
}
throw new FileSystemException(sprintf('Cannot delete symbolic link "%s": %s', $link, static::getLastErrorMessage()));
@ -707,7 +707,7 @@ class FileSystem
throw new InvalidArgumentException(sprintf('%s() accepts only links as $link argument', __METHOD__));
}
// Use `realpath()` on Windows because `readlink()` returns the canonicalized path
if (($target = DS === '\\' ? @realpath($link) : @readlink($link)) !== false) {
if (($target = DIRECTORY_SEPARATOR === '\\' ? @realpath($link) : @readlink($link)) !== false) {
return $target;
}
throw new FileSystemException(sprintf('Cannot resolve symbolic link "%s": %s', $link, static::getLastErrorMessage()));
@ -790,7 +790,7 @@ class FileSystem
static::assertExists($target);
}
// On Windows `symlink()` may require an absolute path
if (@symlink($target, $link) || (DS === '\\' && @symlink(static::resolvePath($target), $link))) {
if (@symlink($target, $link) || (DIRECTORY_SEPARATOR === '\\' && @symlink(static::resolvePath($target), $link))) {
return true;
}
throw new FileSystemException(sprintf('Cannot create symbolic link "%s": %s', $link, static::getLastErrorMessage()));

View File

@ -2,7 +2,6 @@
use Formwork\App;
const DS = DIRECTORY_SEPARATOR;
const ROOT_PATH = __DIR__;
const SYSTEM_PATH = ROOT_PATH . '/formwork';