Repository navigation
fix(stub): put getByDirname on XoopsModule (correct core API) - #8
Conversation
…odules Core defines the static `XoopsModule::getByDirname()` (kernel/module.php); there is no `XoopsModules` class. The stub had the method on a fabricated `XoopsModules`, so a module calling `XoopsModule::getByDirname()` got a bogus undefined-static-method report. Move the signature to `XoopsModule` and remove the fictional class.
Reviewer's guide (collapsed on small PRs)Reviewer's GuideAdjusts the XOOPS PHPStan stub so that the static getByDirname() method is declared on the real XoopsModule class instead of a fabricated XoopsModules class, eliminating false "undefined static method" reports for modules calling XoopsModule::getByDirname(). File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughUpdated the PHP stub file ChangesStub API consolidation
Estimated code review effort: 1 (Trivial) | ~3 minutes 🚥 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.
Pull request overview
This PR corrects the XOOPS PHPStan stub to match the actual core API by placing getByDirname() on the real XoopsModule class and removing the non-existent XoopsModules class, eliminating false “undefined static method” reports for modules calling core.
Changes:
- Added
XoopsModule::getByDirname(string $dirname): ?XoopsModuleto the stub. - Removed the fabricated
XoopsModulesstub class that previously (incorrectly) containedgetByDirname().
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Code Review
This pull request refactors the XOOPS stubs by removing the XoopsModules class and moving its static getByDirname method to the XoopsModule class. Feedback suggests updating the return type of XoopsModule::getByDirname to XoopsModule|false instead of ?XoopsModule, as the underlying XOOPS core method returns false on failure rather than null.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
|
|
||
| public function dirname(): string {} | ||
|
|
||
| public static function getByDirname(string $dirname): ?XoopsModule {} |
There was a problem hiding this comment.
In XOOPS core, XoopsModule::getByDirname() (which delegates to XoopsModuleHandler::getByDirname()) returns false on failure rather than null.\n\nUsing ?XoopsModule (which resolves to XoopsModule|null) will cause PHPStan to reject strict comparisons against false (e.g., $module === false), potentially forcing developers to use $module === null which would fail at runtime.\n\nTo prevent this type-safety mismatch, the return type should be declared as XoopsModule|false.
public static function getByDirname(string $dirname): XoopsModule|false {}
Correct the XOOPS stub: the static
getByDirname()lives onXoopsModule(singular) in core (kernel/module.php), and there is noXoopsModulesclass. The stub previously defined the method on a fabricatedXoopsModules, so a module calling the realXoopsModule::getByDirname()got a bogus "undefined static method" report (and had to baseline it).Discovered when applying the baseline to a real module (xwhoops), whose preload calls
\XoopsModule::getByDirname()for its admin permission check.Summary by Sourcery
Bug Fixes:
Summary by CodeRabbit