Skip to content

refactor: Improve NestedSetsBehavior, NestedSetsQueryBehavior and tests; add PHPStan config. #5

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

Merged
merged 5 commits into from
Jun 26, 2025

Conversation

terabytesoftw
Copy link
Member

@terabytesoftw terabytesoftw commented Jun 26, 2025

Q A
Is bugfix? ✔️
New feature?
Breaks BC?

Summary by CodeRabbit

  • New Features

    • Introduced new configuration files for coding standards and static analysis, including Easy Coding Standard, Rector, and PHPStan Yii2 integration.
    • Added new scripts for code style checks, static analysis, and refactoring in development tools.
  • Bug Fixes

    • Improved multi-tree support and node relationship methods for nested sets functionality.
  • Refactor

    • Major refactor of nested sets behavior and query logic for improved clarity, robustness, and documentation.
    • Enhanced type safety and error handling throughout the codebase.
  • Chores

    • Updated and streamlined GitHub Actions workflows for builds, static analysis, and dependency checks.
    • Updated development dependencies and license from MIT to BSD-3-Clause.
    • Removed redundant or unnecessary doc comments from test and model files.
    • Improved configuration for static analysis and test caching.
  • Documentation

    • Added comprehensive PHPDoc comments and improved documentation for behaviors and methods.

@terabytesoftw terabytesoftw added the bug Something isn't working label Jun 26, 2025
Copy link

coderabbitai bot commented Jun 26, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

This update introduces significant refactoring and modernization across the codebase, focusing on enhanced static analysis, coding standards, and workflow automation. It adds new configuration files for Easy Coding Standard and Rector, updates PHPStan and Composer settings, revises GitHub Actions workflows, and refactors the core NestedSetsBehavior and NestedSetsQueryBehavior classes for improved clarity, documentation, and type safety.

Changes

File(s) / Group Change Summary
.github/workflows/build.yml, .github/workflows/compatibility.yml, .github/workflows/dependency-check.yml, .github/workflows/ecs.yml, .github/workflows/static.yml GitHub Actions workflows refactored: new ECS workflow added, compatibility workflow removed, triggers and parameters updated, jobs consolidated and improved.
LICENSE, LICENSE.md MIT license removed, BSD-3-Clause license introduced in LICENSE.md.
composer.json License changed to BSD-3-Clause, dependencies updated, scripts and allowed plugins revised for new tools and workflows.
ecs.php New ECS configuration file added for coding standards enforcement.
phpstan-yii-config.php, phpstan.neon, tests/config/phpstan-config.php Old PHPStan config removed, new config and custom behaviors for static analysis introduced, analysis level increased.
phpunit.xml.dist PHPUnit cache directory path updated.
rector.php New Rector configuration file added for automated code refactoring.
runtime/.gitignore New .gitignore added to exclude all files except itself in runtime directory.
src/NestedSetsBehavior.php Major refactor: improved PHPDoc, type safety, method clarity, new helper methods, stricter event handling, multi-tree support, and internal state management.
src/NestedSetsQueryBehavior.php Refactored with enhanced PHPDoc, helper methods, improved query logic, and error handling.
tests/NestedSetsBehaviorTest.php, tests/NestedSetsQueryBehaviorTest.php, tests/TestCase.php Imports reordered, formatting improved with trailing commas, no logic changes.
tests/Support/Model/MultipleTree.php, tests/Support/Model/Tree.php, tests/Support/Model/MultipleTreeQuery.php, tests/Support/Model/TreeQuery.php Redundant PHPDoc @inheritdoc comments removed, no functional changes.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant ActiveRecord
    participant NestedSetsBehavior
    participant Database

    User->>ActiveRecord: Calls appendTo()/insertBefore()/makeRoot()
    ActiveRecord->>NestedSetsBehavior: Triggers beforeInsert()/beforeUpdate()
    NestedSetsBehavior->>Database: Adjusts node boundaries (left/right/depth/tree)
    Database-->>NestedSetsBehavior: Updates performed
    NestedSetsBehavior->>ActiveRecord: Triggers afterInsert()/afterUpdate()
    ActiveRecord-->>User: Returns result (success/failure)
Loading

Poem

