Page MenuHomePhabricator

Constant inheritance not detected in phan, blocking merge of a patch
Closed, ResolvedPublic

Description

Example at https://gerrit.wikimedia.org/r/#/c/mediawiki/core/+/563289/

20:25:23 <checkstyle version="6.5">
20:25:23   <file name="includes/libs/objectcache/HashBagOStuff.php">
20:25:23     <error line="143" severity="warning" message="Reference to undeclared constant \HashBagOStuff::TTL_INDEFINITE" source="PhanUndeclaredConstant"/>
20:25:23   </file>
20:25:23   <file name="includes/libs/objectcache/MediumSpecificBagOStuff.php">
20:25:23     <error line="38" severity="warning" message="Reference to undeclared constant \MediumSpecificBagOStuff::ERR_NONE" source="PhanUndeclaredConstant"/>
20:25:23     <error line="428" severity="warning" message="Reference to undeclared constant \MediumSpecificBagOStuff::TTL_INDEFINITE" source="PhanUndeclaredConstant"/>
20:25:23     <error line="470" severity="warning" message="Reference to undeclared constant \MediumSpecificBagOStuff::TTL_DAY" source="PhanUndeclaredConstant"/>
20:25:23     <error line="744" severity="warning" message="Reference to undeclared constant \MediumSpecificBagOStuff::ERR_NONE" source="PhanUndeclaredConstant"/>
20:25:23     <error line="819" severity="warning" message="Reference to undeclared constant \MediumSpecificBagOStuff::TTL_INDEFINITE" source="PhanUndeclaredConstant"/>
20:25:23     <error line="819" severity="warning" message="Reference to undeclared constant \MediumSpecificBagOStuff::TTL_YEAR" source="PhanUndeclaredConstant"/>
20:25:23     <error line="836" severity="warning" message="Reference to undeclared constant \MediumSpecificBagOStuff::TTL_INDEFINITE" source="PhanUndeclaredConstant"/>
20:25:23     <error line="860" severity="warning" message="Reference to undeclared constant \MediumSpecificBagOStuff::TTL_INDEFINITE" source="PhanUndeclaredConstant"/>
20:25:23     <error line="925" severity="warning" message="Reference to undeclared constant \MediumSpecificBagOStuff::QOS_UNKNOWN" source="PhanUndeclaredConstant"/>
20:25:23   </file>
20:25:23   <file name="includes/libs/objectcache/MemcachedBagOStuff.php">
20:25:23     <error line="33" severity="warning" message="Reference to undeclared constant \MemcachedBagOStuff::ATTR_SYNCWRITES" source="PhanUndeclaredConstant"/>
20:25:23     <error line="33" severity="warning" message="Reference to undeclared constant \MemcachedBagOStuff::QOS_SYNCWRITES_BE" source="PhanUndeclaredConstant"/>
20:25:23     <error line="108" severity="warning" message="Reference to undeclared constant \MemcachedBagOStuff::TTL_MONTH" source="PhanUndeclaredConstant"/>
20:25:23   </file>
20:25:23   <file name="includes/libs/objectcache/RESTBagOStuff.php">
20:25:23     <error line="135" severity="warning" message="Reference to undeclared constant \RESTBagOStuff::ATTR_SYNCWRITES" source="PhanUndeclaredConstant"/>
20:25:23     <error line="135" severity="warning" message="Reference to undeclared constant \RESTBagOStuff::QOS_SYNCWRITES_QC" source="PhanUndeclaredConstant"/>
20:25:23     <error line="339" severity="warning" message="Reference to undeclared constant \RESTBagOStuff::ERR_UNEXPECTED" source="PhanUndeclaredConstant"/>
20:25:23     <error line="339" severity="warning" message="Reference to undeclared constant \RESTBagOStuff::ERR_UNREACHABLE" source="PhanUndeclaredConstant"/>
20:25:23   </file>
20:25:23   <file name="includes/libs/objectcache/RedisBagOStuff.php">
20:25:23     <error line="88" severity="warning" message="Reference to undeclared constant \RedisBagOStuff::ATTR_SYNCWRITES" source="PhanUndeclaredConstant"/>
20:25:23     <error line="88" severity="warning" message="Reference to undeclared constant \RedisBagOStuff::QOS_SYNCWRITES_NONE" source="PhanUndeclaredConstant"/>
20:25:23     <error line="308" severity="warning" message="Reference to undeclared constant \RedisBagOStuff::TTL_INDEFINITE" source="PhanUndeclaredConstant"/>
20:25:23     <error line="320" severity="warning" message="Reference to undeclared constant \RedisBagOStuff::TTL_INDEFINITE" source="PhanUndeclaredConstant"/>
20:25:23     <error line="420" severity="warning" message="Reference to undeclared constant \RedisBagOStuff::TTL_INDEFINITE" source="PhanUndeclaredConstant"/>
20:25:23   </file>
20:25:23   <file name="includes/objectcache/SqlBagOStuff.php">
20:25:23     <error line="122" severity="warning" message="Reference to undeclared constant \SqlBagOStuff::ATTR_EMULATION" source="PhanUndeclaredConstant"/>
20:25:23     <error line="122" severity="warning" message="Reference to undeclared constant \SqlBagOStuff::QOS_EMULATION_SQL" source="PhanUndeclaredConstant"/>
20:25:23     <error line="123" severity="warning" message="Reference to undeclared constant \SqlBagOStuff::ATTR_SYNCWRITES" source="PhanUndeclaredConstant"/>
20:25:23     <error line="123" severity="warning" message="Reference to undeclared constant \SqlBagOStuff::QOS_SYNCWRITES_NONE" source="PhanUndeclaredConstant"/>
20:25:23     <error line="146" severity="warning" message="Reference to undeclared constant \SqlBagOStuff::ATTR_SYNCWRITES" source="PhanUndeclaredConstant"/>
20:25:23     <error line="146" severity="warning" message="Reference to undeclared constant \SqlBagOStuff::QOS_SYNCWRITES_BE" source="PhanUndeclaredConstant"/>
20:25:23   </file>
20:25:23 </checkstyle>

