Page MenuHomePhabricator

Adding phan stubs to /.phan/stubs/ folder should not be seen by extensions depending on the extension
Open, Needs TriagePublic

Description

With patch set https://gerrit.wikimedia.org/r/c/mediawiki/extensions/GlobalBlocking/+/971561 a phan stub for a class of the UserMerge extension was added (as that is a non-wmf deployed extension and it feels better to not have a dependency for it on CI and local developer).
But this new stub brings the CI of CheckUser into error:

src/HookHandler/UserMergeHandler.php:7 PhanRedefinedInheritedInterface \MediaWiki\CheckUser\HookHandler\UserMergeHandler inherits Interface \MediaWiki\Extension\UserMerge\Hooks\AccountFieldsHook declared at ../../extensions/GlobalBlocking/.phan/stubs/AccountFieldsHook.php:8 which is also declared at ../../extensions/UserMerge/includes/Hooks/AccountFieldsHook.php:12. This may lead to confusing errors.

CheckUser has UserMerge extension as phan dependency and loads it with:

$cfg['directory_list'] = array_merge(
	$cfg['directory_list'],
	[
		'../../extensions/CentralAuth',
		'../../extensions/EventLogging',
		'../../extensions/GuidedTour',
		'../../extensions/GlobalBlocking',
		'../../extensions/UserMerge'
	]
);

That also pull in the .phan/stubs/ folder with the newly added stub and reports the duplicate interface error.

There should be a way to avoid that stubs are used by dependency or maybe only used when the real extension is not there.

Event Timeline

This is the kind of issue that I was aiming to solve with the ConfigBuilder (T250380). We could have a custom loadExtensionStub method or something that automatically skips the stubs if the real extension is available.

Change #1294334 had a related patch set uploaded (by C. Scott Ananian; author: C. Scott Ananian):

[mediawiki/tools/phan@master] Exclude stubs from .phan configurations in extensions

https://gerrit.wikimedia.org/r/1294334