mirror of
https://github.com/jupeter/clean-code-php.git
synced 2025-09-25 21:49:04 +02:00
Merge pull request #20 from peter-gribanov/mental_mapping
[Bugfix] Correct use foreach
This commit is contained in:
@@ -108,7 +108,7 @@ Explicit is better than implicit.
|
|||||||
```php
|
```php
|
||||||
$l = ['Austin', 'New York', 'San Francisco'];
|
$l = ['Austin', 'New York', 'San Francisco'];
|
||||||
|
|
||||||
foreach($i=0; $i<count($l); $i++) {
|
for ($i = 0; $i < count($l); $i++) {
|
||||||
$li = $l[$i];
|
$li = $l[$i];
|
||||||
oStuff();
|
oStuff();
|
||||||
doSomeOtherStuff();
|
doSomeOtherStuff();
|
||||||
@@ -124,9 +124,7 @@ foreach($i=0; $i<count($l); $i++) {
|
|||||||
```php
|
```php
|
||||||
$locations = ['Austin', 'New York', 'San Francisco'];
|
$locations = ['Austin', 'New York', 'San Francisco'];
|
||||||
|
|
||||||
foreach($i=0; $i<count($locations); $i++) {
|
foreach ($locations as $location) {
|
||||||
$location = $locations[$i];
|
|
||||||
|
|
||||||
doStuff();
|
doStuff();
|
||||||
doSomeOtherStuff();
|
doSomeOtherStuff();
|
||||||
// ...
|
// ...
|
||||||
|
Reference in New Issue
Block a user