fix: disable autoloading in typeIsValid to prevent fatal errors during generation#16
Merged
mikaelcom merged 1 commit intoMar 21, 2026
Conversation
Member
|
Hello, |
…g generation class_exists() in typeIsValid() triggers the autoloader, which can cause fatal errors during code generation when a freshly-generated class extends a parent class that hasn't been generated yet. The generation order of structs is non-deterministic, so this produces intermittent failures. Passing false as the second argument to class_exists() disables autoloading. The subsequent stringIsValid() check still validates the type string format, so there is no loss of validation coverage.
6bd1380 to
77ae5d6
Compare
Member
|
please target develop branch for merging 🙏 |
Contributor
Author
|
Done. Rebased onto develop and retargeted the PR. Thanks for the heads up! |
mikaelcom
approved these changes
Mar 21, 2026
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
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
TypeHintedElementTrait::typeIsValid()callsclass_exists($type)which triggers the PHP autoloader by default. When used bywsdltophp/packagegeneratorto generate code from a WSDL, this can cause fatal errors when a freshly-generated class file is autoloaded and its parent class hasn't been generated yet.The call chain is:
PhpFunctionParameter::setType()→typeIsValid()→class_exists($type)→ autoloader includes the generated file → PHP tries to resolveextends ParentType→ fatal error if the parent class file hasn't been written yet.Fix
Pass
falseas the second argument toclass_exists()to disable autoloading:This has no impact on validation effectiveness — the subsequent
stringIsValid()check validates the type string format, andclass_exists($type, false)still matches classes that are already loaded in memory.