Skip to content

Commit f7ed3a1

Browse files
committed
array length in variable in for loops
1 parent 09aa5b6 commit f7ed3a1

3 files changed

Lines changed: 6 additions & 3 deletions

File tree

src/Service/Builder/AssetListBuilder.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ public function buildByList(array $options): \Generator
3333
$list = $this->getList($options);
3434

3535
$idList = $list->loadIdList();
36-
for ($i = 0; $i < count($idList); $i++) {
36+
$length = count($idList);
37+
for ($i = 0; $i < $length; $i++) {
3738
if ($asset = Asset::getById($idList[$i])) {
3839
yield $asset;
3940
}

src/Service/Builder/DocumentListBuilder.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ public function buildByList(array $options): \Generator
3333
$list = $this->getList($options);
3434

3535
$idList = $list->loadIdList();
36-
for ($i = 0; $i < count($idList); $i++) {
36+
$length = count($idList);
37+
for ($i = 0; $i < $length; $i++) {
3738
if ($doc = Document::getById($idList[$i])) {
3839
yield $doc;
3940
}

src/Service/Builder/ObjectListBuilder.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ public function buildByList(array $options): \Generator
3333
$list = $this->getList($options);
3434

3535
$idList = $list->loadIdList();
36-
for ($i = 0; $i < count($idList); $i++) {
36+
$length = count($idList);
37+
for ($i = 0; $i < $length; $i++) {
3738
if ($object = DataObject::getById($idList[$i])) {
3839
yield $object;
3940
}

0 commit comments

Comments
 (0)