Conversation
This comment was marked as resolved.
This comment was marked as resolved.
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
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.distconfiguration and a small scan bootstrap file undertests/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
Commandto better align withUtils\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.
| $args = func_get_args(); | ||
| if ( is_callable( $func ) ) { | ||
| $value = call_user_func_array( $func, $args ); | ||
| } else { | ||
| $value = null; | ||
| } |
There was a problem hiding this comment.
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).
| $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 ); |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
No description provided.