Optimized the Hyperf\Amqp\Message\Message::getTypeString() method to prevent conflicts between property and getter methods.#7741
Conversation
…avoid the conflict of property and getter.
There was a problem hiding this comment.
Pull request overview
This PR addresses Hyperf issue #7634 by updating how AMQP message exchange types are converted to strings, ensuring delayed-exchange declarations respect overridden getType() implementations in subclasses.
Changes:
- Updated
Message::getTypeString()to derive the type viagetType()instead of reading the$typeproperty directly. - Added a changelog entry documenting the update in the 3.1 line.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/amqp/src/Message/Message.php |
Makes getTypeString() honor overridden getType() to avoid delayed-exchange type mismatches. |
CHANGELOG-3.1.md |
Records the change for the upcoming 3.1.68 release notes. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| ## Optimized | ||
|
|
||
| - [#7741](https://github.com/hyperf/hyperf/pull/7741) Optimized the `Hyperf\Amqp\Message\Message::getTypeString()` method to prevent conflicts between property and getter methods. | ||
|
|
There was a problem hiding this comment.
This entry describes a bug fix for #7634 (incorrect delayed exchange type), so it likely belongs under the "## Fixed" section rather than "## Optimized" to keep release notes consistent with the rest of the changelog.
| ## Optimized | |
| - [#7741](https://github.com/hyperf/hyperf/pull/7741) Optimized the `Hyperf\Amqp\Message\Message::getTypeString()` method to prevent conflicts between property and getter methods. | |
| - [#7741](https://github.com/hyperf/hyperf/pull/7741) Fixed bug that the `Hyperf\Amqp\Message\Message::getTypeString()` method may conflict between property and getter methods. |
| $type = $this->getType(); | ||
| return $type instanceof Type ? $type->value : $type; |
There was a problem hiding this comment.
There are existing AMQP PHPUnit tests, but this behavior change (routing delayed exchange argument x-delayed-type now respecting overridden getType()) is not covered. Please add/adjust a test to assert that when a producer overrides getType() to return a different Type value, getTypeString() reflects it (and thus delayed exchange builder uses the expected string).
fix #7634