summaryrefslogtreecommitdiff
path: root/tests/lang/foreachLoopIteratorAggregate.001.phpt
diff options
context:
space:
mode:
authorPeter Kokot <peterkokot@gmail.com>2018-10-14 17:45:48 +0200
committerPeter Kokot <peterkokot@gmail.com>2018-10-14 19:45:12 +0200
commit782352c54ad69c517e3c32b0dd2c25d74842647a (patch)
tree220bdc1e814e9f44b3578d49b3f239a3fdefa1d0 /tests/lang/foreachLoopIteratorAggregate.001.phpt
parent604d4bdae5037e021c1f9d35f08cbeddd610d84c (diff)
downloadphp-git-782352c54ad69c517e3c32b0dd2c25d74842647a.tar.gz
Trim trailing whitespace in *.phpt
Diffstat (limited to 'tests/lang/foreachLoopIteratorAggregate.001.phpt')
-rw-r--r--tests/lang/foreachLoopIteratorAggregate.001.phpt38
1 files changed, 19 insertions, 19 deletions
diff --git a/tests/lang/foreachLoopIteratorAggregate.001.phpt b/tests/lang/foreachLoopIteratorAggregate.001.phpt
index 094fc3b8bb..47baeab42c 100644
--- a/tests/lang/foreachLoopIteratorAggregate.001.phpt
+++ b/tests/lang/foreachLoopIteratorAggregate.001.phpt
@@ -5,19 +5,19 @@ foreach with iteratorAggregate
class EnglishMealIterator implements Iterator {
private $pos=0;
private $myContent=array("breakfast", "dinner", "tea");
-
+
public function valid() {
global $indent;
echo "$indent--> " . __METHOD__ . " ($this->pos)\n";
return $this->pos < count($this->myContent);
}
-
+
public function next() {
global $indent;
echo "$indent--> " . __METHOD__ . " ($this->pos)\n";
$this->pos++;
}
-
+
public function rewind() {
global $indent;
echo "$indent--> " . __METHOD__ . " ($this->pos)\n";
@@ -29,31 +29,31 @@ class EnglishMealIterator implements Iterator {
echo "$indent--> " . __METHOD__ . " ($this->pos)\n";
return $this->myContent[$this->pos];
}
-
+
public function key() {
global $indent;
echo "$indent--> " . __METHOD__ . " ($this->pos)\n";
return "meal " . $this->pos;
}
-
+
}
class FrenchMealIterator implements Iterator {
private $pos=0;
private $myContent=array("petit dejeuner", "dejeuner", "gouter", "dinner");
-
+
public function valid() {
global $indent;
echo "$indent--> " . __METHOD__ . " ($this->pos)\n";
return $this->pos < count($this->myContent);
}
-
+
public function next() {
global $indent;
echo "$indent--> " . __METHOD__ . " ($this->pos)\n";
$this->pos++;
}
-
+
public function rewind() {
global $indent;
echo "$indent--> " . __METHOD__ . " ($this->pos)\n";
@@ -65,30 +65,30 @@ class FrenchMealIterator implements Iterator {
echo "$indent--> " . __METHOD__ . " ($this->pos)\n";
return $this->myContent[$this->pos];
}
-
+
public function key() {
global $indent;
echo "$indent--> " . __METHOD__ . " ($this->pos)\n";
return "meal " . $this->pos;
}
-
+
}
Class EuropeanMeals implements IteratorAggregate {
-
+
private $storedEnglishMealIterator;
private $storedFrenchMealIterator;
-
+
public function __construct() {
$this->storedEnglishMealIterator = new EnglishMealIterator;
$this->storedFrenchMealIterator = new FrenchMealIterator;
}
-
+
public function getIterator() {
global $indent;
echo "$indent--> " . __METHOD__ . "\n";
-
+
//Alternate between English and French meals
static $i = 0;
if ($i++%2 == 0) {
@@ -97,7 +97,7 @@ Class EuropeanMeals implements IteratorAggregate {
return $this->storedFrenchMealIterator;
}
}
-
+
}
$f = new EuropeanMeals;
@@ -105,11 +105,11 @@ var_dump($f);
echo "-----( Simple iteration 1: )-----\n";
foreach ($f as $k=>$v) {
- echo "$k => $v\n";
+ echo "$k => $v\n";
}
echo "-----( Simple iteration 2: )-----\n";
foreach ($f as $k=>$v) {
- echo "$k => $v\n";
+ echo "$k => $v\n";
}
@@ -117,11 +117,11 @@ $indent = " ";
echo "\n\n\n-----( Nested iteration: )-----\n";
$count=1;
foreach ($f as $k=>$v) {
- echo "\nTop level " . $count++ . ": \n";
+ echo "\nTop level " . $count++ . ": \n";
echo "$k => $v\n";
$indent = " ";
foreach ($f as $k=>$v) {
- echo " $k => $v\n";
+ echo " $k => $v\n";
}
$indent = " ";
}