Skip to content

Commit

Permalink
Rework code to remove confusing foreach loop when setting variable to…
Browse files Browse the repository at this point in the history
… array item

- the array only ever has one data item in it
- the foreach loop was taking each item from the array, which was just the one item, and setting it to a different variable
- the new code sets the variable to the first and only item in the array instead, without the need for a loop
  • Loading branch information
rowan04 committed Sep 13, 2023
1 parent a7ba6e0 commit 9ec9488
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions lib/Doctrine/deploy/AddServiceGroupRoles.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@
"found with name: " . $userRole);
}

foreach ($roleTypes as $result) {
$roleType = $result;
}
// Set $roleType as the first and only role type in the
// roleTypes array
$roleType = $roleTypes[0];

// Get user entity
$userDN = (string) $user->CERTDN;
Expand All @@ -56,9 +56,8 @@
$userDN);
}

foreach ($users as $doctrineUser) {
$doctrineUser = $doctrineUser;
}
// Set $doctrineUser as the first and only user in the users array
$doctrineUser = $users[0];

// get serviceGroup entity
$sgName = (string) $role->ON_ENTITY;
Expand All @@ -76,9 +75,9 @@
"found name: " . $sgName);
}

foreach ($serviceGroups as $serviceGroup) {
$serviceGroup = $serviceGroup;
}
// Set $serviceGroup as the first and only service group in the
// serviceGroups array
$serviceGroup = $serviceGroups[0];

$doctrineRole = new Role(
$roleType,
Expand Down

0 comments on commit 9ec9488

Please sign in to comment.