Skip to content

Conversation

@huangdijia
Copy link
Contributor

@huangdijia huangdijia commented Jul 15, 2025

  • Added doesntEndWith() macro to StrMixin that returns the inverse of endsWith()
  • Added doesntStartWith() macro to StrMixin that returns the inverse of startsWith()
  • Added doesntEndWith() macro to StringableMixin for fluent string operations
  • Added doesntStartWith() macro to StringableMixin for fluent string operations
  • Added comprehensive unit tests covering edge cases including empty strings and arrays
  • All tests pass and follow existing code patterns

🤖 Generated with Claude Code

Summary by CodeRabbit

  • 新功能

    • 字符串工具类新增了 doesEndWith 和 doesStartWith 的反向方法,可判断字符串是否“不以”指定内容开头或结尾。
  • 文档

    • 增加了面向开发者和自动化工具的详细项目说明文档。
    • 新增了解决 GitHub Issue 的操作指南文档。
  • 测试

    • 为新增的字符串反向判断方法补充了全面的测试用例,覆盖多种场景和边界情况。

- Added doesntEndWith() macro to StrMixin that returns the inverse of endsWith()
- Added doesntStartWith() macro to StrMixin that returns the inverse of startsWith()
- Added doesntEndWith() macro to StringableMixin for fluent string operations
- Added doesntStartWith() macro to StringableMixin for fluent string operations
- Added comprehensive unit tests covering edge cases including empty strings and arrays
- All tests pass and follow existing code patterns

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@coderabbitai
Copy link

coderabbitai bot commented Jul 15, 2025

Walkthrough

此次变更新增了两份文档文件,分别为针对 Claude AI 的项目指导和修复 GitHub Issue 的操作指南。同时在 StrMixinStringableMixin 类中新增了 doesntEndWithdoesntStartWith 方法,并为这些新方法补充了相应的测试用例。

Changes

文件/分组 变更摘要
.claude/CLAUDE.md 新增面向 Claude AI 的详细项目结构、开发流程和集成文档。
.claude/commands/fix-github-issue.md 新增 GitHub Issue 修复操作指南,详细说明分析和提交流程。
src/macros/src/StrMixin.php
src/macros/src/StringableMixin.php
在两个 Mixin 类中分别新增 doesntEndWithdoesntStartWith 方法,提供字符串前后缀的否定判断。
tests/Macros/StrTest.php
tests/Macros/StringableTest.php
新增上述新方法的单元测试,覆盖多种输入和边界情况。

Sequence Diagram(s)

sequenceDiagram
    participant 调用者
    participant StrMixin
    participant StringableMixin

    调用者->>StrMixin: doesntEndWith($haystack, $needles)
    StrMixin->>Str: endsWith($haystack, $needles)
    Str-->>StrMixin: bool
    StrMixin-->>调用者: !endsWith 结果

    调用者->>StrMixin: doesntStartWith($haystack, $needles)
    StrMixin->>Str: startsWith($haystack, $needles)
    Str-->>StrMixin: bool
    StrMixin-->>调用者: !startsWith 结果

    调用者->>StringableMixin: doesntEndWith($needles)
    StringableMixin->>Stringable: endsWith($needles)
    Stringable-->>StringableMixin: bool
    StringableMixin-->>调用者: !endsWith 结果

    调用者->>StringableMixin: doesntStartWith($needles)
    StringableMixin->>Stringable: startsWith($needles)
    Stringable-->>StringableMixin: bool
    StringableMixin-->>调用者: !startsWith 结果
Loading

Poem

🐇
新增文档指路明,
字符串方法更聪明。
前后缀否定查,
测试覆盖细如麻。
贡献流程步步清,
代码小兔乐开花!

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 PHPStan (2.1.17)

Note: Using configuration file /phpstan.neon.dist.
At least one path must be specified to analyse.

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@huangdijia huangdijia marked this pull request as ready for review July 15, 2025 00:19
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (4)
.claude/CLAUDE.md (2)

7-8: 项目规模描述建议使用更灵活的措辞
“40+ modular packages” 随时间推移容易失真,可改为“数十个”或“几十个”,避免日后维护成本。


107-112: 代码标准段落缺少 CS Fixer 规则来源说明
建议补充 .php-cs-fixer.php 所使用的规则集或链接,方便贡献者了解格式要求。

.claude/commands/fix-github-issue.md (2)

1-2: 占位符变量不够直观
$ARGUMENTS 未说明具体格式,例如 “issue-number” 还是 “owner/repo#number”。建议改为更明确的 <ISSUE_NUMBER> 并在开头给出示例。


