phpcompat icon indicating copy to clipboard operation
phpcompat copied to clipboard

FALSE POSITIVE: break within a loop

Open msykes opened this issue 7 years ago • 3 comments

This line of code

foreach( Some_Object::return_an_array() as $array_item ) break;

whilst valid will cause the following error:

ERROR | Using ‘break’ outside of a loop or switch structure is invalid and will throw a fatal error since PHP 7.0

msykes avatar Apr 12 '17 19:04 msykes

To work arround this false positive use curly brackets.

ScrewedCode avatar Jul 19 '17 21:07 ScrewedCode

Thanks, I think I must have done that already as the error doesn't appear anymore. Also thought you'd like to know about the false positive.

msykes avatar Jul 20 '17 15:07 msykes

@msykes Hi Marcus, this is a known issue and being working on - see https://github.com/wimg/PHPCompatibility/issues/292

jrfnl avatar Jul 20 '17 23:07 jrfnl