Skip to content

Conversation

@kjdev
Copy link
Owner

@kjdev kjdev commented Jul 31, 2025

Summary by CodeRabbit

  • New Features

    • Added support for using named arguments with all Zstandard (zstd) compression and decompression functions in PHP 8.0 and above.
  • Tests

    • Introduced comprehensive tests to verify correct behavior and error handling of zstd functions when called with named arguments, including one-shot and incremental operations, as well as dictionary-based variants.
  • Style

    • Enhanced type safety and reflection information for zstd functions when used with PHP 8.0+, improving developer experience.

@coderabbitai
Copy link

coderabbitai bot commented Jul 31, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

This change introduces new PHP test files to verify the correct handling of named arguments in Zstandard compression and decompression functions, including dictionary-based and incremental APIs. Additionally, the extension's C source is updated to define PHP 8+ typed argument info for all user-facing functions, enhancing type safety and reflection metadata.

Changes

Cohort / File(s) Change Summary
Named Arguments Tests
tests/named_args.phpt
Adds tests for zstd_compress and zstd_uncompress using named arguments, including error handling and validation of correct compression/decompression behavior. Skips on PHP < 8.0.
Dictionary Named Arguments Tests
tests/dictionary_named_args.phpt
Adds tests for zstd_compress_dict and zstd_uncompress_dict with named arguments, covering error cases and verifying round-trip compression/decompression with dictionaries. Skips on PHP < 8.0.
Incremental Named Arguments Tests
tests/inc_named_args.phpt
Adds tests for incremental compression and decompression functions using named arguments, chunked processing, and error handling for invalid compression levels. Skips on PHP < 8.0.
PHP 8+ Typed Arginfo Declarations
zstd.c
Adds PHP 8+ specific typed argument info for all exported functions, specifying parameter and return types for one-shot, dictionary, and incremental APIs. Retains legacy macros for older PHP versions. No control flow changes.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant PHP_Zstd_Extension

    User->>PHP_Zstd_Extension: zstd_compress(data: ..., level: ...)
    PHP_Zstd_Extension-->>User: compressed string

    User->>PHP_Zstd_Extension: zstd_uncompress(data: ...)
    PHP_Zstd_Extension-->>User: original string

    User->>PHP_Zstd_Extension: zstd_compress_dict(data: ..., dict: ..., level: ...)
    PHP_Zstd_Extension-->>User: compressed string

    User->>PHP_Zstd_Extension: zstd_uncompress_dict(data: ..., dict: ...)
    PHP_Zstd_Extension-->>User: original string

    User->>PHP_Zstd_Extension: zstd_compress_init(level: ...)
    PHP_Zstd_Extension-->>User: Compress\Context

    User->>PHP_Zstd_Extension: zstd_compress_add(context, data: ..., end: ...)
    PHP_Zstd_Extension-->>User: chunked compressed data

    User->>PHP_Zstd_Extension: zstd_uncompress_init()
    PHP_Zstd_Extension-->>User: UnCompress\Context

    User->>PHP_Zstd_Extension: zstd_uncompress_add(context, data: ...)
    PHP_Zstd_Extension-->>User: chunked decompressed data
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~18 minutes

Possibly related PRs

  • Refactor #86: Refactors internal context handling and streaming logic in dictionary-based functions, directly related to the functions tested and updated here.
  • Refactor/zend parse parameters #84: Refactors parameter parsing logic for multiple zstd functions, including those covered by the new tests and arginfo changes.
  • Fix/streaming uncompress dict #81: Refactors internal implementation of zstd_uncompress_dict for streaming support, related at the function level to the new tests.

Poem

A hop, a skip, named args in tow,
Compression tested high and low.
Dictionaries join the fun,
Incremental chunks—one by one!
Typed hints for PHP eight,
Ensuring code and tests relate.
🐇✨ Hooray for zstd’s fate!

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e061583 and 8b8e84c.

📒 Files selected for processing (4)
  • tests/dictionary_named_args.phpt (1 hunks)
  • tests/inc_named_args.phpt (1 hunks)
  • tests/named_args.phpt (1 hunks)
  • zstd.c (1 hunks)
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/named-argument-support

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@kjdev
Copy link
Owner Author

kjdev commented Jul 31, 2025

@coderabbitai review

@coderabbitai
Copy link

coderabbitai bot commented Jul 31, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

1 similar comment
@coderabbitai
Copy link

coderabbitai bot commented Jul 31, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@kjdev kjdev merged commit 8b8e84c into master Jul 31, 2025
98 checks passed
@kjdev kjdev deleted the feat/named-argument-support branch July 31, 2025 23:50
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.

2 participants