-
-
Notifications
You must be signed in to change notification settings - Fork 2
refactor: Update PHPStan
configuration paths and create new config files for improved structure and clarity.
#48
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
Conversation
…files for improved structure and clarity.
WalkthroughConfiguration file paths throughout the project were updated from Changes
Sequence Diagram(s)sequenceDiagram
participant PHPStan
participant ProjectConfig
participant RuntimeDir
PHPStan->>ProjectConfig: Load config from phpstan-config.php
PHPStan->>RuntimeDir: Use tmpDir for temp files (%cwd%/tests/runtime)
Note right of PHPStan: All analysis uses updated config paths and tmpDir
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (8)
✅ Files skipped from review due to trivial changes (3)
🚧 Files skipped from review as they are similar to previous changes (5)
⏰ Context from checks skipped due to timeout of 90000ms (18)
✨ Finishing Touches
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed 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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
…nfig.php` for consistency.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #48 +/- ##
===========================================
Coverage 100.00% 100.00%
Complexity 71 71
===========================================
Files 2 2
Lines 129 129
===========================================
Hits 129 129 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
Actionable comments posted: 0
🔭 Outside diff range comments (1)
README.md (1)
70-86
: Documentation path mismatch: snippet still instructs to createconfig/test.php
The sample
phpstan.neon
now expectsyii2: config_path: config/phpstan-config.phpbut the paragraph right below says “Create a PHPStan-specific config file (
config/test.php
).”
This inconsistency will confuse users.-Create a PHPStan-specific config file (`config/test.php`). +Create a PHPStan-specific config file (`config/phpstan-config.php`).Update the filename everywhere (and in the code block header if present).
♻️ Duplicate comments (1)
tests/ServiceMapTest.php (1)
40-42
: Apply the same DRY helper for config pathsThese two snippets duplicate the logic already noted in
ServiceMapBehaviorTest.php
. Once a helper/constant is introduced, switch to:$configPath = self::CONFIG_BASE . 'phpstan-config.php'; // web $configPath = self::CONFIG_BASE . 'console/phpstan-console-config.php'; // console(replace with whatever helper you decide on).
Also applies to: 56-58
🧹 Nitpick comments (5)
CHANGELOG.md (1)
18-18
: Consider mentioningtmpDir
addition.The entry summarizes config path updates but omits the new
tmpDir
parameter. You may want to note the addition of the runtime directory in the changelog.tests/StubFilesExtensionTest.php (1)
31-34
: Avoid hard-coding identical path construction in every testNearly every test class now repeats
$ds = DIRECTORY_SEPARATOR; $configPath = __DIR__ . "{$ds}config{$ds}phpstan-config.php";Consider extracting a helper (e.g.
TestCaseWithConfig::getConfigPath()
) or defining aconst CONFIG_PATH
in a base test to reduce duplication and the risk of typos when the path changes again.tests/ServiceMapServiceTest.php (1)
60-72
: Repeated$configPath
construction clutters the test fileThe same 3-line snippet is duplicated nine times. A tiny helper will make the intent clearer and centralise future changes:
+ private static function configPath(): string + { + return __DIR__ . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'phpstan-config.php'; + } ... - $ds = DIRECTORY_SEPARATOR; - $configPath = __DIR__ . "{$ds}config{$ds}phpstan-config.php"; - $serviceMap = new ServiceMap($configPath); + $serviceMap = new ServiceMap(self::configPath());This keeps each test focused on its assertion and eliminates duplicated string interpolation.
Also applies to: 84-88, 100-104, 116-120, 132-136, 148-152, 164-168, 180-184, 196-200
tests/ServiceMapComponentTest.php (1)
40-58
: Same duplication issue – extract a helper in a base test
ServiceMapComponentTest
repeats the identical path building logic four times.
Re-use the helper/constant suggested forServiceMapServiceTest
to keep tests DRY.Also applies to: 72-90, 104-122, 134-138
tests/ServiceMapBehaviorTest.php (1)
40-42
: Factor-out repeated config-path constructionEvery test re-builds the same path string; this is four identical snippets in this file (and appears in other test classes, too). Replacing the duplication with a small helper or constant will cut noise and make future renames cheaper:
-final class ServiceMapBehaviorTest extends TestCase +final class ServiceMapBehaviorTest extends TestCase { + private const CONFIG_BASE = __DIR__ . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR; + public function testReturnBehaviorsWhenValidClassIsClassString(): void { - $ds = DIRECTORY_SEPARATOR; - $configPath = __DIR__ . "{$ds}config{$ds}phpstan-config.php"; + $configPath = self::CONFIG_BASE . 'phpstan-config.php';Same simplification applies to the other three occurrences and the sibling test classes.
Also applies to: 61-63, 82-84, 100-102
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (13)
CHANGELOG.md
(1 hunks)README.md
(1 hunks)docs/configuration.md
(12 hunks)docs/installation.md
(4 hunks)phpstan.neon
(2 hunks)tests/ServiceMapBehaviorTest.php
(4 hunks)tests/ServiceMapComponentTest.php
(7 hunks)tests/ServiceMapServiceTest.php
(9 hunks)tests/ServiceMapTest.php
(2 hunks)tests/StubFilesExtensionTest.php
(1 hunks)tests/console/extension-console-test.neon
(1 hunks)tests/extension-test.neon
(1 hunks)tests/runtime/.gitignore
(1 hunks)
🧰 Additional context used
🧠 Learnings (1)
docs/configuration.md (1)
Learnt from: terabytesoftw
PR: yii2-extensions/phpstan#40
File: src/ServiceMap.php:0-0
Timestamp: 2025-06-14T17:41:48.780Z
Learning: The yii2-extensions/phpstan repository contains a PHPStan extension specifically designed for static analysis of Yii framework applications.
⏰ Context from checks skipped due to timeout of 90000ms (6)
- GitHub Check: phpunit-compatibility / PHP 8.1-windows-latest
- GitHub Check: phpunit-compatibility / PHP 8.2-windows-latest
- GitHub Check: phpunit-compatibility / PHP 8.3-windows-latest
- GitHub Check: phpunit-compatibility / PHP 8.4-windows-latest
- GitHub Check: phpunit / PHP 8.4-windows-latest
- GitHub Check: phpunit-compatibility / PHP 8.1-windows-latest
🔇 Additional comments (11)
tests/runtime/.gitignore (1)
1-2
: Configuration directory properly ignored.The
.gitignore
correctly omits all runtime files except the.gitignore
itself, aligning with thetmpDir
setting.phpstan.neon (2)
20-20
: AddtmpDir
for PHPStan runtime files.The new
tmpDir
parameter points totests/runtime
, matching the.gitignore
and ensuring temp files don’t clutter the repo.
33-33
: Updateyii2.config_path
.Changed path to
tests/config/phpstan-config.php
aligns with the relocated config fixtures.docs/installation.md (5)
91-91
: DocumenttmpDir
parameter.The
tmpDir
entry reflects the new runtime directory setting, ensuring docs mirror the config.
94-94
: Update exampleconfig_path
.Changed to
config/phpstan-config.php
to match the new filename in instructions.
103-103
: Clarify creation of web config.Instruction to create
config/phpstan-config.php
is clear and matches code.
144-144
: Clarify creation of console config.Instruction to create
config/phpstan-console-config.php
correctly documents the console setup.
170-170
: Update consoleconfig_path
in docs.Example now points to
config/phpstan-console-config.php
, matching the file rename.tests/console/extension-console-test.neon (1)
6-6
: Update console test config path.Revised to point at
tests/console/config/phpstan-console-config.php
, aligning with relocated config fixture.tests/extension-test.neon (1)
6-6
: Confirm the new relative path is resolvable by PHPStan when executed from project root
%rootDir%
points to PHPStan’s vendor directory, so the resulting path will be
vendor/phpstan/phpstan/../../../tests/config/phpstan-config.php
→ effectivelytests/config/phpstan-config.php
.
That looks correct, but an unnoticed../
mismatch would silently break all tests.Please run a quick
realpath()
check (or let CI runphpstan analyse
) to verify the file is really picked up.docs/configuration.md (1)
17-22
: Docs update LGTMRenamed
config_path
references and the newtmpDir
default are consistently reflected. No further action needed.Also applies to: 37-42, 51-55, 61-64, 78-82, 104-108, 290-305, 328-342
…nd update paths in configuration files.
…` console config file for consistency.
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 refactors PHPStan configuration by renaming config files, updating paths in tests and docs, and centralizing test config directory handling.
- Renamed PHPStan config files to
phpstan-config.php
andphpstan-console-config.php
and updated all references. - Updated
phpstan.neon
andphpstan-console.neon
to settmpDir
and newconfig_path
. - Refactored test classes to use a shared
BASE_PATH
constant and added.gitignore
for runtime files. - Updated documentation and README to reflect new filenames and temporary directory instructions.
Reviewed Changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 1 comment.
Show a summary per file
File | Description |
---|---|
tests/runtime/.gitignore | Added ignore rule for runtime cache files |
tests/extension-test.neon | Updated config_path to new PHPStan config filename |
tests/console/extension-console-test.neon | Updated config_path to new PHPStan console config filename |
tests/StubFilesExtensionTest.php | Updated test to use renamed config file |
tests/ServiceMapTest.php | Introduced BASE_PATH constant and updated config references |
tests/ServiceMapServiceTest.php | Introduced BASE_PATH constant and updated config references |
tests/ServiceMapComponentTest.php | Introduced BASE_PATH constant and updated config references |
tests/ServiceMapBehaviorTest.php | Introduced BASE_PATH constant and updated config references |
phpstan.neon | Set tmpDir and updated yii2.config_path |
phpstan-console.neon | Set tmpDir and updated yii2.config_path |
docs/installation.md | Updated example filenames and added tmpDir instructions |
docs/configuration.md | Updated example filenames, added tmpDir and excludePaths |
README.md | Updated example filenames and added tmpDir instructions |
CHANGELOG.md | Added entry for updating PHPStan configuration paths |
Comments suppressed due to low confidence (2)
tests/ServiceMapServiceTest.php:42
- [nitpick] The constant name
BASE_PATH
is generic. Consider renaming it to something more descriptive likeCONFIG_BASE_PATH
to clarify its purpose.
private const BASE_PATH = __DIR__ . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR;
docs/configuration.md:21
- [nitpick] The
tmpDir
parameter is repeated multiple times across this document. Consider consolidating common parameters or using includes to avoid duplication and reduce maintenance.
tmpDir: %currentWorkingDirectory%/tests/runtime
Summary by CodeRabbit