Event Timeline

Daimona subscribed.

FTR: This really seems like a phan bug, but I couldn't reproduce the issue with smaller pieces of code.

Legoktm renamed this task from Constant inheritance not detected in phan block CI to Constant inheritance not detected in phan, blocking merge of a patch.Feb 10 2020, 4:28 AM

I can reproduce this with master phan as well:

aaron@SPECTRE-GRE3FQT:~/PhpstormProjects/mediawiki/core$ ../../phan/phan
   analyze ████████████████████████████████████████████████████████████ 100.0% 1558MB/1559MB
includes/libs/objectcache/HashBagOStuff.php:143 PhanUndeclaredConstant Reference to undeclared constant \HashBagOStuff::TTL_INDEFINITE
includes/libs/objectcache/MediumSpecificBagOStuff.php:38 PhanUndeclaredConstant Reference to undeclared constant \MediumSpecificBagOStuff::ERR_NONE
includes/libs/objectcache/MediumSpecificBagOStuff.php:428 PhanUndeclaredConstant Reference to undeclared constant \MediumSpecificBagOStuff::TTL_INDEFINITE
includes/libs/objectcache/MediumSpecificBagOStuff.php:470 PhanUndeclaredConstant Reference to undeclared constant \MediumSpecificBagOStuff::TTL_DAY
includes/libs/objectcache/MediumSpecificBagOStuff.php:744 PhanUndeclaredConstant Reference to undeclared constant \MediumSpecificBagOStuff::ERR_NONE
includes/libs/objectcache/MediumSpecificBagOStuff.php:819 PhanUndeclaredConstant Reference to undeclared constant \MediumSpecificBagOStuff::TTL_INDEFINITE
includes/libs/objectcache/MediumSpecificBagOStuff.php:819 PhanUndeclaredConstant Reference to undeclared constant \MediumSpecificBagOStuff::TTL_YEAR
includes/libs/objectcache/MediumSpecificBagOStuff.php:836 PhanUndeclaredConstant Reference to undeclared constant \MediumSpecificBagOStuff::TTL_INDEFINITE
includes/libs/objectcache/MediumSpecificBagOStuff.php:860 PhanUndeclaredConstant Reference to undeclared constant \MediumSpecificBagOStuff::TTL_INDEFINITE
includes/libs/objectcache/MediumSpecificBagOStuff.php:925 PhanUndeclaredConstant Reference to undeclared constant \MediumSpecificBagOStuff::QOS_UNKNOWN
includes/libs/objectcache/MemcachedBagOStuff.php:33 PhanUndeclaredConstant Reference to undeclared constant \MemcachedBagOStuff::ATTR_SYNCWRITES
includes/libs/objectcache/MemcachedBagOStuff.php:33 PhanUndeclaredConstant Reference to undeclared constant \MemcachedBagOStuff::QOS_SYNCWRITES_BE
includes/libs/objectcache/MemcachedBagOStuff.php:108 PhanUndeclaredConstant Reference to undeclared constant \MemcachedBagOStuff::TTL_MONTH
includes/libs/objectcache/RESTBagOStuff.php:135 PhanUndeclaredConstant Reference to undeclared constant \RESTBagOStuff::ATTR_SYNCWRITES
includes/libs/objectcache/RESTBagOStuff.php:135 PhanUndeclaredConstant Reference to undeclared constant \RESTBagOStuff::QOS_SYNCWRITES_QC
includes/libs/objectcache/RESTBagOStuff.php:339 PhanUndeclaredConstant Reference to undeclared constant \RESTBagOStuff::ERR_UNEXPECTED
includes/libs/objectcache/RESTBagOStuff.php:339 PhanUndeclaredConstant Reference to undeclared constant \RESTBagOStuff::ERR_UNREACHABLE
includes/libs/objectcache/RedisBagOStuff.php:88 PhanUndeclaredConstant Reference to undeclared constant \RedisBagOStuff::ATTR_SYNCWRITES
includes/libs/objectcache/RedisBagOStuff.php:88 PhanUndeclaredConstant Reference to undeclared constant \RedisBagOStuff::QOS_SYNCWRITES_NONE
includes/libs/objectcache/RedisBagOStuff.php:308 PhanUndeclaredConstant Reference to undeclared constant \RedisBagOStuff::TTL_INDEFINITE
includes/libs/objectcache/RedisBagOStuff.php:320 PhanUndeclaredConstant Reference to undeclared constant \RedisBagOStuff::TTL_INDEFINITE
includes/libs/objectcache/RedisBagOStuff.php:420 PhanUndeclaredConstant Reference to undeclared constant \RedisBagOStuff::TTL_INDEFINITE
includes/libs/redis/RedisConnectionPool.php:100 PhanUndeclaredConstant Reference to undeclared constant \Redis::SERIALIZER_IGBINARY
includes/objectcache/SqlBagOStuff.php:122 PhanUndeclaredConstant Reference to undeclared constant \SqlBagOStuff::ATTR_EMULATION
includes/objectcache/SqlBagOStuff.php:122 PhanUndeclaredConstant Reference to undeclared constant \SqlBagOStuff::QOS_EMULATION_SQL
includes/objectcache/SqlBagOStuff.php:123 PhanUndeclaredConstant Reference to undeclared constant \SqlBagOStuff::ATTR_SYNCWRITES
includes/objectcache/SqlBagOStuff.php:123 PhanUndeclaredConstant Reference to undeclared constant \SqlBagOStuff::QOS_SYNCWRITES_NONE
includes/objectcache/SqlBagOStuff.php:146 PhanUndeclaredConstant Reference to undeclared constant \SqlBagOStuff::ATTR_SYNCWRITES
includes/objectcache/SqlBagOStuff.php:146 PhanUndeclaredConstant Reference to undeclared constant \SqlBagOStuff::QOS_SYNCWRITES_BE

It seems to be subclass use of constants only.

@aaron Were you able to extract a minimal test case from that? If not, we can try to open an issue without it anyway. Perhaps the issue is already known upstream.

Fixed upstream, will be included in phan 2.4.9. Based on previous release times, we can expect it to happen in the next 2 weeks (I believe). Once that happens, we should upgrade phan in mediawiki/tools/phan and make our release as well. Please ping me if I forget to do that!

Change 571724 had a related patch set uploaded (by Daimona Eaytoy; owner: Daimona Eaytoy):
[mediawiki/tools/phan@master] Upgrade phan to 2.4.9

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

Change 571724 merged by jenkins-bot:
[mediawiki/tools/phan@master] Upgrade phan to 2.4.9

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

Change 572058 had a related patch set uploaded (by Daimona Eaytoy; owner: Daimona Eaytoy):
[mediawiki/core@master] build: Upgrade mediawiki-phan-config to 0.9.2

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

Change 572058 merged by jenkins-bot:
[mediawiki/core@master] build: Upgrade mediawiki-phan-config to 0.9.2

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

Umherirrender triaged this task as Medium priority.