-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Refactor files trashbin app #39883
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
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)); | ||
| self::copy($rootView, $owner . '/files_versions' . $v['path'] . '.v' . $v['version'], $owner . '/files_trashbin/versions/' . static::getTrashFilename($v['name'] . '.v' . $v['version'], $timestamp)); | ||
| } | ||
| 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
| } else { | ||
| $size += $view->filesize('/files_trashbin/versions/' . $filename . '.v' . $v); | ||
| $view->unlink('/files_trashbin/versions/' . $filename . '.v' . $v); | ||
| } |
Check notice
Code scanning / Psalm
PossiblyNullArgument
Signed-off-by: Danial Rahimi <[email protected]>
Signed-off-by: Danial Rahimi <[email protected]>
Signed-off-by: Danial Rahimi <[email protected]>
Signed-off-by: Danial Rahimi <[email protected]>
Signed-off-by: Danial Rahimi <[email protected]>
Signed-off-by: Danial Rahimi <[email protected]>
Signed-off-by: Danial Rahimi <[email protected]>
24de858 to
82dd6fa
Compare
…e psalm analysis Signed-off-by: Danial Rahimi <[email protected]>
…ption on doctype Signed-off-by: Danial Rahimi <[email protected]>
| * @return bool|string original location | ||
| */ | ||
| 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 { |
nfebe
left a comment
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 <[email protected]> Signed-off-by: danial rahimy <[email protected]>
Co-authored-by: F. E Noel Nfebe <[email protected]> Signed-off-by: danial rahimy <[email protected]>
Co-authored-by: F. E Noel Nfebe <[email protected]> Signed-off-by: danial rahimy <[email protected]>
Co-authored-by: F. E Noel Nfebe <[email protected]> Signed-off-by: danial rahimy <[email protected]>
Co-authored-by: F. E Noel Nfebe <[email protected]> Signed-off-by: danial rahimy <[email protected]>
Summary
I did these items in a single file
apps/files_trashbin/lib/Trashbin.phpfor two reasons:Checklist