Fix getMethodParamsTypes intermitent failure#547
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses an intermittent fatal TypeError caused by class-name collisions between WHMCS-bundled phpstan/phpdoc-parser (v0.4.14) and the module-bundled version (v2.2.0) when resolving PHPDoc parameter types during cron runs. It removes the runtime dependency on phpDocumentor\Reflection\DocBlockFactory in ParamsCreator::getMethodParamsTypes() and replaces it with a simple regex-based extraction from raw docblocks, avoiding the conflicting parser classes.
Changes:
- Removed
phpDocumentor\Reflection\DocBlockFactoryusage fromParamsCreator::getMethodParamsTypes(). - Implemented direct
@param <type> $<name>extraction viapreg_match_all()and added a safe early return when no docblock exists. - Added an explicit
arrayreturn type forgetMethodParamsTypes().
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
prasad-fernando-74
approved these changes
May 20, 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
On some WHMCS servers, the daily cron aborts at
DomainTransferSyncwith:TypeError: PHPStan\PhpDocParser\Parser\TypeParser::__construct():
Argument #1 must be of type ?ConstExprParser, ParserConfig given
WHMCS core bundles
phpstan/phpdoc-parserv0.4.14 and the OP module bundles v2.2.0. Both definePHPStan\PhpDocParser\Parser\TypeParserunder the same namespace. When another component on the server (a module, addon, or hook) loads WHMCS's v0.4.14TypeParserbefore the OP module initialises, it gets locked into PHP's class cache. The module'sDocBlockFactory::createInstance()call then hits the v0.4.14 constructor with v2.2.0 arguments — fatalTypeError.Fix
Removed the
phpDocumentor\Reflection\DocBlockFactorydependency fromParamsCreator::getMethodParamsTypes()and replaced it with a directpreg_match_allon the raw docblock string. The REST client only uses simple@param string/@param inttypes so the regex covers all cases and thesettype()coercion behaviour is preserved.Files Changed
modules/registrars/openprovider/OpenProvider/API/ParamsCreator.php