Discover providers from the project itself.#84
Conversation
📝 WalkthroughWalkthroughModifies manifest recompilation checks in ContainerMixinManifest and PackageManifest to also account for the project's root composer.json, adds extraction of root-level extra.faker configuration in PackageManifest, adjusts argument order in a Method tag call, and adds a test support composer.json fixture. ChangesManifest Root composer.json Handling
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
♻️ Duplicate comments (1)
src/Manifests/ContainerMixinManifest.php (1)
145-147: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick winSame
filemtimeguard issue asPackageManifest::shouldRecompile().
filemtime($this->basePath.'/composer.json')will emit a PHP warning if the file doesn't exist. Apply the sameis_file()guard suggested forPackageManifest::shouldRecompile().🛡️ Proposed fix
public function shouldRecompile(): bool { return !is_file($this->containerMixinPath) || // We check here if the manifest has been generated before changing the installed.json composer file or the project composer.json - filemtime($this->containerMixinPath) <= filemtime($this->vendorPath.'/composer/installed.json') || - filemtime($this->containerMixinPath) <= filemtime($this->basePath.'/composer.json'); + (is_file($this->vendorPath.'/composer/installed.json') && filemtime($this->containerMixinPath) <= filemtime($this->vendorPath.'/composer/installed.json')) || + (is_file($this->basePath.'/composer.json') && filemtime($this->containerMixinPath) <= filemtime($this->basePath.'/composer.json')); }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/Manifests/ContainerMixinManifest.php` around lines 145 - 147, The `ContainerMixinManifest` freshness check has the same unsafe `filemtime` usage as `PackageManifest::shouldRecompile()`, and `filemtime($this->basePath.'/composer.json')` can warn when the file is missing. Update the logic around the manifest rebuild guard to use an `is_file()` check before calling `filemtime()` for the project composer file, keeping the existing comparison behavior in `ContainerMixinManifest` while avoiding warnings.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/Manifests/PackageManifest.php`:
- Around line 144-147: The shouldRecompile() logic in PackageManifest currently
calls filemtime() on composer.json without verifying the file exists, which can
trigger warnings on missing layouts. Update shouldRecompile() to mirror the
build() guard by checking is_file() before any filemtime() call on the basePath
composer.json (and any other potentially absent paths), and only compare mtimes
when the files are present.
---
Duplicate comments:
In `@src/Manifests/ContainerMixinManifest.php`:
- Around line 145-147: The `ContainerMixinManifest` freshness check has the same
unsafe `filemtime` usage as `PackageManifest::shouldRecompile()`, and
`filemtime($this->basePath.'/composer.json')` can warn when the file is missing.
Update the logic around the manifest rebuild guard to use an `is_file()` check
before calling `filemtime()` for the project composer file, keeping the existing
comparison behavior in `ContainerMixinManifest` while avoiding warnings.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 0bb7e42d-a324-4d6a-bce2-f9e069c8f188
📒 Files selected for processing (3)
src/Manifests/ContainerMixinManifest.phpsrc/Manifests/PackageManifest.phptests/Support/composer.json
| $methodName, | ||
| returnType: $reflectionMethod->hasReturnType() ? (new TypeResolver())->resolve($reflectionMethod->getReturnType()) : new Mixed_(), | ||
| parameters: $parameters, | ||
| returnType: $reflectionMethod->hasReturnType() ? (new TypeResolver())->resolve($reflectionMethod->getReturnType()) : new Mixed_(), |
There was a problem hiding this comment.
what is the point of this change please ?
There was a problem hiding this comment.
Just a sort of the parameters by the signature order. Not a requirement, but a "CS" fix.
| @@ -0,0 +1,3 @@ | |||
| { | |||
| "name": "xefi/faker-php-tests-support" | |||
| } | |||
There was a problem hiding this comment.
Please add some unit tests for your feature
|
Interesting changes, thank you. I added some little feedbacks but the main thing is cool ! |
The auto-discovery feature of installed packages is nice, however it fails to discover project-local providers and extensions. This PR address this issue by reading the project
composer.jsonfile too.Summary by CodeRabbit
New Features
composer.jsonwhenextra.fakeris present.Bug Fixes
composer.jsonchanges, reducing stale configuration issues.