8-10: 动词“implement”略口语,可替换为更正式表述
将 “Implement the necessary changes” 调整为 “Apply the necessary changes” 或 “Make the necessary modifications”,使语气与其余步骤保持一致。

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8dba0ef and 377ea22.

📒 Files selected for processing (6)
  • .claude/CLAUDE.md (1 hunks)
  • .claude/commands/fix-github-issue.md (1 hunks)
  • src/macros/src/StrMixin.php (1 hunks)
  • src/macros/src/StringableMixin.php (1 hunks)
  • tests/Macros/StrTest.php (1 hunks)
  • tests/Macros/StringableTest.php (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (2)
src/macros/src/StrMixin.php (2)
src/macros/src/StringableMixin.php (2)
  • doesntEndWith (84-88)
  • doesntStartWith (90-94)
src/macros/output/Hyperf/Stringable/Str.php (1)
  • Str (14-70)
src/macros/src/StringableMixin.php (1)
src/macros/src/StrMixin.php (2)
  • doesntEndWith (76-81)
  • doesntStartWith (83-88)
🪛 LanguageTool
.claude/commands/fix-github-issue.md

[style] ~8-~8: Consider using a different verb for a more formal wording.
Context: ...s 4. Implement the necessary changes to fix the issue 5. Write and run tests to ver...

(FIX_RESOLVE)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (9)
  • GitHub Check: Test on PHP 8.2 with Swoole 5.1.7
  • GitHub Check: Test on PHP 8.2 with Swoole 6.0.2
  • GitHub Check: Test on PHP 8.1 with Swoole 5.1.7
  • GitHub Check: Test on PHP 8.3 with Swoole 5.1.7
  • GitHub Check: Test on PHP 8.1 with Swoole 6.0.2
  • GitHub Check: Test on PHP 8.3 with Swoole 6.0.2
  • GitHub Check: Test on PHP 8.1 with Swoole 5.1.7
  • GitHub Check: Test on PHP 8.2 with Swoole 5.1.7
  • GitHub Check: Test on PHP 8.3 with Swoole 5.1.7
🔇 Additional comments (5)
.claude/CLAUDE.md (1)

26-28: 脚本名称与常见约定不一致
多数团队使用 composer analyze 而不是 composer analyse。若当前仓库脚本名为 analyse 没问题;若并不存在,将导致文档误导。请确认并保持一致。

src/macros/src/StrMixin.php (1)

76-88: 实现正确,遵循了现有代码模式

新增的 doesntEndWithdoesntStartWith 方法实现正确,通过对现有 Str::endsWithStr::startsWith 方法结果取反来提供逆向功能。方法签名和闭包结构与该类中其他方法保持一致。

tests/Macros/StrTest.php (1)

68-86: 测试覆盖全面且实现正确

新增的测试用例覆盖了各种场景,包括单个字符串、字符串数组、空字符串等边界情况。测试逻辑正确,断言清晰,与现有测试风格保持一致。

src/macros/src/StringableMixin.php (1)

84-94: Stringable 上下文的实现正确

新增的方法正确地适配了 Stringable 对象上下文,使用 $this->endsWith()$this->startsWith() 实例方法而非静态方法。包含了必要的 PHPStan 忽略注释,与类中其他方法的模式保持一致。

tests/Macros/StringableTest.php (1)

88-106: Stringable 对象的测试实现完整

测试用例正确使用了 $this->stringable() 辅助方法,提供了与 StrTest 相对应的测试覆盖。测试场景全面,包括各种边界情况,断言逻辑正确。

@huangdijia huangdijia merged commit 0cb04db into main Jul 15, 2025
17 checks passed
@huangdijia huangdijia deleted the feature/add-doesnt-start-end-with-macros branch July 15, 2025 00:21
huangdijia added a commit that referenced this pull request Jul 15, 2025
)

- Added doesntEndWith() macro to StrMixin that returns the inverse of endsWith()
- Added doesntStartWith() macro to StrMixin that returns the inverse of startsWith()
- Added doesntEndWith() macro to StringableMixin for fluent string operations
- Added doesntStartWith() macro to StringableMixin for fluent string operations
- Added comprehensive unit tests covering edge cases including empty strings and arrays
- All tests pass and follow existing code patterns

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-authored-by: Deeka Wong <8337659+huangdijia@users.noreply.github.com>
Co-authored-by: Claude <noreply@anthropic.com>
@coderabbitai coderabbitai bot mentioned this pull request Oct 29, 2025
3 tasks
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