Skip to content

Commit

Permalink
prefer assignment over array_push for 1 element (#53813)
Browse files Browse the repository at this point in the history
  • Loading branch information
browner12 authored Dec 10, 2024
1 parent 5422f99 commit 5bd1ec6
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/Illuminate/Collections/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -995,7 +995,7 @@ public function pop($count = 1)
$collectionCount = $this->count();

foreach (range(1, min($count, $collectionCount)) as $item) {
array_push($results, array_pop($this->items));
$results[] = array_pop($this->items);
}

return new static($results);
Expand Down Expand Up @@ -1246,7 +1246,7 @@ public function shift($count = 1)
$collectionCount = $this->count();

foreach (range(1, min($count, $collectionCount)) as $item) {
array_push($results, array_shift($this->items));
$results[] = array_shift($this->items);
}

return new static($results);
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Mail/Mailable.php
Original file line number Diff line number Diff line change
Expand Up @@ -1163,7 +1163,7 @@ public function hasAttachedData($data, $name, array $options = [])
*/
public function tag($value)
{
array_push($this->tags, $value);
$this->tags[] = $value;

return $this;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Notifications/Messages/MailMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ public function attachData($data, $name, array $options = [])
*/
public function tag($value)
{
array_push($this->tags, $value);
$this->tags[] = $value;

return $this;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Redis/RedisConnectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -709,7 +709,7 @@ public function testItSscansForKeys()

foreach ($returnedMembers as $member) {
$this->assertContains($member, $members);
array_push($result, $member);
$result[] = $member;
}
} while ($iterator > 0);

Expand Down

0 comments on commit 5bd1ec6

Please sign in to comment.