Changeset 65808
- Timestamp:
- 11/27/2026 08:15:25 PM (15 hours ago)
- Location:
- trunk
- Files:
-
- 38 added
- 6 edited
-
.github/workflows/phpstan-static-analysis.yml (modified) (1 diff)
-
.github/workflows/reusable-phpstan-static-analysis-v2.yml (modified) (2 diffs)
-
composer.json (modified) (1 diff)
-
package.json (modified) (1 diff)
-
tests/phpstan/README.md (modified) (1 diff)
-
tests/phpstan/Tests (added)
-
tests/phpstan/Tests/ApplyFiltersDynamicFunctionReturnTypeExtensionTest.php (added)
-
tests/phpstan/Tests/GlobalDocBlockVisitorTest.php (added)
-
tests/phpstan/Tests/HashNotationTypeTest.php (added)
-
tests/phpstan/Tests/HashNotationVisitorTest.php (added)
-
tests/phpstan/Tests/HookDocBlockTest.php (added)
-
tests/phpstan/Tests/HookDocsVisitorTest.php (added)
-
tests/phpstan/Tests/HookDocumentationRuleTest.php (added)
-
tests/phpstan/Tests/HookParamCountRuleTest.php (added)
-
tests/phpstan/Tests/ReflectionParserTest.php (added)
-
tests/phpstan/Tests/bootstrap.php (added)
-
tests/phpstan/Tests/data (added)
-
tests/phpstan/Tests/data/ApplyFiltersTestClass.php (added)
-
tests/phpstan/Tests/data/GlobalDocBlockTestClass.php (added)
-
tests/phpstan/Tests/data/apply-filters.php (added)
-
tests/phpstan/Tests/data/functions.php (added)
-
tests/phpstan/Tests/data/global-docblock.php (added)
-
tests/phpstan/Tests/data/hash-notation.php (added)
-
tests/phpstan/Tests/data/hook-documentation.php (added)
-
tests/phpstan/Tests/data/hook-param-count.php (added)
-
tests/phpstan/Tests/data/outside.php (added)
-
tests/phpstan/Tests/data/reflection (added)
-
tests/phpstan/Tests/data/reflection/analyzed.php (added)
-
tests/phpstan/Tests/data/reflection/phpstan.neon (added)
-
tests/phpstan/Tests/data/reflection/scanned.php (added)
-
tests/phpstan/Tests/data/wordpress (added)
-
tests/phpstan/Tests/data/wordpress/wp-admin (added)
-
tests/phpstan/Tests/data/wordpress/wp-admin/admin.php (added)
-
tests/phpstan/Tests/data/wordpress/wp-content (added)
-
tests/phpstan/Tests/data/wordpress/wp-content/themes (added)
-
tests/phpstan/Tests/data/wordpress/wp-content/themes/wptests (added)
-
tests/phpstan/Tests/data/wordpress/wp-content/themes/wptests/author.php (added)
-
tests/phpstan/Tests/data/wordpress/wp-content/themes/wptests/index.php (added)
-
tests/phpstan/Tests/data/wordpress/wp-includes (added)
-
tests/phpstan/Tests/data/wordpress/wp-includes/canonical.php (added)
-
tests/phpstan/Tests/data/wordpress/wp-includes/other.php (added)
-
tests/phpstan/Tests/tests.neon (added)
-
tests/phpstan/base.neon (modified) (4 diffs)
-
tests/phpstan/phpunit.xml.dist (added)
Legend:
- Unmodified
- Added
- Removed
-
trunk/.github/workflows/phpstan-static-analysis.yml
r65693 r65808 22 22 - 'tests/phpstan/baselines/**' 23 23 - 'tests/phpstan/baselines-strict/**' 24 # These files configure the tests of the PHPStan extensions, and hold their fixtures. 25 - 'tests/phpstan/phpunit.xml.dist' 26 - 'tests/phpstan/Tests/**' 24 27 # Confirm any changes to relevant workflow files. 25 28 - '.github/workflows/phpstan-static-analysis.yml' -
trunk/.github/workflows/reusable-phpstan-static-analysis-v2.yml
r65693 r65808 39 39 # - Reports the results as annotations. 40 40 # - Uploads the results as an artifact (pull requests only). 41 # - Runs the tests of the WordPress-specific PHPStan extensions (default analysis only). 41 42 # - Checks for errors that cannot be reported as warnings, such as out-of-date baselines. 42 43 # - Saves the PHPStan result cache. … … 278 279 path: ${{ runner.temp }}/phpstan-results/ 279 280 281 # The extensions in `tests/phpstan` are tested against fixtures rather than against 282 # core, so a defect in one is reported here as a failing test rather than as a 283 # change in what the analysis above reports. 284 # 285 # This runs after the results are reported and uploaded, so that a failing test 286 # does not also keep the pull request from being annotated and commented on. It 287 # runs even when the analysis failed, since the two are independent, but not when 288 # the analysis was skipped: that means a step setting up the job, such as installing 289 # the Composer dependencies, failed, and the tests could only fail along with it. 290 # Both analyses load the same extensions, so the tests run in only one of them. 291 - name: Run the tests of the PHPStan extensions 292 if: ${{ !cancelled() && steps.phpstan.outcome != 'skipped' && matrix.analysis == 'default' && hashFiles('tests/phpstan/phpunit.xml.dist') != '' }} 293 run: composer run phpstan:test 294 280 295 # Some errors cannot be ignored, so they cannot be reported as warnings either. Most often 281 296 # this is an ignored error that no longer occurs, or occurs a different number of times, -
trunk/composer.json
r65769 r65808 81 81 "phpstan:baselines": [ "Composer\\Config::disableProcessTimeout", "@php ./tests/phpstan/generate-baselines.php" ], 82 82 "phpstan:fix": [ "Composer\\Config::disableProcessTimeout", "@php ./tests/phpstan/analyse.php --memory-limit=2G --fix" ], 83 "phpstan:test": "@php ./vendor/phpunit/phpunit/phpunit -c tests/phpstan/phpunit.xml.dist", 83 84 "compat": "@php ./vendor/squizlabs/php_codesniffer/bin/phpcs --standard=phpcompat.xml.dist --report=summary,source", 84 85 "format": "@php ./vendor/squizlabs/php_codesniffer/bin/phpcbf --report=summary,source", -
trunk/package.json
r65764 r65808 156 156 "typecheck:php:baselines": "node ./tools/local-env/scripts/docker.js run --rm php composer phpstan:baselines --", 157 157 "typecheck:php:fix": "node ./tools/local-env/scripts/docker.js run --rm php composer phpstan:fix --", 158 "typecheck:php:test": "node ./tools/local-env/scripts/docker.js run --rm php composer phpstan:test --", 158 159 "gutenberg:copy": "node tools/gutenberg/copy.js", 159 160 "gutenberg:verify": "node tools/gutenberg/utils.js", -
trunk/tests/phpstan/README.md
r65693 r65808 210 210 | `wordpress.hookParamCountMismatch` | The call passes a different number of arguments than the docblock documents `@param` tags for. Passing fewer risks an `ArgumentCountError` in a callback registered for the documented count; passing more silently drops the extra argument and leaves the documentation misleading. | 211 211 212 ### Testing the extensions 213 214 The extensions have tests of their own under [`Tests/`](Tests), built on PHPStan's test harness. The two rules are run over fixture files and the errors they report are compared with the ones expected. The visitors and the return type extension are checked through the types PHPStan infers for the `assertType()` calls in their fixtures. Reference comments resolve against a small WordPress tree of fixtures in [`Tests/data/wordpress`](Tests/data/wordpress) rather than against `src`, so a broken reference can be tested without one existing in core. 215 216 The harness parses every file the way an analyzed file is parsed, so one test, `ReflectionParserTest`, runs a real analysis with `base.neon` instead. It checks that a function declared in a file that is only scanned is reflected with the shape its hash notation describes, which depends on the redefinition of `currentPhpVersionSimpleParser` there. 217 218 Run them with: 219 220 ```bash 221 npm run typecheck:php:test 222 ``` 223 224 or, outside the Docker environment: 225 226 ```bash 227 composer phpstan:test 228 ``` 229 230 They also run in CI, after the analysis of the whole codebase, so that a failing test does not keep its results from being reported. 231 212 232 ## Ignoring and baselining errors 213 233 -
trunk/tests/phpstan/base.neon
r65310 r65808 76 76 # the per-file reflection cache can be keyed on the file's contents alone. 77 77 # 78 # HashNotationVisitor breaks that agreement. It rewrites `@param` , `@return` and79 # `@var`docblocks, which are exactly what reflection exposes, so a file read78 # HashNotationVisitor breaks that agreement. It rewrites `@param` and `@return` 79 # docblocks, which are exactly what reflection exposes, so a file read 80 80 # through the simple parser reflects the documented `array` where the same file 81 81 # analyzed reflects the shape its hash notation describes. Analyzing a subset of … … 92 92 # into anything and the behavior above returns; the errors it prevents are all of 93 93 # the quiet sort, so check this first when a hash notation type looks wrong. 94 # Tests/ReflectionParserTest.php fails when that happens. 94 95 # 95 96 # `arguments!` replaces the inherited arguments rather than merging with them. … … 306 307 - HookDocumentationRule.php 307 308 - HookParamCountRule.php 309 - Tests 308 310 bootstrapFiles: 309 311 - bootstrap.php … … 313 315 excludePaths: 314 316 analyseAndScan: 317 # Fixtures for the tests of the extensions above, which carry the errors those tests expect. 318 - Tests/data 315 319 # Locally installed npm dependencies, such as in bundled themes, which may include PHP files. 316 320 - */node_modules/*
Note:
See TracChangeset
for help on using the changeset viewer.