Skip to content

Commit

Permalink
add phpstan assertions to Collection isEmpty and isNotEmpty (#51998)
Browse files Browse the repository at this point in the history
* add @phpstan-assert-if-true|false for Collection isEmpty/isNotEmpty

* fix code style
  • Loading branch information
johanrosenson authored Jul 2, 2024
1 parent 4529498 commit 821346d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Illuminate/Collections/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -663,6 +663,10 @@ public function intersectByKeys($items)
/**
* Determine if the collection is empty or not.
*
* @phpstan-assert-if-true null $this->first()
*
* @phpstan-assert-if-false !null $this->first()
*
* @return bool
*/
public function isEmpty()
Expand Down
4 changes: 4 additions & 0 deletions src/Illuminate/Collections/Traits/EnumeratesValues.php
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,10 @@ public function ensure($type)
/**
* Determine if the collection is not empty.
*
* @phpstan-assert-if-true !null $this->first()
*
* @phpstan-assert-if-false null $this->first()
*
* @return bool
*/
public function isNotEmpty()
Expand Down

0 comments on commit 821346d

Please sign in to comment.