Skip to content

Commit 8605f8a

Browse files
authored
Revert "EnumerateValues::value() support and return negative values if exists…" (#57572)
This reverts commit d158526.
1 parent 70b2c87 commit 8605f8a

File tree

2 files changed

+1
-25
lines changed

2 files changed

+1
-25
lines changed

src/Illuminate/Collections/Traits/EnumeratesValues.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -340,11 +340,7 @@ public function firstWhere($key, $operator = null, $value = null)
340340
*/
341341
public function value($key, $default = null)
342342
{
343-
$value = $this->first();
344-
345-
if ($value && Arr::exists($value, $key)) {
346-
return data_get($value, $key);
347-
} elseif ($value = $this->firstWhere($key)) {
343+
if ($value = $this->firstWhere($key)) {
348344
return data_get($value, $key, $default);
349345
}
350346

tests/Support/SupportCollectionTest.php

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1182,26 +1182,6 @@ public function testValueUsingEnum($collection)
11821182
$this->assertEquals(StaffEnum::Joe, $c->where('id', 2)->value('name'));
11831183
}
11841184

1185-
#[DataProvider('collectionClassProvider')]
1186-
public function testValueWithNegativeValue($collection)
1187-
{
1188-
$c = new $collection([['id' => 1, 'balance' => 0], ['id' => 2, 'balance' => 200]]);
1189-
1190-
$this->assertEquals(0, $c->value('balance'));
1191-
1192-
$c = new $collection([['id' => 1, 'balance' => ''], ['id' => 2, 'balance' => 200]]);
1193-
1194-
$this->assertEquals('', $c->value('balance'));
1195-
1196-
$c = new $collection([['id' => 1, 'balance' => null], ['id' => 2, 'balance' => 200]]);
1197-
1198-
$this->assertEquals(null, $c->value('balance'));
1199-
1200-
$c = new $collection([['id' => 1], ['id' => 2, 'balance' => 200]]);
1201-
1202-
$this->assertEquals(200, $c->value('balance'));
1203-
}
1204-
12051185
#[DataProvider('collectionClassProvider')]
12061186
public function testBetween($collection)
12071187
{

0 commit comments

Comments
 (0)