Skip to content

[ECO-5183] Added support for PHP 8.4#210

Merged
sacOO7 merged 3 commits intomainfrom
fix/php-8.4-deprecation-notice
Mar 5, 2025
Merged

[ECO-5183] Added support for PHP 8.4#210
sacOO7 merged 3 commits intomainfrom
fix/php-8.4-deprecation-notice

Conversation

@sacOO7
Copy link
Copy Markdown
Collaborator

@sacOO7 sacOO7 commented Mar 3, 2025

Fixed #206

Summary by CodeRabbit

  • Chores

    • Updated testing configuration to support PHP 8.4, ensuring smoother compatibility.
  • Refactor

    • Refined public messaging behavior to better handle optional values, enhancing clarity and robustness.
  • Tests

    • Improved validation checks in tests to prevent issues with missing message properties.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 3, 2025

Walkthrough

This pull request updates the GitHub Actions workflow to include PHP 8.4 in the test matrix. It also modifies two static methods in the BaseMessage class to allow nullable CipherParams, thereby making their intent clearer. Additionally, a unit test in ChannelMessagesTest now checks for the existence of the "encoding" property before asserting its value, which helps prevent potential errors.

Changes

File(s) Change Summary
.github/workflows/check.yml Updated the PHP version matrix to include PHP 8.4.
src/Models/BaseMessage.php Modified the method signatures for fromEncoded and fromEncodedArray to use ?CipherParams (allowing null) instead of CipherParams.
tests/ChannelMessagesTest.php Added a property_exists check in testEncodingInteroperabilityAblyToRaw before asserting the encoding property.

Poem

I'm a rabbit, hopping through code so free,
Testing new PHP versions with glee.
Methods now gracefully accept null's sweet call,
And tests ensure properties exist, one and all.
With each small change, I twitch my nose in delight!


📜 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 420f97d and ab6853e.

📒 Files selected for processing (3)
  • .github/workflows/check.yml (1 hunks)
  • src/Models/BaseMessage.php (2 hunks)
  • tests/ChannelMessagesTest.php (1 hunks)
🔇 Additional comments (5)
.github/workflows/check.yml (1)

17-17: Good addition of PHP 8.4 support to the test matrix

This change adds PHP 8.4 to the test matrix, ensuring that the library is tested against the latest PHP version.

tests/ChannelMessagesTest.php (1)

544-546: Good defensive programming adding a property existence check

This change makes the test more robust by checking if the encoding property exists before attempting to assert its value. This helps prevent potential test failures when handling responses that might not include this property.

src/Models/BaseMessage.php (3)

117-117: Improved type declaration using nullable type hint

The addition of the nullable type hint (?) before CipherParams makes the parameter type declaration more expressive, clearly indicating that the method accepts either a CipherParams object or null. This is aligned with modern PHP type system best practices (available since PHP 7.1).


141-141: Improved type declaration using nullable type hint

Similar to the fromEncoded method, this change adds a nullable type hint to make the parameter type declaration more expressive. This maintains consistency across related methods and follows modern PHP type system best practices.


117-134:

Details

✅ Verification successful

Verify compatibility with PHP 7.2

Since the PR is supporting PHP 8.4 while maintaining compatibility with PHP 7.2+, it's worth verifying that the nullable type hint syntax works correctly in all supported PHP versions.

Also applies to: 141-146


🏁 Script executed:

#!/bin/bash
# Check PHP version compatibility for nullable type hints

# The '?' nullable type hint was introduced in PHP 7.1
# Let's check if all PHP versions in the test matrix are >= 7.1
echo "Checking PHP version compatibility with nullable type hints..."
echo "Nullable type hints were introduced in PHP 7.1"
echo "PHP versions in test matrix: 7.2, 7.3, 7.4, 8.0, 8.1, 8.2, 8.3, 8.4"
echo "All versions are >= 7.1, so nullable type hints are supported."

# Also check if there are any other usages of the CipherParams type that might need similar updates
echo -e "\nChecking for other CipherParams parameter usages that might need updating:"
rg -A 2 "function.*CipherParams \$" --glob="*.php"

Length of output: 734


Action: Confirm PHP version compatibility and CipherParams usage

The usage of nullable type hints (introduced in PHP 7.1) is confirmed to be compatible with all supported versions (PHP 7.2 through 8.4). A comprehensive search for additional usages of the CipherParams type in PHP files produced no results, indicating no other parts of the codebase require similar updates.

  • The ?CipherParams type hint in fromEncoded (and similarly in lines 141-146) is valid.
  • No further occurrences of CipherParams needing update were detected.

Please verify manually for any edge cases, although automated checks did not reveal issues.

✨ Finishing Touches
  • 📝 Generate Docstrings

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ 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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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.

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 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.

@github-actions github-actions bot temporarily deployed to staging/pull/210/features March 3, 2025 10:27 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/210/features March 4, 2025 13:23 Inactive
@sacOO7 sacOO7 merged commit eaecef2 into main Mar 5, 2025
18 checks passed
@sacOO7 sacOO7 deleted the fix/php-8.4-deprecation-notice branch March 5, 2025 10:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

PHP 8.4 Deprecations - Implicitly marking parameter $cipherParams as nullable is deprecated

2 participants