Following updates can be performed:
- never return type
- Array unpacking with string keys
- Named Arguments where necessary
- Union Types
- Nullsafe Operator
Following updates can be performed:
| Status | Subtype | Assigned | Task | ||
|---|---|---|---|---|---|
| Open | Goal | None | T402514 Update ContentTranslation to use PHP 8.1 features | ||
| Stalled | None | T403194 Use PHP 8.1 features in the ActionAPI folder |
Change #1182888 had a related patch set uploaded (by Abijeet Patro; author: Abijeet Patro):
[mediawiki/extensions/ContentTranslation@master] ApiContentTranslationSave: Update to use PHP 8.1 features
Change #1182891 had a related patch set uploaded (by Abijeet Patro; author: Abijeet Patro):
[mediawiki/extensions/ContentTranslation@master] ApiContentTranslationDelete: Update to use PHP 8.1 features
We have noticed a blocker that Phan doesn't seem to support all these features yet. More details to be added.
We're currently unable to use nullsafe operator due to limitations with phan. Possibly also the never return type. I think we can put this task in backlog and revisit once we have better support for PHP 8.1 feature detection in phan. Similar ticket: T334726
Upstream has fixed the Phan limitation this task is blocked on.
phan/phan#5571 (commit 7b493cda) was merged on 2026-09-15, closing phan/phan#5569. It teaches Phan's condition visitors to narrow a nullsafe receiver to non-null inside a guarded branch: $x?->m() evaluates to null when $x is null, so a truthy test on it proves $x is not null. ConditionVisitor had no case for ast\AST_NULLSAFE_METHOD_CALL, which is why $block stayed ?Block.
That is precisely the error reported on change 1182891:
includes/ActionApi/ApiContentTranslationDelete.php:33 PhanTypeMismatchArgumentNullable Argument 1 ($block) is $block of type ?\MediaWiki\Block\AbstractBlock|... but ApiContentTranslationDelete::dieBlocked() takes \MediaWiki\Block\Block
As @Nikerabbit suspected above, the operator itself was already supported; the gap was in condition narrowing, not parsing.
This does not unblock CI yet. mediawiki/mediawiki-phan-config pins an exact version:
"phan/phan": "6.0.7"
and 6.0.7 (released 2026-06-22) predates the fix, which currently exists only on Phan's master branch. Checking a reduced version of the same pattern against both:
| Phan | Result |
|---|---|
| 6.0.7 | 4 x PhanTypeMismatchArgumentNullable |
| master 7b493cd | clean |
So rechecking 1182891 today would still fail. Three things need to happen, in order:
All four nullsafe shapes are covered by the upstream fix, not just the method-call form: property fetch, strict comparison against true, and the inverted if ( !$x?->m() ) { return; } early-return guard all narrow correctly now. So the wider "use PHP 8.1 features" work in this task should not hit the same wall again once the pin moves.
Note also that change 1182888 has been Verified+2 since 2026-03-12, so 1182891 is the only one of the pair still held up.
Change #1182888 merged by jenkins-bot:
[mediawiki/extensions/ContentTranslation@master] ApiContentTranslationSave: Update to use PHP 8.1 features