-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Added isEmpty / isNotEmpty / getIterator methods to Fluent class
#7466
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
Added isEmpty / isNotEmpty / getIterator methods to Fluent class
#7466
Conversation
- Add isEmpty() method to check if fluent instance has no attributes - Add isNotEmpty() method as convenience method returning \!isEmpty() - Include comprehensive unit tests covering various scenarios - Tests validate behavior with empty instances, different value types, dynamic setters, and array access 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
- Expand FluentTest.php with complete coverage of all public methods - Add tests for constructor with different input types (array, object, generator) - Add tests for all magic methods (__call, __get, __set, __isset, __unset, __toString) - Add tests for get method with default values and closures - Add tests for array conversion methods (toArray, jsonSerialize, toJson) - Add tests for ArrayAccess interface methods - Add tests for method chaining and complex data types - Fix code style issues (spacing, comments) - Total: 22 test methods covering all functionality 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
- Add entry for PR hyperf#7466 in v3.1.60 Added section - Document new isEmpty and isNotEmpty methods for Hyperf\Support\Fluent class 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds two new methods to the Fluent class for checking emptiness: isEmpty() to determine if a fluent instance has no attributes, and isNotEmpty() as a convenience method that returns the negation of isEmpty(). The implementation uses PHP's empty() function to check the internal attributes array.
- Added
isEmpty()method that returns true when the fluent instance has no attributes - Added
isNotEmpty()method as a convenience wrapper returning!isEmpty() - Comprehensive test coverage for both methods including edge cases with different data types
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/support/src/Fluent.php | Implements the two new methods with proper documentation |
| src/support/tests/FluentTest.php | Adds comprehensive test suite covering all Fluent functionality including the new methods |
| CHANGELOG-3.1.md | Documents the addition of the new methods |
Comments suppressed due to low confidence (1)
src/support/tests/FluentTest.php:280
- [nitpick] Testing array assignment with null key ($fluent[] = 'array_value') may not represent realistic usage and could mask potential issues with how null keys are handled in the Fluent class.
$this->assertEquals('array_value', $fluent->getAttributes()[null]);
|
|
||
| /** | ||
| * @internal | ||
| * @coversNothing |
Copilot
AI
Jul 25, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The @coversNothing annotation and #[CoversNothing] attribute are redundant. Consider using only the PHP 8 attribute syntax.
| * @coversNothing |
| $fluent = new Fluent([ | ||
| 'array' => [1, 2, 3], | ||
| 'object' => $object, | ||
| 'closure' => function () { return 'test'; }, |
Copilot
AI
Jul 25, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The closure in the test data is defined but never executed in the test. Consider either executing it to test closure handling or removing it if not needed.
Integrated Hyperf\Macroable\Macroable into the Fluent class to allow dynamic method macros. Updated __call to prioritize macros when available. Added comprehensive tests for macro functionality, including macro definition, usage, chaining, overriding, and mixins.
isEmpty / isNotEmpty / getIterator methods to Fluent class
Summary
isEmpty()method to check if fluent instance has no attributesisNotEmpty()method as convenience method returning\!isEmpty()Test plan
🤖 Generated with Claude Code