Skip to content

Conversation

@huangdijia
Copy link
Member

Summary

This PR fixes two issues:

  1. Macroable trait validation: Added validation to prevent macros with reference parameters, which can cause unexpected behavior and potential issues
  2. Redis adapter formatting: Fixed formatting inconsistencies in LUA scripts within the Prometheus Redis adapter

Changes

  • Added parameter validation in Macroable::macro() method to detect and reject closures with reference parameters
  • Added InvalidArgumentException with descriptive error message when reference parameters are detected
  • Added comprehensive test case to ensure reference parameter validation works correctly
  • Fixed formatting issues in Redis adapter LUA scripts (removed extra newlines for consistency)

Testing

  • Added new test case testParametersPassedByReference() in MacroableTest.php
  • All existing tests continue to pass
  • Manual verification of the changes

Impact

  • Breaking change: Macros with reference parameters will now throw InvalidArgumentException
  • Code quality: Improved consistency in Redis adapter code formatting
  • Stability: Prevents potential issues with macro binding and reference parameters

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Documentation update

…pter formatting

- Added validation in Macroable trait to prevent macros with reference parameters
- Added InvalidArgumentException with descriptive message for reference parameter detection
- Added comprehensive test case for reference parameter validation
- Fixed formatting issues in Redis adapter LUA scripts (removed extra newlines)
- Improved code consistency in Prometheus Redis adapter
@huangdijia huangdijia changed the title Fix macro validation for reference parameters and Redis formatting Fix macro validation for reference parameters Aug 17, 2025
@limingxinleo limingxinleo merged commit afdceb0 into hyperf:master Aug 18, 2025
70 of 71 checks passed
@huangdijia huangdijia deleted the fix/macroable-reference-validation branch August 18, 2025 08:15
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