Added methods Hyperf\Collection\Arr::push() and Hyperf\Collection\Arr::array().#7500
Merged
limingxinleo merged 4 commits intohyperf:masterfrom Sep 3, 2025
Merged
Conversation
- Add push method to Hyperf\Collection\Arr based on Laravel PR #56632 - Allows pushing items into arrays using dot notation - Includes comprehensive test coverage for nested arrays and edge cases - Matches Laravel's implementation and API
4dd62e2 to
f3079b1
Compare
huangdijia
commented
Aug 18, 2025
Member
Author
huangdijia
left a comment
There was a problem hiding this comment.
🔍 代码审查结果
✅ 总体评价
这是一个高质量的 PR!功能实现正确,测试覆盖全面,代码风格符合项目规范。
💪 优点
- 类型安全: 使用了现代 PHP 的联合类型和严格类型检查
- 测试完整: 覆盖了正常流程、边界情况和异常情况
- 架构合理: 通过复用现有的
get()和set()方法实现功能 - 兼容性好: 与 Laravel 的实现保持一致
- CI/CD: 所有 65 项检查全部通过 ✅
📝 小建议
array() 方法的注释可以更准确一些:
/**
* Get an array value from an array using "dot" notation, ensuring the result is an array.
*/当前的注释 "Get an array item from an array" 有些模糊,建议强调这个方法的核心作用是确保返回值是数组类型。
🧪 测试评价
测试用例设计得很好:
- ✅ 嵌套数组的点记法推送
- ✅ 多值推送
- ✅ 根级数组推送 (null key)
- ✅ 异常情况处理
🎯 评分: 9.5/10
除了注释需要小幅优化外,其他方面表现优秀。推荐合并 🚀
这个功能将大大提升数组操作的便利性,为 Hyperf 框架增加了实用价值。
Hyperf\Collection\Arr::push() and Hyperf\Collection\Arr::array().
limingxinleo
approved these changes
Sep 3, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds the
pushmethod to theHyperf\Collection\Arrclass, following the implementation from Laravel PR #56632.Changes
pushmethod toArrclass that allows pushing items into arrays using dot notationFeatures
Usage Examples
Tests
All tests are passing, including edge cases and exception scenarios.