Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F22419086
reused-local.lint-test
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Authored By
Unknown
Size
1 KB
Referenced Files
None
Subscribers
None
reused-local.lint-test
View Options
<?php
function f($stuff, $thing) {
foreach ($stuff as $ii) {}
// OK: Only reused for iteration.
foreach ($stuff as $ii) {}
}
function g($stuff, $thing) {
foreach ($stuff as $thing) {}
// OK: Not reused later.
}
function h($stuff, $thing) {
// OK: Used afterwards but not before.
foreach ($stuff as $key => $val) {}
$key = 1;
$thing = 1;
$thing = $key;
$key = $thing;
}
function i($stuff, $thing) {
foreach ($stuff as $thing) {
$thing++;
}
// OK: Used afterwards but inside loop.
foreach ($stuff as $thing) {
$thing++;
}
}
function j($stuff, $thing) {
foreach ($stuff as $thing) {
break;
}
// ERROR: Clobbers $thing; probably not what the author intended.
f($thing);
}
function k($stuff, $thing) {
foreach ($stuff as $thing) {
break;
}
// ERROR: Clobbers $thing. Test case to cover some errors of implementation
// where subsequent legitimate foreach()es threw a wrench in the gears.
f($thing);
$other = array();
foreach ($other as $item) {}
}
~~~~~~~~~~
error:43:22
error:53:22
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sat, Nov 28, 02:18 (1 d, 16 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1217853
Default Alt Text
reused-local.lint-test (1 KB)
Attached To
Mode
R118 Arcanist - fork
Attached
Detach File
Event Timeline