Skip to content

Commit 821346d

Browse files
add phpstan assertions to Collection isEmpty and isNotEmpty (#51998)
* add @phpstan-assert-if-true|false for Collection isEmpty/isNotEmpty * fix code style
1 parent 4529498 commit 821346d

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

src/Illuminate/Collections/Collection.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -663,6 +663,10 @@ public function intersectByKeys($items)
663663
/**
664664
* Determine if the collection is empty or not.
665665
*
666+
* @phpstan-assert-if-true null $this->first()
667+
*
668+
* @phpstan-assert-if-false !null $this->first()
669+
*
666670
* @return bool
667671
*/
668672
public function isEmpty()

src/Illuminate/Collections/Traits/EnumeratesValues.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,10 @@ public function ensure($type)
367367
/**
368368
* Determine if the collection is not empty.
369369
*
370+
* @phpstan-assert-if-true !null $this->first()
371+
*
372+
* @phpstan-assert-if-false null $this->first()
373+
*
370374
* @return bool
371375
*/
372376
public function isNotEmpty()

0 commit comments

Comments
 (0)