-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor files trashbin app #39883
Refactor files trashbin app #39883
Conversation
9d23571
to
24de858
Compare
if ($owner !== $user) { | ||
self::copy_recursive($owner . '/files_versions/' . $ownerPath, $owner . '/files_trashbin/versions/' . static::getTrashFilename(basename($ownerPath), $timestamp), $rootView); | ||
} | ||
self::move($rootView, $owner . '/files_versions/' . $ownerPath, $user . '/files_trashbin/versions/' . static::getTrashFilename($filename, $timestamp)); |
Check notice
Code scanning / Psalm
PossiblyFalseOperand
} | ||
self::move($rootView, $owner . '/files_versions' . $v['path'] . '.v' . $v['version'], $user . '/files_trashbin/versions/' . static::getTrashFilename($filename . '.v' . $v['version'], $timestamp)); |
Check notice
Code scanning / Psalm
PossiblyFalseOperand
} | ||
|
||
if ($view->is_dir('/files_trashbin/versions/' . $file)) { | ||
$rootView->rename(Filesystem::normalizePath($user . '/files_trashbin/versions/' . $file), Filesystem::normalizePath($owner . '/files_versions/' . $ownerPath)); |
Check notice
Code scanning / Psalm
PossiblyFalseOperand
|
||
if ($view->is_dir('/files_trashbin/versions/' . $file)) { | ||
$rootView->rename(Filesystem::normalizePath($user . '/files_trashbin/versions/' . $file), Filesystem::normalizePath($owner . '/files_versions/' . $ownerPath)); | ||
} elseif ($versions = self::getVersionsFromTrash($versionedFile, $timestamp, $user)) { |
Check notice
Code scanning / Psalm
PossiblyFalseArgument
} elseif ($versions = self::getVersionsFromTrash($versionedFile, $timestamp, $user)) { | ||
foreach ($versions as $v) { | ||
if ($timestamp) { | ||
$rootView->rename($user . '/files_trashbin/versions/' . static::getTrashFilename($versionedFile . '.v' . $v, $timestamp), $owner . '/files_versions/' . $ownerPath . '.v' . $v); |
Check notice
Code scanning / Psalm
PossiblyFalseOperand
if ($timestamp) { | ||
$rootView->rename($user . '/files_trashbin/versions/' . static::getTrashFilename($versionedFile . '.v' . $v, $timestamp), $owner . '/files_versions/' . $ownerPath . '.v' . $v); | ||
} else { | ||
$rootView->rename($user . '/files_trashbin/versions/' . $versionedFile . '.v' . $v, $owner . '/files_versions/' . $ownerPath . '.v' . $v); |
Check notice
Code scanning / Psalm
PossiblyFalseOperand
if ($view->is_dir('files_trashbin/versions/' . $file)) { | ||
$size += self::calculateSize(new View('/' . $user . '/files_trashbin/versions/' . $file)); | ||
$view->unlink('files_trashbin/versions/' . $file); | ||
} elseif ($versions = self::getVersionsFromTrash($filename, $timestamp, $user)) { |
Check notice
Code scanning / Psalm
PossiblyNullArgument
Signed-off-by: Danial Rahimi <48244647+danialRahimy@users.noreply.github.com>
Signed-off-by: Danial Rahimi <48244647+danialRahimy@users.noreply.github.com>
Signed-off-by: Danial Rahimi <48244647+danialRahimy@users.noreply.github.com>
Signed-off-by: Danial Rahimi <48244647+danialRahimy@users.noreply.github.com>
Signed-off-by: Danial Rahimi <48244647+danialRahimy@users.noreply.github.com>
Signed-off-by: Danial Rahimi <48244647+danialRahimy@users.noreply.github.com>
Signed-off-by: Danial Rahimi <48244647+danialRahimy@users.noreply.github.com>
24de858
to
82dd6fa
Compare
…e psalm analysis Signed-off-by: Danial Rahimi <48244647+danialRahimy@users.noreply.github.com>
…ption on doctype Signed-off-by: Danial Rahimi <48244647+danialRahimy@users.noreply.github.com>
*/ | ||
public static function getLocation($user, $filename, $timestamp) { | ||
public static function getLocation($user, $filename, $timestamp): bool|string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public static function getLocation($user, $filename, $timestamp): bool|string { | |
public static function getLocation(string $user, string $filename, string $timestamp): bool|string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this is just a refactor and no main functional change you can just use build in type hinting for PHP... I left a few examples but not all, most of the functions can use built in type hinting and that would allow you to delete the comment annotations at the top (leaving behind just the exceptions)
Co-authored-by: F. E Noel Nfebe <fenn25.fn@gmail.com> Signed-off-by: danial rahimy <48244647+danialRahimy@users.noreply.github.com>
Co-authored-by: F. E Noel Nfebe <fenn25.fn@gmail.com> Signed-off-by: danial rahimy <48244647+danialRahimy@users.noreply.github.com>
Co-authored-by: F. E Noel Nfebe <fenn25.fn@gmail.com> Signed-off-by: danial rahimy <48244647+danialRahimy@users.noreply.github.com>
Co-authored-by: F. E Noel Nfebe <fenn25.fn@gmail.com> Signed-off-by: danial rahimy <48244647+danialRahimy@users.noreply.github.com>
Co-authored-by: F. E Noel Nfebe <fenn25.fn@gmail.com> Signed-off-by: danial rahimy <48244647+danialRahimy@users.noreply.github.com>
Summary
I did these items in a single file
apps/files_trashbin/lib/Trashbin.php
for two reasons:Checklist