1
0
mirror of https://github.com/jupeter/clean-code-php.git synced 2025-09-26 05:59:04 +02:00

foreach loop syntax fixed.

does not use "in" syntax, it uses "as"
This commit is contained in:
Emin Şen
2017-09-02 16:08:24 +03:00
committed by GitHub
parent cc9896241a
commit c058329bff

View File

@@ -1186,12 +1186,12 @@ class Square extends Rectangle {
}
function renderLargeRectangles($rectangles) {
foreach($rectangle in $rectangles) {
foreach($rectangles as $rectangle) {
$rectangle->setWidth(4);
$rectangle->setHeight(5);
$area = $rectangle->getArea(); // BAD: Will return 25 for Square. Should be 20.
$rectangle->render($area);
});
}
}
$rectangles = [new Rectangle(), new Rectangle(), new Square()];
@@ -1250,7 +1250,7 @@ class Square extends Shape {
}
function renderLargeRectangles($rectangles) {
foreach($rectangle in $rectangles) {
foreach($rectangles as $rectangle) {
if ($rectangle instanceof Square) {
$rectangle->setLength(5);
} else if ($rectangle instanceof Rectangle) {
@@ -1260,7 +1260,7 @@ function renderLargeRectangles($rectangles) {
$area = $rectangle->getArea();
$rectangle->render($area);
});
}
}
$shapes = [new Rectangle(), new Rectangle(), new Square()];