Page MenuHomePhabricator

Remove use of PHP extract() function (use explicit assignment)
Open, NormalPublic

Description

extract() makes variables appear from nowhere, and should really be cleaned up in most (all?) cases to be made explicit.

Details

Reference
bz26496

Event Timeline

bzimport raised the priority of this task from to Normal.Nov 21 2014, 11:20 PM
bzimport added a project: MediaWiki-General.
bzimport set Reference to bz26496.
bzimport added a subscriber: Unknown Object (MLST).
Reedy created this task.Dec 30 2010, 2:53 AM

Although $var->extract( calls were also matched, here's a resultspage that may be useful to see visualy:
http://toolserver.org/~krinkle/wikimedia-svn-search/view.php?id=59&hash=808b5bef729e4547355d3c659d16a0dd#F5

ViewVC links in the right column.

Heh... it's a shame PHP doesn't have destructuring assignment for non-numeiric arrays/objects.

Krinkle renamed this task from extract() sucks (change for explicit definition) to PHP extract() sucks (change for explicit definition).Dec 10 2014, 2:12 PM
Krinkle updated the task description. (Show Details)
Krinkle added a project: Technical-Debt.
Krinkle set Security to None.
Krinkle removed a subscriber: Unknown Object (MLST).
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptSep 23 2015, 11:15 PM

Change 271358 had a related patch set uploaded (by Ricordisamoa):
Replace extract() with explicit variable definitions in DjVuImage

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

Change 271358 merged by jenkins-bot:
Replace extract() with explicit variable definitions in DjVuImage

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

Heh... it's a shame PHP doesn't have destructuring assignment for non-numeiric arrays/objects.

https://wiki.php.net/rfc/list_keys has been implemented in PHP 7.1

So instead of

$arr = unpack( 'a4magic/a4chunk/NchunkLength', $header );
$chunk = $arr['chunk'];
$chunkLength = $arr['chunkLength'];

you should be able to write

[ 'chunk' => $chunk, 'chunkLength' => $chunkLength ] = unpack( 'a4magic/a4chunk/NchunkLength', $header );
Krinkle renamed this task from PHP extract() sucks (change for explicit definition) to Remove use of PHP extract() function (use explicit assignment).Dec 27 2017, 9:16 PM
Krinkle moved this task from Unsorted to Needs refactor on the Technical-Debt board.

Change 413937 had a related patch set uploaded (by MaxSem; owner: MaxSem):
[mediawiki/core@master] Don't suggest using extract()

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

Change 413937 merged by jenkins-bot:
[mediawiki/core@master] Don't suggest using extract()

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