[PRES] [web-pres2] master: Fix syntax that disappeared in PHP 8 (I know)

[email protected] (Derick Rethans) Fri, 9 Aug 2024 14:48:23 +0000
Newsgroups php.pres
Message-ID <[email protected]>
Author: Derick Rethans (derickr)
Date: 2024-08-09T15:47:52+01:00

Commit: https://github.com/php/web-pres2/commit/d533ba2a71809cc501b8fc8bfff44be1151920c5
Raw diff: https://github.com/php/web-pres2/commit/d533ba2a71809cc501b8fc8bfff44be1151920c5.diff

Fix syntax that disappeared in PHP 8 (I know)

Changed paths:
  M  display.php
  M  index.php
  M  objects.php
  M  show.php


Diff:

diff --git a/display.php b/display.php
index b01c9fe..eaa5c4f 100644
--- a/display.php
+++ b/display.php
@@ -610,7 +610,7 @@ function _list(&$list) {
             if(!empty($list->lineheight)) $style = "line-height: ".$list->lineheight.';';
             echo '<ul class="pres" style="'.$style.'">';
         }
-        while(list($k,$bul)=each($list->bullets)) { $bul->display(); }
+        foreach($list->bullets as $k => $bul) { $bul->display(); }
         echo '</ul>';
     }
 
diff --git a/index.php b/index.php
index c4f289d..e202379 100644
--- a/index.php
+++ b/index.php
@@ -48,7 +48,7 @@
 			$pr[$i]['generated'] = false;
 		}
 		$pr[$i]['id'] = $pres_id;
-		$pr[$i]['slidecount'] = count($pres[1]->slides);
+		$pr[$i]['slidecount'] = count($pres[1]->slides ?? []);
 		$pr[$i]['title'] = $pres[1]->title;
 
 		if(isset($pres[1]->date)) {
diff --git a/objects.php b/objects.php
index 12af78a..1c185f1 100644
--- a/objects.php
+++ b/objects.php
@@ -84,7 +84,7 @@ function add_line_numbers($text)
 	$lnwidth = strlen(count($lines));
 	$format = '%'.$lnwidth."d: %s\n";
 	$lined_text = '';
-	while (list ($num, $line) = each ($lines)) {
+	foreach ($lines as $num => $line) {
 			$lined_text .= sprintf($format, $num + 1, $line);
 	}
 	return $lined_text;
diff --git a/show.php b/show.php
index 3a857f9..1690414 100644
--- a/show.php
+++ b/show.php
@@ -124,7 +124,7 @@
 function get_all_titles($pres) {
 	global $presentationDir;
 
-	while(list($slideNum,$slide) = each($pres->slides)) {
+	foreach($pres->slides as $slideNum => $slide) {
 		$fh = fopen($presentationDir.'/'.$pres->slides[$slideNum]->filename, "rb");
 		$r = new XML_Slide($fh);
 		$r->parse();