Skip to content

Exclude phpstorm-stubs test suite from function metadata generation - #6439

Merged
ondrejmirtes merged 1 commit into
2.2.xfrom
fix-generate-function-metadata
Sep 14, 2026
Merged

Exclude phpstorm-stubs test suite from function metadata generation#6439
ondrejmirtes merged 1 commit into
2.2.xfrom
fix-generate-function-metadata

Conversation

@ondrejmirtes

Copy link
Copy Markdown
Member

The scheduled "Update PhpStorm stubs" workflow has been failing in the "Update function metadata" step: https://github.com/phpstan/phpstan-src/actions/runs/34172166172/job/101894414480

PHP Fatal error:  Uncaught Error: Call to a member function toString() on null in bin/generate-function-metadata.php:94

Cause: the Finder scanned every PHP file in vendor/jetbrains/phpstorm-stubs, including the package's own tests/ directory. The latest stubs master rewrote those tests using anonymous classes with methods, and NameResolver does not assign namespacedName to anonymous classes.

Fix:

  • Exclude tests/ from the scan and skip methods of anonymous classes.
  • Regenerating drops four bogus StubTests\* entries that had leaked into resources/functionMetadata.php.
  • The generator now writes the trailing newline .editorconfig requires, so regeneration no longer produces whitespace churn.
  • ob_get_level() was flipped to hasSideEffects => false by hand in Narrow ob_get_contents()/ob_get_clean()/ob_get_flush()/ob_get_length() to non-false while output buffering is active #5909 (its level is tracked in the scope, so the call result must stay narrowable) without teaching the generator, so any regeneration would have reverted it and broken nsrt/output-buffering.php. It is now in the list of scope-managed functions and bin/functionMetadata_original.php is aligned, making the generated file stable.

Verified locally: with the fix, the generator runs cleanly against both the locked stubs (output identical apart from the four removed StubTests\* entries) and the current stubs master (three new intl functions only). This PR intentionally does not bump the stubs; the workflow will do that once it passes again.

🤖 Generated with Claude Code

https://claude.ai/code/session_01RM7vts9eefx5pyNFj7jRKY

The Finder in bin/generate-function-metadata.php scanned every PHP file
in vendor/jetbrains/phpstorm-stubs, including the package's own tests/
directory. The latest stubs master added anonymous classes with methods
there, and NameResolver does not assign namespacedName to anonymous
classes, so the script died with "Call to a member function toString()
on null" and the "Update PhpStorm stubs" workflow failed.

Exclude tests/ from the scan and skip methods of anonymous classes.
Regenerating drops four bogus StubTests\* entries that had leaked into
resources/functionMetadata.php, and the generator now writes the
trailing newline that .editorconfig requires.

ob_get_level() was flipped to hasSideEffects => false by hand in #5909
(its level is tracked in the scope, so the call result must stay
narrowable) without teaching the generator, so any regeneration would
have reverted it. Add it to the list of scope-managed functions and
align bin/functionMetadata_original.php, so the generated file is
stable.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RM7vts9eefx5pyNFj7jRKY
@ondrejmirtes
ondrejmirtes merged commit 6f4d111 into 2.2.x Sep 14, 2026
236 of 238 checks passed
@ondrejmirtes
ondrejmirtes deleted the fix-generate-function-metadata branch September 14, 2026 10:05
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.

1 participant