Skip to content

Refactor/zend parse parameters #84

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 11, 2025
Merged

Conversation

kjdev
Copy link
Owner

@kjdev kjdev commented Jun 11, 2025

Summary by CodeRabbit

  • Bug Fixes
    • Improved error and warning messages for compression and decompression functions, providing more specific details when incorrect parameter types are passed.
  • Tests
    • Updated test cases to reflect the new, more explicit error messages for invalid parameter types.

Copy link

coderabbitai bot commented Jun 11, 2025

Walkthrough

The changes update parameter parsing in several zstd compression-related functions to use modern Zend macros, removing legacy PHP version checks and manual error handling. Corresponding test files are updated to expect more explicit and detailed warning messages reflecting these improvements in error reporting.

Changes

Files Change Summary
tests/002.phpt, tests/005.phpt Updated expected warning messages for parameter type errors to match more explicit, modern Zend error reporting.
zstd.c Removed legacy PHP version checks and manual parameter parsing; standardized on modern Zend macros for arguments.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant PHP_Extension
    participant Zend_API

    User->>PHP_Extension: Call zstd_compress()/zstd_uncompress() with arguments
    PHP_Extension->>Zend_API: Parse parameters using ZEND_PARSE_PARAMETERS_START
    alt Parameters valid
        Zend_API-->>PHP_Extension: Parameters extracted
        PHP_Extension-->>User: Proceed with compression/decompression
    else Parameters invalid
        Zend_API-->>PHP_Extension: Emit detailed warning (parameter index, type)
        PHP_Extension-->>User: Return false
    end
Loading

Poem

In the warren of code, we hop and refine,
Old checks are gone, new macros align.
Warnings now clearer, with types in the light,
Rabbits rejoice—our tests now read right!
🐇✨

✨ Finishing Touches
  • 📝 Generate Docstrings

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 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 Jun 11, 2025

@coderabbitai review

Copy link

coderabbitai bot commented Jun 11, 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.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

♻️ Duplicate comments (4)
zstd.c (4)

375-378: Same concern as earlier about the availability of ZEND_PARSE_PARAMETERS_END_EX on the lowest supported PHP-7 version.


466-470: See first comment – applies here as well.


617-621: Same macro-compatibility consideration.


657-666: Same remark regarding macro presence; otherwise the refactor looks clean.

🧹 Nitpick comments (1)
zstd.c (1)

718-737: Remove unused local variable to avoid compiler warnings

zend_object *context; is declared but never used. Compilers (esp. with -Werror) will complain.

-    zend_object *context;

No other code refers to context, so it can be deleted safely.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between bb58ed7 and c121499.

📒 Files selected for processing (3)
  • tests/002.phpt (1 hunks)
  • tests/005.phpt (1 hunks)
  • zstd.c (7 hunks)
🧰 Additional context used
🧠 Learnings (1)
zstd.c (1)
Learnt from: thekid
PR: kjdev/php-ext-zstd#77
File: zstd.stub.php:13-22
Timestamp: 2025-04-20T19:39:56.258Z
Learning: The php-ext-zstd library aims to maintain compatibility with PHP 7, so PHP 8-specific syntax features like union types should be avoided in favor of PHPDoc annotations.
🔇 Additional comments (3)
zstd.c (1)

340-344: Confirm ZEND_PARSE_PARAMETERS_END_EX exists on all supported PHP-7 targets

Good call switching to the _EX(RETURN_FALSE) variant – it keeps the fast-return behaviour explicit.
Please double-check that this macro is available all the way down to the minimum PHP 7.x version you claim to support (7.0/7.1). If not, a small #if !defined(ZEND_PARSE_PARAMETERS_END_EX) shim will be required.

tests/002.phpt (1)

29-29: Expectation update aligns with new Zend-parsing error – looks good

The revised message matches the behaviour after switching to modern parameter parsing.

tests/005.phpt (1)

29-33: Updated expectations are consistent with new parsing semantics

The integer argument now passes the parser and fails inside zstd_uncompress, so the expected warning is correct.

@kjdev kjdev merged commit c121499 into master Jun 11, 2025
95 checks passed
@kjdev kjdev deleted the refactor/zend-parse-parameters branch June 11, 2025 22:59
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