🐇
Hopping through the code so neat,
With standards crisp and tests complete,
New configs bloom and docs align,
The trees grow strong, their roots entwine.
Static checks and ECS in tow—
A garden where good code will grow!
🌱✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0a460b8 and c2e4d59.

📒 Files selected for processing (24)
  • .github/workflows/build.yml (1 hunks)
  • .github/workflows/compatibility.yml (0 hunks)
  • .github/workflows/dependency-check.yml (0 hunks)
  • .github/workflows/ecs.yml (1 hunks)
  • .github/workflows/static.yml (0 hunks)
  • LICENSE (0 hunks)
  • LICENSE.md (1 hunks)
  • composer.json (2 hunks)
  • ecs.php (1 hunks)
  • phpstan-yii-config.php (0 hunks)
  • phpstan.neon (1 hunks)
  • phpunit.xml.dist (1 hunks)
  • rector.php (1 hunks)
  • runtime/.gitignore (1 hunks)
  • src/NestedSetsBehavior.php (2 hunks)
  • src/NestedSetsQueryBehavior.php (1 hunks)
  • tests/NestedSetsBehaviorTest.php (8 hunks)
  • tests/NestedSetsQueryBehaviorTest.php (3 hunks)
  • tests/Support/Model/MultipleTree.php (0 hunks)
  • tests/Support/Model/MultipleTreeQuery.php (0 hunks)
  • tests/Support/Model/Tree.php (0 hunks)
  • tests/Support/Model/TreeQuery.php (0 hunks)
  • tests/TestCase.php (3 hunks)
  • tests/config/phpstan-config.php (1 hunks)
✨ 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.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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.

@terabytesoftw
Copy link
Member Author

@coderabbitai review

Copy link

coderabbitai bot commented Jun 26, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@terabytesoftw
Copy link
Member Author

@coderabbitai full

@terabytesoftw terabytesoftw requested a review from Copilot June 26, 2025 13:42
Copy link

coderabbitai bot commented Jun 26, 2025

Tip

For best results, initiate chat on the files or code changes.

@terabytesoftw I understand you want to trigger a full review. I'll interpret your truncated command as @coderabbitai full review.

✅ Actions performed

Full review triggered.

Note: This will conduct a comprehensive review from scratch, analyzing all files in the PR again, regardless of previous review status.

This full review will:

  • Re-examine all files in the PR from the beginning
  • Provide fresh analysis without relying on previous review comments
  • Help address any issues that may have been missed due to the previous review failure caused by head commit changes

The review should begin shortly and will analyze the entire changeset comprehensively.

Copy link

@Copilot 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

A refactor of NestedSetsBehavior and NestedSetsQueryBehavior to add richer type safety, documentation, and structure, plus updates to test files, static analysis, coding standards, and CI configuration.

  • Enhanced behaviors with PHPDoc, internal method extraction, and getOwner() guards
  • Removed redundant docblocks in test model stubs and updated import/order formatting
  • Added PHPStan, ECS, Rector configs; adjusted workflows and composer settings

Reviewed Changes

Copilot reviewed 24 out of 24 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/NestedSetsBehavior.php Comprehensive docblock and type declaration overhaul
src/NestedSetsQueryBehavior.php Added usage examples, getOwner() helper, and docs
tests/config/phpstan-config.php New PHPStan behavior mapping configuration
phpstan.neon Switched to bleeding‐edge, adjusted analysis level & parameters
.github/workflows/build.yml Added Codecov token, updated concurrency and compatibility jobs
Comments suppressed due to low confidence (2)

.github/workflows/build.yml:34

  • The phpunit-compatibility job under with: only specifies concurrency-group and extensions, but omits a composer-command which the php-forge/phpunit action typically requires. Add an explicit composer-command or verify the action’s defaults.
    with:

phpstan.neon:2

  • The indentation for the second includes entry is inconsistent and may break NEON parsing. Align the dash under includes: to match the first entry.
    - phar://phpstan.phar/conf/bleedingEdge.neon

@terabytesoftw
Copy link
Member Author

@coderabbitai full review

Copy link

coderabbitai bot commented Jun 26, 2025

✅ Actions performed

Full review triggered.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy