Skip to content

Exclude internal PHPStan stubs from distribution archives#6329

Merged
swissspidy merged 3 commits into
mainfrom
copilot/fix-incomplete-wpdb-stub
Jun 3, 2026
Merged

Exclude internal PHPStan stubs from distribution archives#6329
swissspidy merged 3 commits into
mainfrom
copilot/fix-incomplete-wpdb-stub

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jun 3, 2026

WP-CLI ships utils/phpstan/scan-files.php, which declares a partial global wpdb stub. When downstream PHPStan runs scan installed vendor trees, that stub can shadow fuller WordPress definitions and trigger false positives such as Call to an undefined method wpdb::get_col().

  • What changed

    • Marked the internal utils/phpstan/ directory as export-ignore in .gitattributes.
    • This keeps WP-CLI’s internal PHPStan helper files out of distribution archives without changing runtime code or the internal analysis setup used in this repository.
  • Why this addresses the issue

    • Installed package contents no longer include the partial wpdb stub.
    • Downstream projects can rely on WordPress core or dedicated WordPress stubs instead of inheriting WP-CLI’s internal analysis-only definitions.
  • Archive rule

    /utils/phpstan export-ignore
    /utils/phpstan/** export-ignore
  • Effect on consumers

    global $wpdb;
    
    $ids = $wpdb->get_col( 'SELECT ID FROM wp_posts' );

    This no longer picks up WP-CLI’s incomplete wpdb stub from utils/phpstan/scan-files.php in distributed installs.

Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix incomplete global wpdb stub in PHPStan Exclude internal PHPStan stubs from distribution archives Jun 3, 2026
Copilot AI requested a review from swissspidy June 3, 2026 15:22
@swissspidy swissspidy added the scope:distribution Related to distribution label Jun 3, 2026
@swissspidy swissspidy marked this pull request as ready for review June 3, 2026 21:08
@swissspidy swissspidy requested a review from a team as a code owner June 3, 2026 21:08
Copilot AI review requested due to automatic review settings June 3, 2026 21:08
@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 3, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Copy link
Copy Markdown
Contributor

Copilot AI left a 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 prevents WP-CLI’s internal PHPStan helper stubs (notably the partial wpdb stub) from being included in distribution archives, reducing the risk of downstream PHPStan false-positives when scanning installed vendor trees.

Changes:

  • Added export-ignore rules for utils/phpstan/ so it’s excluded from generated distribution archives.
  • Leaves runtime behavior unchanged while keeping internal analysis-only files out of consumer installs.

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

Comment thread .gitattributes Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@swissspidy swissspidy merged commit 49ad9e4 into main Jun 3, 2026
73 checks passed
@swissspidy swissspidy deleted the copilot/fix-incomplete-wpdb-stub branch June 3, 2026 21:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope:distribution Related to distribution

Projects

None yet

Development

Successfully merging this pull request may close these issues.

utils/phpstan/scan-files.php declares an incomplete global wpdb stub that causes false positives for wpdb::get_col() and other methods

3 participants