Index: src/wp-admin/includes/class-wp-upgrader.php
===================================================================
--- src/wp-admin/includes/class-wp-upgrader.php	(revision 40304)
+++ src/wp-admin/includes/class-wp-upgrader.php	(working copy)
@@ -358,9 +358,9 @@
 		$_files = $wp_filesystem->dirlist( $remote_destination, true, true );

 		// Flatten the resulting array, iterate using each as we append to the array during iteration.
-		while ( $f = each( $_files ) ) {
-			$file = $f['value'];
-			$name = $f['key'];
+		foreach ( $_files as $key => $value ) {
+			$file = $value;
+			$name = $key;

 			if ( ! isset( $file['files'] ) ) {
 				continue;
Index: src/wp-includes/Text/Diff/Engine/native.php
===================================================================
--- src/wp-includes/Text/Diff/Engine/native.php	(revision 40304)
+++ src/wp-includes/Text/Diff/Engine/native.php	(working copy)
@@ -190,7 +190,7 @@
                 }
                 $matches = $ymatches[$line];
                 reset($matches);
-                while (list(, $y) = each($matches)) {
+                foreach ( $matches as $y ) {
                     if (empty($this->in_seq[$y])) {
                         $k = $this->_lcsPos($y);
                         assert($k > 0);
@@ -198,7 +198,7 @@
                         break;
                     }
                 }
-                while (list(, $y) = each($matches)) {
+                foreach ( $matches as $y ) {
                     if ($y > $this->seq[$k - 1]) {
                         assert($y <= $this->seq[$k]);
                         /* Optimization: this is a common case: next match is
Index: src/wp-includes/class-snoopy.php
===================================================================
--- src/wp-includes/class-snoopy.php	(revision 40304)
+++ src/wp-includes/class-snoopy.php	(working copy)
@@ -183,8 +183,7 @@
 						$frameurls = $this->_frameurls;
 						$this->_frameurls = array();

-						while(list(,$frameurl) = each($frameurls))
-						{
+						foreach ( $frameurls as $frameurl ) {
 							if($this->_framedepth < $this->maxframes)
 							{
 								$this->fetch($frameurl);
@@ -243,8 +242,7 @@
 					$frameurls = $this->_frameurls;
 					$this->_frameurls = array();

-					while(list(,$frameurl) = each($frameurls))
-					{
+					foreach ( $frameurls as $frameurl ) {
 						if($this->_framedepth < $this->maxframes)
 						{
 							$this->fetch($frameurl);
@@ -341,8 +339,7 @@
 						$frameurls = $this->_frameurls;
 						$this->_frameurls = array();

-						while(list(,$frameurl) = each($frameurls))
-						{
+						foreach ( $frameurls as $frameurl ) {
 							if($this->_framedepth < $this->maxframes)
 							{
 								$this->fetch($frameurl);
@@ -408,7 +405,7 @@
 					$frameurls = $this->_frameurls;
 					$this->_frameurls = array();

-					while(list(,$frameurl) = each($frameurls))
+					foreach ( $frameurls as $frameurl ) {
 					{
 						if($this->_framedepth < $this->maxframes)
 						{
@@ -629,14 +626,12 @@

 		// catenate the non-empty matches from the conditional subpattern

-		while(list($key,$val) = each($links[2]))
-		{
+		foreach ( $links[2] as $key => $val ) {
 			if(!empty($val))
 				$match[] = $val;
 		}

-		while(list($key,$val) = each($links[3]))
-		{
+		foreach ( $links[3] as $key => $val ) {
 			if(!empty($val))
 				$match[] = $val;
 		}
@@ -821,8 +816,10 @@
 		{
 			if(!is_array($this->rawheaders))
 				$this->rawheaders = (array)$this->rawheaders;
-			while(list($headerKey,$headerVal) = each($this->rawheaders))
+
+			foreach ( $this->rawheaders as $headerKey => $headerVal ) {
 				$headers .= $headerKey.": ".$headerVal."\r\n";
+			}
 		}
 		if(!empty($content_type)) {
 			$headers .= "Content-type: $content_type";
@@ -985,8 +982,9 @@
 		{
 			if(!is_array($this->rawheaders))
 				$this->rawheaders = (array)$this->rawheaders;
-			while(list($headerKey,$headerVal) = each($this->rawheaders))
+			foreach ( $this->rawheaders as $headerKey => $headerVal ) {
 				$headers[] = $headerKey.": ".$headerVal;
+			}
 		}
 		if(!empty($content_type)) {
 			if ($content_type == "multipart/form-data")
@@ -1204,9 +1202,9 @@
 		switch ($this->_submit_type) {
 			case "application/x-www-form-urlencoded":
 				reset($formvars);
-				while(list($key,$val) = each($formvars)) {
+				foreach ( $formvars as $key => $val ) {
 					if (is_array($val) || is_object($val)) {
-						while (list($cur_key, $cur_val) = each($val)) {
+						foreach ( $val as $cur_key => $cur_val ) {
 							$postdata .= urlencode($key)."[]=".urlencode($cur_val)."&";
 						}
 					} else
@@ -1218,9 +1216,9 @@
 				$this->_mime_boundary = "Snoopy".md5(uniqid(microtime()));

 				reset($formvars);
-				while(list($key,$val) = each($formvars)) {
+				foreach ( $formvars as $key => $val ) {
 					if (is_array($val) || is_object($val)) {
-						while (list($cur_key, $cur_val) = each($val)) {
+						foreach ( $val as $cur_key => $cur_val ) {
 							$postdata .= "--".$this->_mime_boundary."\r\n";
 							$postdata .= "Content-Disposition: form-data; name=\"$key\[\]\"\r\n\r\n";
 							$postdata .= "$cur_val\r\n";
@@ -1233,9 +1231,9 @@
 				}

 				reset($formfiles);
-				while (list($field_name, $file_names) = each($formfiles)) {
+				foreach ( $formfiles as $field_name => $file_names ) {
 					settype($file_names, "array");
-					while (list(, $file_name) = each($file_names)) {
+					foreach ( $file_names as $file_name ) {
 						if (!is_readable($file_name)) continue;

 						$fp = fopen($file_name, "r");
Index: tests/phpunit/includes/bootstrap.php
===================================================================
--- tests/phpunit/includes/bootstrap.php	(revision 40304)
+++ tests/phpunit/includes/bootstrap.php	(working copy)
@@ -126,7 +126,7 @@
 	function __construct( $argv ) {
 		array_shift( $argv );
 		$options = array();
-		while ( list( $i, $arg ) = each( $argv ) ) {
+		foreach ( $argv as $i => $arg ) {
 			try {
 				if ( strlen( $arg ) > 1 && $arg[0] === '-' && $arg[1] === '-' ) {
 					PHPUnit_Util_Getopt::parseLongOption( substr( $arg, 2 ), $this->longOptions, $options, $argv );
