Skip to content

Commit 79c7985

Browse files
authored
Revert "[8.x] Add doesntHave method on the Collection & Lazy Collection classes (#32873)"
This reverts commit 852fab3.
1 parent 0f3ad14 commit 79c7985

File tree

4 files changed

+0
-72
lines changed

4 files changed

+0
-72
lines changed

src/Illuminate/Collections/Collection.php

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -508,25 +508,6 @@ public function has($key)
508508
return true;
509509
}
510510

511-
/**
512-
* Determine if an item does not exist in the collection by key.
513-
*
514-
* @param mixed $key
515-
* @return bool
516-
*/
517-
public function doesntHave($key)
518-
{
519-
$keys = is_array($key) ? $key : func_get_args();
520-
521-
foreach ($keys as $value) {
522-
if (! $this->offsetExists($value)) {
523-
return true;
524-
}
525-
}
526-
527-
return false;
528-
}
529-
530511
/**
531512
* Concatenate values of a given key as a string.
532513
*

src/Illuminate/Collections/Enumerable.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -442,14 +442,6 @@ public function keyBy($keyBy);
442442
*/
443443
public function has($key);
444444

445-
/**
446-
* Determine if an item does not exist in the collection by key.
447-
*
448-
* @param mixed $key
449-
* @return bool
450-
*/
451-
public function doesntHave($key);
452-
453445
/**
454446
* Concatenate values of a given key as a string.
455447
*

src/Illuminate/Collections/LazyCollection.php

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -507,27 +507,6 @@ public function has($key)
507507
return false;
508508
}
509509

510-
/**
511-
* Determine if an item does not exist in the collection by key.
512-
*
513-
* @param mixed $key
514-
* @return bool
515-
*/
516-
public function doesntHave($key)
517-
{
518-
$keys = array_flip(is_array($key) ? $key : func_get_args());
519-
520-
$count = count($keys);
521-
522-
foreach ($this as $key => $value) {
523-
if (array_key_exists($key, $keys) && --$count == 0) {
524-
return false;
525-
}
526-
}
527-
528-
return true;
529-
}
530-
531510
/**
532511
* Concatenate values of a given key as a string.
533512
*

tests/Support/SupportCollectionTest.php

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1678,18 +1678,6 @@ public function testHas($collection)
16781678
$this->assertFalse($data->has(['third', 'first']));
16791679
}
16801680

1681-
/**
1682-
* @dataProvider collectionClassProvider
1683-
*/
1684-
public function testDoesntHave($collection)
1685-
{
1686-
$data = new $collection(['id' => 1, 'first' => 'Hello', 'second' => 'World']);
1687-
$this->assertFalse($data->doesntHave('first'));
1688-
$this->assertTrue($data->doesntHave('third'));
1689-
$this->assertFalse($data->doesntHave(['first', 'second']));
1690-
$this->assertTrue($data->doesntHave(['third', 'first']));
1691-
}
1692-
16931681
/**
16941682
* @dataProvider collectionClassProvider
16951683
*/
@@ -4166,18 +4154,6 @@ public function testHasReturnsValidResults($collection)
41664154
$this->assertFalse($data->has('baz'));
41674155
}
41684156

4169-
/**
4170-
* @dataProvider collectionClassProvider
4171-
*/
4172-
public function testDoesntHaveReturnsValidResults($collection)
4173-
{
4174-
$data = new $collection(['foo' => 'one', 'bar' => 'two', 1 => 'three']);
4175-
$this->assertFalse($data->doesntHave('foo'));
4176-
$this->assertFalse($data->doesntHave('foo', 'bar', 1));
4177-
$this->assertTrue($data->doesntHave('foo', 'bar', 1, 'baz'));
4178-
$this->assertTrue($data->doesntHave('baz'));
4179-
}
4180-
41814157
public function testPutAddsItemToCollection()
41824158
{
41834159
$data = new Collection;

0 commit comments

Comments
 (0)