feat: Add rename method to SevenZip wrapper#44
Conversation
Added a new `rename` method to the `SevenZip` class allowing the renaming of files within an existing archive via the `7z rn` command. The implementation includes: - Validation checks for required source path and empty renames arrays. - Graceful handling of unsupported formats (e.g. `bzip2`) by throwing a `RuntimeException`. - Addition of a new `testRename` test in `tests/SevenZipTest.php`, integrated properly with the `#[Depends]` test flow (executed between verify and extract). - Addition of API documentation for the `rename` method to the `README.md` file. - Fixed two implicit nullable parameters deprecated in PHP 8.4 and updated `phpstan-baseline.neon`. Co-authored-by: insign <1113045+insign@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
Blocking: the new rename API documents that bzip2 is unsupported, but the implementation only checks getFormat(). In this wrapper, source() does not infer archive format, and the README example for rename also does not call format(). So a normal call like source(/path/archive.bz2) followed by rename(...) keeps the default format 7z, skips the unsupported-format guard, and behaves differently from the documented contract. Please make support detection depend on the actual archive being renamed, or adjust the API, docs, and tests so the documented usage is consistent with the real behavior. |
Good catch! I've updated the |
Updated the `rename` method to detect the archive format by extracting the file extension from the provided `source()` path. This ensures that a `RuntimeException` is properly thrown when attempting to rename within a `bzip2` archive, even if the user relies on the default `7z` format state without explicitly calling `->format('bzip2')`.
Also updated the `testRename` test to verify this exact behavior by not setting the format manually prior to calling `rename()`.
Co-authored-by: insign <1113045+insign@users.noreply.github.com>
This commit introduces the ability to rename files within a given 7-Zip archive using the
renamemethod, passing an associative array mapping old file names to new file names.It updates
README.mdto document the method properly and introduces the corresponding test case intests/SevenZipTest.php.It also addresses a minor issue on PHP 8.4 deprecation to make sure the library stays compatible out-of-the-box in the upcoming environment.
PR created automatically by Jules for task 5084006000029647903 started by @insign