Skip to content

Commit 6d2b42b

Browse files
committed
Generic/ForLoopWithTestFunctionCall: add more tests
Adds tests for function call on new object and when the first, second and/or third conditions are missing. Tests were added using both the regular and the alternative `for` syntax.
1 parent 72bad6f commit 6d2b42b

File tree

2 files changed

+53
-1
lines changed

2 files changed

+53
-1
lines changed

src/Standards/Generic/Tests/CodeAnalysis/ForLoopWithTestFunctionCallUnitTest.1.inc

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,49 @@ endfor;
4343
for ($i = 0; $countFunction($value); $i++):
4444
echo $i;
4545
endfor;
46+
47+
for ($i = 0; (new MyClass)->method(); $i++) {
48+
}
49+
50+
for (; $i < 10; ++$i) {}
51+
52+
for (; count($a); ++$i) {}
53+
54+
for ($i = 0;; ++$i) {}
55+
56+
for ($i = 0; $i < 10;) {}
57+
58+
for ($i = 0; count($a);) {}
59+
60+
for (;; $i++) {}
61+
62+
for ($i = 0;;) {}
63+
64+
for (;;) {}
65+
66+
for ($i = 0; (new MyClass)->method(); $i++):
67+
endfor;
68+
69+
for (; $i < 10; ++$i) :
70+
endfor;
71+
72+
for (; count($a); ++$i) :
73+
endfor;
74+
75+
for ($i = 0;; ++$i) :
76+
endfor;
77+
78+
for ($i = 0; $i < 10;) :
79+
endfor;
80+
81+
for ($i = 0; count($a);) :
82+
endfor;
83+
84+
for (;; $i++) :
85+
endfor;
86+
87+
for ($i = 0;;) :
88+
endfor;
89+
90+
for (;;) :
91+
endfor;

src/Standards/Generic/Tests/CodeAnalysis/ForLoopWithTestFunctionCallUnitTest.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,16 @@ public function getWarningList($testFile='')
5858
35 => 1,
5959
39 => 1,
6060
43 => 1,
61+
47 => 1,
62+
52 => 1,
63+
58 => 1,
64+
66 => 1,
65+
72 => 1,
66+
81 => 1,
6167
];
6268
default:
6369
return [];
64-
}
70+
}//end switch
6571

6672
}//end getWarningList()
6773

0 commit comments

Comments
 (0)