Doc #69853 [NEW]: break behavior unspecified when no argument is specified

From: Date: Tue, 16 Jun 2015 18:12:52 +0000
Subject: Doc #69853 [NEW]: break behavior unspecified when no argument is specified
Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-12439@lists.php.net to get a copy of this message
From:             chealer at gmail dot com
Operating system: 
PHP version:      Irrelevant
Package:          Documentation problem
Bug Type:         Documentation Problem
Bug description:break behavior unspecified when no argument is specified

Description:
------------
---
From manual page: http://www.php.net/control-structures.break
---
"break accepts an optional numeric argument which tells it how many
nested enclosing structures are to be broken out of."

The documentation does not specify what happens if break's optional is
not provided. Therefore, the effect of a "break;" statement inside
several concerned structures (as happens at the end of the example) is
unspecified. As of PHP 5.4, the effect appears to be that of "break
1;".

Comment http://php.net/manual/en/control-structures.break.php#90308
confirms.

Test script:
---------------
<?php
foreach(array(1, 2) as $iteration) {
	var_dump($iteration);
	foreach (array() as $dummy) {
		break;
	}
}
?>

Actual result:
--------------
int 1

int 2

-- 
Edit bug report at https://bugs.php.net/bug.php?id=69853&edit=1
-- 
Try a snapshot (PHP 5.4):   https://bugs.php.net/fix.php?id=69853&r=trysnapshot54
Try a snapshot (PHP 5.5):   https://bugs.php.net/fix.php?id=69853&r=trysnapshot55
Try a snapshot (trunk):     https://bugs.php.net/fix.php?id=69853&r=trysnapshottrunk
Fixed in SVN:               https://bugs.php.net/fix.php?id=69853&r=fixed
Fixed in release:           https://bugs.php.net/fix.php?id=69853&r=alreadyfixed
Need backtrace:             https://bugs.php.net/fix.php?id=69853&r=needtrace
Need Reproduce Script:      https://bugs.php.net/fix.php?id=69853&r=needscript
Try newer version:          https://bugs.php.net/fix.php?id=69853&r=oldversion
Not developer issue:        https://bugs.php.net/fix.php?id=69853&r=support
Expected behavior:          https://bugs.php.net/fix.php?id=69853&r=notwrong
Not enough info:            https://bugs.php.net/fix.php?id=69853&r=notenoughinfo
Submitted twice:            https://bugs.php.net/fix.php?id=69853&r=submittedtwice
register_globals:           https://bugs.php.net/fix.php?id=69853&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=69853&r=php4
Daylight Savings:           https://bugs.php.net/fix.php?id=69853&r=dst
IIS Stability:              https://bugs.php.net/fix.php?id=69853&r=isapi
Install GNU Sed:            https://bugs.php.net/fix.php?id=69853&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=69853&r=float
No Zend Extensions:         https://bugs.php.net/fix.php?id=69853&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=69853&r=mysqlcfg



Thread (7 messages)

« previous php.doc.bugs (#12439) next »