chore: replace legacy OC_Helper calls with OCP\Util#52801
Merged
Conversation
ArtificialOwl
approved these changes
May 14, 2025
- Replace legacy calls with OCP\Util - Add missing deprecation notices - Inline implementation in OCP\Util and call it from OC_Helper Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
3749b4c to
1ae3fa4
Compare
come-nc
approved these changes
May 14, 2025
Contributor
come-nc
left a comment
There was a problem hiding this comment.
A rector rule for this would be nice
solracsf
reviewed
May 14, 2025
| @@ -332,19 +332,70 @@ public static function numericToNumber(string|float|int $number): int|float { | |||
| * @since 4.0.0 | |||
| */ | |||
| public static function humanFileSize(int|float $bytes): string { | |||
Member
There was a problem hiding this comment.
Just a suggestion:
public static function humanFileSize(int|float $bytes, int $precision = 1): string
const KB = 1024;
const UNITS = ['B', 'KB', 'MB', 'GB', 'TB', 'PB'];
if (!is_numeric($bytes) || $bytes < 0) {
return '?';
}
$value = $bytes;
$unitIndex = 0;
while ($value >= KB && $unitIndex < count(UNITS) - 1) {
$value /= KB;
$unitIndex++;
}
return sprintf("%.${precision}f %s", $value, UNITS[$unitIndex]);
}
Contributor
Author
There was a problem hiding this comment.
Seems to be good but that would be better in a follow up PR.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Checklist