Skip to content

Conversation

@huangdijia
Copy link
Member

Summary

  • 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

Test plan

  • Unit tests pass for both new methods
  • Tests cover empty instances, different value types, dynamic setters, and array access
  • All existing tests continue to pass

🤖 Generated with Claude Code

huangdijia and others added 2 commits July 25, 2025 21:20
- 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>
@huangdijia huangdijia changed the title Add isEmpty and isNotEmpty methods to Fluent class Added isEmpty and isNotEmpty methods to Fluent class Jul 25, 2025
- 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>
Copy link

Copilot AI left a 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
Copy link

Copilot AI Jul 25, 2025

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.

Suggested change
* @coversNothing

Copilot uses AI. Check for mistakes.
$fluent = new Fluent([
'array' => [1, 2, 3],
'object' => $object,
'closure' => function () { return 'test'; },
Copy link

Copilot AI Jul 25, 2025

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.

Copilot uses AI. Check for mistakes.
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.
@huangdijia huangdijia changed the title Added isEmpty and isNotEmpty methods to Fluent class Added isEmpty / isNotEmpty / getIterator methods to Fluent class Jul 31, 2025
@limingxinleo limingxinleo merged commit 0808853 into hyperf:master Aug 2, 2025
71 checks passed
@huangdijia huangdijia deleted the feature/fluent-isEmpty-isNotEmpty branch August 2, 2025 07:16
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