FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Add initial PHPStan config by swissspidy · Pull Request #218 · wp-cli/profile-command · GitHub

Add initial PHPStan config - #218

Merged
swissspidy merged 16 commits into
mainfrom
fix/phpstan
Apr 8, 2026
Merged

Add initial PHPStan config#218
swissspidy merged 16 commits into
mainfrom
fix/phpstan

Conversation

Copy link
Copy Markdown
Member

No description provided.

github-actions Bot added the scope:testing Related to testing label Apr 2, 2026

This comment was marked as resolved.

codecov Bot commented Apr 2, 2026
edited
Loading

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 75.30864% with 40 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/Profiler.php 69.15% 33 Missing ⚠️
src/Formatter.php 80.55% 7 Missing ⚠️

📢 Thoughts on this report? Let us know!

This comment was marked as resolved.

swissspidy marked this pull request as ready for review April 8, 2026 11:18
swissspidy requested a review from a team as a code owner April 8, 2026 11:18
Copilot AI review requested due to automatic review settings April 8, 2026 11:18
swissspidy added this to the 2.1.7 milestone Apr 8, 2026

Copilot AI 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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Pull request overview

This PR introduces an initial PHPStan setup for the package and adjusts the codebase (mainly via typing/docblocks and a few runtime guards) to satisfy stricter static analysis.

Changes:

  • Add a phpstan.neon.dist configuration and a small scan bootstrap file under tests/phpstan/.
  • Improve PHPStan compatibility by adding/adjusting PHPDoc types and some defensive type checks across Profiler/Logger/Formatter/Command.
  • Introduce typed assoc-args handling in Command to better align with Utils\get_flag_value() expectations.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
phpstan.neon.dist Adds baseline PHPStan configuration (level, paths, scanned stubs/files).
tests/phpstan/scan-files.php Provides scan-time constants to satisfy static analysis.
src/Profiler.php Adds PHPDoc types and runtime guards; refactors hook wrapping/tick profiling logic for static analysis.
src/Logger.php Adds PHPDoc typing + class-level documentation for dynamic properties.
src/Formatter.php Adds PHPDoc typing and stricter input normalization for fields/ordering.
src/Command.php Adds PHPDoc typing and a helper to normalize assoc args for PHPStan/flag parsing.

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

Comment thread src/Profiler.php
Comment on lines +327 to +332
$args = func_get_args();
if ( is_callable( $func ) ) {
$value = call_user_func_array( $func, $args );
} else {
$value = null;
}

Copilot AI Apr 8, 2026

Copy link

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

In wrap_current_filter_callbacks(), the wrapper now returns null when $func is not callable. That changes WordPress semantics: an uncallable hook callback would normally trigger a runtime error, but under profiling it would silently continue and potentially alter filter values. Consider removing the is_callable() branch and always invoking the original callback so behavior matches non-profiled execution (or, if you want to keep the guard, preserve the original filter value and surface a warning/error instead of returning null).

Suggested change
$args = func_get_args();
if ( is_callable( $func ) ) {
$value = call_user_func_array( $func, $args );
} else {
$value = null;
}
$args = func_get_args();
$value = call_user_func_array( $func, $args );

Copilot uses AI. Check for mistakes.
Comment thread src/Command.php Outdated
Comment thread src/Command.php Outdated
Comment thread src/Command.php Outdated
Comment thread src/Formatter.php
swissspidy merged commit 47fc059 into main Apr 8, 2026
61 of 62 checks passed
swissspidy deleted the fix/phpstan branch April 8, 2026 14:29
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope:testing Related to testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants


Back | FazBrowse Home | New Git URL