extract() makes variables appear from nowhere, and should really be cleaned up in most (all?) cases to be made explicit.
Description
Details
- Reference
- bz26496
Related Objects
- Mentioned In
- T180398: CodeSniffer to warn against usages of extract()
- Mentioned Here
- T180398: CodeSniffer to warn against usages of extract()
Event Timeline
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.
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
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 );
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
The few calls are either for tests or $GLOBALS (and mostly a combination of both) or false positives of methods called extract. MediaWiki-Codesniffer bans usage of extract anyways. (T180398)