Skip to content

feat: Add rename method to SevenZip wrapper#44

Merged
insign merged 2 commits into
mainfrom
add-rename-method-5084006000029647903
Apr 7, 2026
Merged

feat: Add rename method to SevenZip wrapper#44
insign merged 2 commits into
mainfrom
add-rename-method-5084006000029647903

Conversation

@insign
Copy link
Copy Markdown
Contributor

@insign insign commented Apr 1, 2026

This commit introduces the ability to rename files within a given 7-Zip archive using the rename method, passing an associative array mapping old file names to new file names.

It updates README.md to document the method properly and introduces the corresponding test case in tests/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

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>
@google-labs-jules
Copy link
Copy Markdown
Contributor

👋 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 @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@insign
Copy link
Copy Markdown
Contributor Author

insign commented Apr 7, 2026

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.

@google-labs-jules
Copy link
Copy Markdown
Contributor

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 rename method to detect the format from the actual source file extension in addition to the globally set format. The tests have also been updated to omit the explicit ->format() call, verifying that the new source-based detection properly enforces the bzip2 unsupported rule. Thank you for the review!

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>
@insign insign merged commit 908c7ff into main Apr 7, 2026
9 checks passed
@insign insign deleted the add-rename-method-5084006000029647903 branch April 7, 2026 04:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant