Skip to content

Issue/633 Reduce the repeated base directory lookups - #637

Merged
armanist merged 1 commit into
quantum-php:3.1.xfrom
armanist:issue/633-reduce-base-dir-lookups
Oct 29, 2026
Merged

armanist merged 1 commit into
quantum-php:3.1.xfrom
armanist:issue/633-reduce-base-dir-lookups

Conversation

@armanist

@armanist armanist commented Oct 29, 2026 •

Copy link
Copy Markdown
Collaborator

Refs #633. This pull request targets 3.1.x, so it does not close the issue; the merge of 3.1.x into master does.

What changed

  • EnvCommand::exec(), Environment::resolveEnvironmentFile(), Config::resolveFilePath() and ViewCache::getCacheDir() read the base directory once instead of asking for it several times in the same method.
  • LoadHelpersStage builds the module helpers path with modules_dir() instead of rebuilding it by hand.
  • ViewCache::getCacheDir() was not in the ticket's list; it asked for the base directory twice in one method, which the acceptance criteria rule out.
  • No shared_dir() helper: it would be a new public helper in a patch release to save a few repeated 'shared' . DS . 'config' strings, and the ticket allows leaving them.

Why

Readability: the same call was repeated in one method, and one path was rebuilt although a helper exists. App::getBaseDir() is cheap, so this is not about speed.

Breaking changes

None. No behavior, signature or public name changes.

Testing

  • New tests for ViewCache::getCacheDir(), which had none: without a module (<base>/cache/views) and with module Test (<base>/cache/views/test). They pass on the code before and after the change, which shows the behavior is unchanged.
  • The other touched code is covered by the existing EnvCommandTest, LoadHelpersStageTest and the Environment and Config tests.

Notes for reviewers

  • This is the first pull request into 3.1.x after .coderabbit.yaml was merged, so it also shows whether CodeRabbit now reviews pull requests into maintenance branches.

Summary by CodeRabbit

  • Refactor
    • Standardized directory path handling across environment, configuration, helper, and view-cache operations. Existing behavior remains unchanged.
  • Tests
    • Added coverage confirming view-cache directories are selected correctly with and without a module.

…ral times

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between ba60194 and a846e11.

Files selected for processing: 7
  • CHANGELOG.md
  • src/App/Stages/Boot/LoadHelpersStage.php
  • src/Config/Config.php
  • src/Console/Commands/EnvCommand.php
  • src/Environment/Environment.php
  • src/ResourceCache/ViewCache.php
  • tests/Unit/ResourceCache/ViewCacheTest.php

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

Walkthrough

Several components now capture and reuse the base directory when building paths. Module helper loading uses modules_dir(), and view-cache paths append the lowercased module name when one is present. Tests cover view-cache paths with and without a module.

Changes: Path construction cleanup

Layer / File(s) Summary
Reuse the base directory in environment and configuration paths
src/Config/Config.php, src/Console/Commands/EnvCommand.php, src/Environment/Environment.php, CHANGELOG.md
These components reuse one base-directory value for path construction and file checks. The changelog records these updates and the helper-path change.
Build module-related paths from existing directories
src/App/Stages/Boot/LoadHelpersStage.php, src/ResourceCache/ViewCache.php, tests/Unit/ResourceCache/ViewCacheTest.php
LoadHelpersStage uses modules_dir() as the module-helper path root. ViewCache appends the lowercased module name to its existing cache directory. Tests check cache-directory selection with and without a module.

Priority: Low

Estimated code review effort: 2 (Simple) | ~8 minutes

Change: Refactor

Possibly related issues

  • quantum-php/framework#633 — The issue describes the same base-directory reuse and module-helper path cleanup.

Possibly related PRs

Suggested reviewers: hatik92, andrey-smaelov

Merge Risk: Minimal · up to a846e

No actionable merge-blocking risk was identified; the changes preserve existing path behavior.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 75.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documenta… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the primary change: reducing repeated base directory lookups across the affected methods.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 75.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 4 functions across 6 files. (1 skipped: 1 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Oct 29, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@armanist
armanist requested a review from artem-dev2 October 29, 2026 13:23
@armanist
armanist merged commit 99e3baf into quantum-php:3.1.x Oct 29, 2026
6 checks passed
@armanist
armanist deleted the issue/633-reduce-base-dir-lookups branch October 29, 2026 14:05
@coderabbitai coderabbitai Bot mentioned this pull request Oct 29, 2026
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