Skip to content

Commit

Permalink
Merge pull request #911 from goatherd/fix-foreach-as-style
Browse files Browse the repository at this point in the history
fix foreach coding style
  • Loading branch information
deeky666 committed Jan 14, 2014
2 parents b0736b5 + a485e79 commit cf43edd
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 22 deletions.
2 changes: 1 addition & 1 deletion docs/en/cookbook/aggregate-fields.rst
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ collection, which means we can compute this value at runtime:
public function getBalance()
{
$balance = 0;
foreach ($this->entries AS $entry) {
foreach ($this->entries as $entry) {
$balance += $entry->getAmount();
}
return $balance;
Expand Down
2 changes: 1 addition & 1 deletion docs/en/cookbook/dql-custom-walkers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ implementation is:
{
$parent = null;
$parentName = null;
foreach ($this->_getQueryComponents() AS $dqlAlias => $qComp) {
foreach ($this->_getQueryComponents() as $dqlAlias => $qComp) {
if ($qComp['parent'] === null && $qComp['nestingLevel'] == 0) {
$parent = $qComp;
$parentName = $dqlAlias;
Expand Down
2 changes: 1 addition & 1 deletion docs/en/cookbook/validation-of-entities.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ is allowed to:
$orderLimit = $this->customer->getOrderLimit();
$amount = 0;
foreach ($this->orderLines AS $line) {
foreach ($this->orderLines as $line) {
$amount += $line->getAmount();
}
Expand Down
4 changes: 2 additions & 2 deletions docs/en/reference/batch-processing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ with the batching strategy that was already used for bulk inserts:
$i = 0;
$q = $em->createQuery('select u from MyProject\Model\User u');
$iterableResult = $q->iterate();
foreach($iterableResult AS $row) {
foreach ($iterableResult as $row) {
$user = $row[0];
$user->increaseCredit();
$user->calculateNewBonuses();
Expand Down Expand Up @@ -162,7 +162,7 @@ problems using the following approach:
<?php
$q = $this->_em->createQuery('select u from MyProject\Model\User u');
$iterableResult = $q->iterate();
foreach ($iterableResult AS $row) {
foreach ($iterableResult as $row) {
// do stuff with the data in the row, $row[0] is always the object
// detach from Doctrine, so that it can be Garbage-Collected immediately
Expand Down
10 changes: 5 additions & 5 deletions docs/en/reference/events.rst
Original file line number Diff line number Diff line change
Expand Up @@ -584,23 +584,23 @@ mentioned sets. See this example:
$em = $eventArgs->getEntityManager();
$uow = $em->getUnitOfWork();
foreach ($uow->getScheduledEntityInsertions() AS $entity) {
foreach ($uow->getScheduledEntityInsertions() as $entity) {
}
foreach ($uow->getScheduledEntityUpdates() AS $entity) {
foreach ($uow->getScheduledEntityUpdates() as $entity) {
}
foreach ($uow->getScheduledEntityDeletions() AS $entity) {
foreach ($uow->getScheduledEntityDeletions() as $entity) {
}
foreach ($uow->getScheduledCollectionDeletions() AS $col) {
foreach ($uow->getScheduledCollectionDeletions() as $col) {
}
foreach ($uow->getScheduledCollectionUpdates() AS $col) {
foreach ($uow->getScheduledCollectionUpdates() as $col) {
}
}
Expand Down
2 changes: 1 addition & 1 deletion docs/en/reference/working-with-associations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ removed from the system:
<?php
$user = $em->find('User', $deleteUserId);
foreach ($user->getAuthoredComments() AS $comment) {
foreach ($user->getAuthoredComments() as $comment) {
$em->remove($comment);
}
$em->remove($user);
Expand Down
2 changes: 1 addition & 1 deletion docs/en/reference/working-with-objects.rst
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ your code. See the following code:
// accessing the comments as an iterator triggers the lazy-load
// retrieving ALL the comments of this article from the database
// using a single SELECT statement
foreach ($article->getComments() AS $comment) {
foreach ($article->getComments() as $comment) {
echo $comment->getText() . "\n\n";
}
Expand Down
20 changes: 10 additions & 10 deletions docs/en/tutorials/getting-started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1054,7 +1054,7 @@ like this:
$bug->setCreated(new DateTime("now"));
$bug->setStatus("OPEN");
foreach ($productIds AS $productId) {
foreach ($productIds as $productId) {
$product = $entityManager->find("Product", $productId);
$bug->assignToProduct($product);
}
Expand Down Expand Up @@ -1108,11 +1108,11 @@ the first read-only use-case:
$query->setMaxResults(30);
$bugs = $query->getResult();
foreach($bugs AS $bug) {
foreach ($bugs as $bug) {
echo $bug->getDescription()." - ".$bug->getCreated()->format('d.m.Y')."\n";
echo " Reported by: ".$bug->getReporter()->getName()."\n";
echo " Assigned to: ".$bug->getEngineer()->getName()."\n";
foreach($bug->getProducts() AS $product) {
foreach ($bug->getProducts() as $product) {
echo " Platform: ".$product->getName()."\n";
}
echo "\n";
Expand Down Expand Up @@ -1194,11 +1194,11 @@ can rewrite our code:
$query = $entityManager->createQuery($dql);
$bugs = $query->getArrayResult();
foreach ($bugs AS $bug) {
foreach ($bugs as $bug) {
echo $bug['description'] . " - " . $bug['created']->format('d.m.Y')."\n";
echo " Reported by: ".$bug['reporter']['name']."\n";
echo " Assigned to: ".$bug['engineer']['name']."\n";
foreach($bug['products'] AS $product) {
foreach ($bug['products'] as $product) {
echo " Platform: ".$product['name']."\n";
}
echo "\n";
Expand Down Expand Up @@ -1312,7 +1312,7 @@ and usage of bound parameters:
echo "You have created or assigned to " . count($myBugs) . " open bugs:\n\n";
foreach ($myBugs AS $bug) {
foreach ($myBugs as $bug) {
echo $bug->getId() . " - " . $bug->getDescription()."\n";
}
Expand All @@ -1337,7 +1337,7 @@ grouped by product:
"JOIN b.products p WHERE b.status = 'OPEN' GROUP BY p.id";
$productBugs = $entityManager->createQuery($dql)->getScalarResult();
foreach($productBugs as $productBug) {
foreach ($productBugs as $productBug) {
echo $productBug['name']." has " . $productBug['openBugs'] . " open bugs!\n";
}
Expand Down Expand Up @@ -1417,7 +1417,7 @@ example querying for all closed bugs:
$bugs = $entityManager->getRepository('Bug')
->findBy(array('status' => 'CLOSED'));
foreach ($bugs AS $bug) {
foreach ($bugs as $bug) {
// do stuff
}
Expand Down Expand Up @@ -1519,11 +1519,11 @@ As an example here is the code of the first use case "List of Bugs":
$bugs = $entityManager->getRepository('Bug')->getRecentBugs();
foreach($bugs AS $bug) {
foreach ($bugs as $bug) {
echo $bug->getDescription()." - ".$bug->getCreated()->format('d.m.Y')."\n";
echo " Reported by: ".$bug->getReporter()->getName()."\n";
echo " Assigned to: ".$bug->getEngineer()->getName()."\n";
foreach($bug->getProducts() AS $product) {
foreach ($bug->getProducts() as $product) {
echo " Platform: ".$product->getName()."\n";
}
echo "\n";
Expand Down

0 comments on commit cf43edd

Please sign in to comment.