Skip to content

fix(stub): put getByDirname on XoopsModule (correct core API) - #8

Merged
mambax7 merged 1 commit into
XoopsModules27x:masterfrom
mambax7:fix/stub-getbydirname
Jul 3, 2026
Merged

mambax7 merged 1 commit into
XoopsModules27x:masterfrom
mambax7:fix/stub-getbydirname

Conversation

@mambax7

@mambax7 mambax7 commented Jul 3, 2026 •

Copy link
Copy Markdown
Contributor

Correct the XOOPS stub: the static getByDirname() lives on XoopsModule (singular) in core (kernel/module.php), and there is no XoopsModules class. The stub previously defined the method on a fabricated XoopsModules, so a module calling the real XoopsModule::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.

Q A
Is bugfix? ✔️
New feature? ❌
Breaks BC? ❌
Fixed issues —

Summary by Sourcery

Bug Fixes:

  • Resolve false "undefined static method" reports for calls to XoopsModule::getByDirname() caused by the method being stubbed on an incorrect class.

Summary by CodeRabbit

  • Chores
    • Updated module lookup support to use a single, clearer static method for finding modules by directory name.
    • Removed an outdated alternative lookup entry point to keep the available API simpler and more consistent.

…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.
Copilot AI review requested due to automatic review settings July 3, 2026 03:49
@sourcery-ai

sourcery-ai Bot commented Jul 3, 2026 •

Copy link
Copy Markdown
Contributor
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Adjusts 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

Change Details Files
Move the getByDirname() static method stub from a non-existent XoopsModules class to the real XoopsModule class and clean up the obsolete class stub.
  • Remove or deprecate the fabricated XoopsModules class from the XOOPS stub.
  • Add the static getByDirname() method signature to the XoopsModule class stub, matching the core kernel/module.php API.
  • Ensure the method’s visibility, static declaration, and parameter/return types in the stub reflect the real core implementation so static analyzers recognize XoopsModule::getByDirname().
stubs/xoops.stub

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@coderabbitai

coderabbitai Bot commented Jul 3, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: a61cf3a9-3f75-4210-a8d8-0fc3bd61c77e

📥 Commits

Reviewing files that changed from the base of the PR and between b0821fd and a131e0f.

📒 Files selected for processing (1)
  • stubs/xoops.stub

📝 Walkthrough

Walkthrough

Updated the PHP stub file stubs/xoops.stub to add a static getByDirname method on XoopsModule and remove the previously separate XoopsModules class that had declared a similar method.

Changes

Stub API consolidation

Layer / File(s) Summary
Move getByDirname to XoopsModule
stubs/xoops.stub
Added public static function getByDirname(string $dirname): ?XoopsModule to XoopsModule and removed the XoopsModules class that previously declared getByDirname(string $dirname): mixed.

Estimated code review effort: 1 (Trivial) | ~3 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: moving getByDirname to XoopsModule to align with the core API.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

Copilot AI left a comment

Copy link
Copy Markdown

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 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): ?XoopsModule to the stub.
  • Removed the fabricated XoopsModules stub class that previously (incorrectly) contained getByDirname().

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread stubs/xoops.stub

public function dirname(): string {}

public static function getByDirname(string $dirname): ?XoopsModule {}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

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 {}

@mambax7 mambax7 closed this Jul 3, 2026
@mambax7
mambax7 deleted the fix/stub-getbydirname branch July 3, 2026 05:26
@mambax7
mambax7 restored the fix/stub-getbydirname branch July 3, 2026 05:31
@mambax7 mambax7 reopened this Jul 3, 2026
@mambax7
mambax7 merged commit 83c6544 into XoopsModules27x:master Jul 3, 2026
12 checks passed
@mambax7
mambax7 deleted the fix/stub-getbydirname branch July 3, 2026 05:39
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