Uh oh!
There was an error while loading. Please reload this page.
Refactor files trashbin app - #39883
Conversation
9d23571 to
24de858CompareUh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
| 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
Uh oh!
There was an error while loading. Please reload this page.
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
82dd6faCompare…e psalm analysis Signed-off-by: Danial Rahimi <48244647+danialRahimy@users.noreply.github.com>
Uh oh!
There was an error while loading. Please reload this page.
…ption on doctype Signed-off-by: Danial Rahimi <48244647+danialRahimy@users.noreply.github.com>
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
| * @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.
| publicstaticfunction getLocation($user, $filename, $timestamp): bool|string { | |
| publicstaticfunction getLocation(string$user, string$filename,string$timestamp): bool|string { |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
nfebe
left a comment
There was a problem hiding this comment.
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.phpfor two reasons:Checklist