Skip to content

fix(phpstan): declare XOOPS core classes via scanFiles so extends res… - #7

Merged
mambax7 merged 1 commit into
XoopsModules27x:masterfrom
mambax7:fix/phpstan-core-class-discovery
Jul 3, 2026
Merged

mambax7 merged 1 commit into
XoopsModules27x:masterfrom
mambax7:fix/phpstan-core-class-discovery

Conversation

@mambax7

@mambax7 mambax7 commented Jul 3, 2026 •

Copy link
Copy Markdown
Contributor

The baseline referenced stubs/xoops.stub via stubFiles, which only refines signatures of classes PHPStan can already discover — it does not register stub-only classes as existing. Any module that extends a core class (e.g. a preload extending XoopsPreloadItem, or an object extending XoopsObject) then hits a non-ignorable class.notFound that cannot be baselined, failing composer qa.

  • phpstan.neon.dist: use scanFiles instead of stubFiles so the stub's classes are registered as existing and extends/implements resolve.
  • stubs/xoops.stub: add the XoopsPreloadItem base class, extended by every module preload.

Went unnoticed because module-devops itself has no code extending a XOOPS class; it only surfaces once the baseline is applied to a real module.

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

Summary by Sourcery

Adjust PHPStan configuration and XOOPS stubs so core XOOPS classes are recognised and module classes extending them can be analysed successfully.

Bug Fixes:

  • Resolve PHPStan class-not-found errors for modules extending XOOPS core classes by registering stub-only classes as existing.

Enhancements:

  • Extend the XOOPS stub file with the XoopsPreloadItem base class used by module preloads.

Build:

  • Update phpstan.neon.dist to load XOOPS stubs via scanFiles instead of stubFiles so their classes are discovered during analysis.

…olves

The baseline referenced stubs/xoops.stub via `stubFiles`, which only refines
signatures of classes PHPStan can already discover — it does not register
stub-only classes as existing. Any module that extends a core class (e.g. a
preload extending XoopsPreloadItem, or an object extending XoopsObject) then
hits a non-ignorable class.notFound that cannot be baselined, failing
`composer qa`.

- phpstan.neon.dist: use `scanFiles` instead of `stubFiles` so the stub's
  classes are registered as existing and extends/implements resolve.
- stubs/xoops.stub: add the XoopsPreloadItem base class, extended by every
  module preload.

Went unnoticed because module-devops itself has no code extending a XOOPS
class; it only surfaces once the baseline is applied to a real module.
Copilot AI review requested due to automatic review settings July 3, 2026 02:31
@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 PHPStan configuration so XOOPS core classes from the stub file are treated as real, discoverable classes, and extends the stub to include the XoopsPreloadItem base class used by module preloads.

File-Level Changes

Change Details Files
Register XOOPS stub classes with PHPStan so extends/implements resolve correctly.
  • Switch PHPStan configuration from using stubFiles to scanFiles for the XOOPS stub so its classes are treated as existing by the analyser.
  • Ensure class.notFound errors for modules extending XOOPS core classes become resolvable instead of non-ignorable.
phpstan.neon.dist
Provide a stub for the XoopsPreloadItem base class.
  • Add a stub definition for the XoopsPreloadItem base class in the XOOPS stub file so module preload classes can extend it without class-not-found errors.
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

Warning

Review limit reached

@mambax7, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 59 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: fc98ac67-227b-40ee-a929-7a7b75ac0a20

📥 Commits

Reviewing files that changed from the base of the PR and between 3e66300 and e7e4e43.

📒 Files selected for processing (2)
  • phpstan.neon.dist
  • stubs/xoops.stub
✨ 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.

@sonarqubecloud

sonarqubecloud Bot commented Jul 3, 2026

Copy link
Copy Markdown

@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 left some high level feedback:

  • Switching from stubFiles to scanFiles will now register all classes in xoops.stub as real; consider splitting the file so only truly missing classes (like XoopsPreloadItem) go through scanFiles and signature refinements for existing classes remain under stubFiles to avoid accidental conflicts with real implementations.
  • With XOOPS core classes now materialized via scanFiles, review the stubbed class and method signatures to ensure they are minimal and generic enough that they won’t become a maintenance burden or diverge from actual XOOPS versions used across modules.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Switching from `stubFiles` to `scanFiles` will now register all classes in `xoops.stub` as real; consider splitting the file so only truly missing classes (like `XoopsPreloadItem`) go through `scanFiles` and signature refinements for existing classes remain under `stubFiles` to avoid accidental conflicts with real implementations.
- With XOOPS core classes now materialized via `scanFiles`, review the stubbed class and method signatures to ensure they are minimal and generic enough that they won’t become a maintenance burden or diverge from actual XOOPS versions used across modules.

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.

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 fixes PHPStan analysis failures for XOOPS modules that extend core classes which are not composer-autoloadable during static analysis. It does this by ensuring the XOOPS stub file is discovered as defining classes (not merely refining existing ones) and by adding the missing XoopsPreloadItem base class commonly extended by module preloads.

Changes:

  • Switch PHPStan config from stubFiles to scanFiles so stub-defined XOOPS classes are registered as existing and extends/implements resolve.
  • Add a minimal XoopsPreloadItem class to the XOOPS stub so preloads can extend it without triggering class.notFound.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
stubs/xoops.stub Adds XoopsPreloadItem to the global-namespace XOOPS core stubs so module preload inheritance resolves.
phpstan.neon.dist Uses scanFiles to register XOOPS stub-defined classes as existing during analysis.

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

@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 updates the PHPStan configuration to use scanFiles instead of stubFiles for stubs/xoops.stub, which ensures that XOOPS core classes are properly registered as existing to prevent class.notFound errors during analysis. Additionally, a stub for the XoopsPreloadItem class has been added. There are no review comments, so I have no feedback to provide.

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.

@mambax7
mambax7 merged commit b0821fd into XoopsModules27x:master Jul 3, 2026
8 checks passed
@mambax7
mambax7 deleted the fix/phpstan-core-class-discovery branch July 3, 2026 03:13
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