Skip to content

Fix getMethodParamsTypes intermitent failure#547

Merged
avishka-ra merged 1 commit into
masterfrom
INTGRTNS-516-OpenProvider-WHMCS-Module-PHPStan-namespace-collision-breaks-all-API-v1-calls-on-WHMCS-9.0.4
May 21, 2026
Merged

Fix getMethodParamsTypes intermitent failure#547
avishka-ra merged 1 commit into
masterfrom
INTGRTNS-516-OpenProvider-WHMCS-Module-PHPStan-namespace-collision-breaks-all-API-v1-calls-on-WHMCS-9.0.4

Conversation

@avishka-ra

Copy link
Copy Markdown
Collaborator

Problem

On some WHMCS servers, the daily cron aborts at DomainTransferSync with:

TypeError: PHPStan\PhpDocParser\Parser\TypeParser::__construct():
Argument #1 must be of type ?ConstExprParser, ParserConfig given

WHMCS core bundles phpstan/phpdoc-parser v0.4.14 and the OP module bundles v2.2.0. Both define PHPStan\PhpDocParser\Parser\TypeParser under the same namespace. When another component on the server (a module, addon, or hook) loads WHMCS's v0.4.14 TypeParser before the OP module initialises, it gets locked into PHP's class cache. The module's DocBlockFactory::createInstance() call then hits the v0.4.14 constructor with v2.2.0 arguments — fatal TypeError.

Fix

Removed the phpDocumentor\Reflection\DocBlockFactory dependency from ParamsCreator::getMethodParamsTypes() and replaced it with a direct preg_match_all on the raw docblock string. The REST client only uses simple @param string / @param int types so the regex covers all cases and the settype() coercion behaviour is preserved.

Files Changed

  • modules/registrars/openprovider/OpenProvider/API/ParamsCreator.php

Copilot AI review requested due to automatic review settings May 20, 2026 10:07

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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\DocBlockFactory usage from ParamsCreator::getMethodParamsTypes().
  • Implemented direct @param <type> $<name> extraction via preg_match_all() and added a safe early return when no docblock exists.
  • Added an explicit array return type for getMethodParamsTypes().

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@avishka-ra
avishka-ra merged commit 02b5215 into master May 21, 2026
1 check passed
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.

3 participants