mirror of
https://github.com/itflow-org/itflow
synced 2026-08-24 00:15:12 +00:00
Allow PHP-8.2 and up Compatibility instead of just PHP-8.4
This commit is contained in:
@@ -86,7 +86,7 @@ class File extends \SplFileInfo
|
||||
{
|
||||
$target = $this->getTargetFile($directory, $name);
|
||||
|
||||
set_error_handler(function ($type, $msg) use (&$error) { $error = $msg; });
|
||||
set_error_handler(static function ($type, $msg) use (&$error) { $error = $msg; });
|
||||
try {
|
||||
$renamed = rename($this->getPathname(), $target);
|
||||
} finally {
|
||||
@@ -96,7 +96,7 @@ class File extends \SplFileInfo
|
||||
throw new FileException(\sprintf('Could not move the file "%s" to "%s" (%s).', $this->getPathname(), $target, strip_tags($error)));
|
||||
}
|
||||
|
||||
@chmod($target, 0666 & ~umask());
|
||||
@chmod($target, 0o666 & ~umask());
|
||||
|
||||
return $target;
|
||||
}
|
||||
@@ -114,10 +114,11 @@ class File extends \SplFileInfo
|
||||
|
||||
protected function getTargetFile(string $directory, ?string $name = null): self
|
||||
{
|
||||
if (!is_dir($directory)) {
|
||||
if (false === @mkdir($directory, 0777, true) && !is_dir($directory)) {
|
||||
throw new FileException(\sprintf('Unable to create the "%s" directory.', $directory));
|
||||
if (!is_dir($directory) && !@mkdir($directory, 0o777, true) && !is_dir($directory)) {
|
||||
if (is_file($directory)) {
|
||||
throw new FileException(\sprintf('Unable to create the "%s" directory: a similarly-named file exists.', $directory));
|
||||
}
|
||||
throw new FileException(\sprintf('Unable to create the "%s" directory.', $directory));
|
||||
} elseif (!is_writable($directory)) {
|
||||
throw new FileException(\sprintf('Unable to write in the "%s" directory.', $directory));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user