Skip to content

[12.x] Refactor: improve doc block#58677

Merged
taylorotwell merged 1 commit intolaravel:12.xfrom
alipowerful7:refactor/improve-doc-block
Feb 7, 2026
Merged

[12.x] Refactor: improve doc block#58677
taylorotwell merged 1 commit intolaravel:12.xfrom
alipowerful7:refactor/improve-doc-block

Conversation

@alipowerful7
Copy link
Contributor

add @throws and modify @return
for this line:

        if ($step == 0) {
            throw new InvalidArgumentException('Step value cannot be zero.');
        }

@taylorotwell taylorotwell merged commit f23dda7 into laravel:12.x Feb 7, 2026
72 checks passed
* @param int $to
* @param int $step
* @return static<int, int>
* @return ($step is zero ? never : static<int, int>)
Copy link
Contributor

@shaedrich shaedrich Feb 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is what PHPStan has to say:

Condition "int is zero" in conditional return type is always false.
Method LazyCollection::range() has invalid return type zero.

https://phpstan.org/r/fe45d051-2850-4c2d-a04d-f359f58956f6

These are the supported integer ranges:

  • positive-int
  • negative-int
  • non-positive-int
  • non-negative-int
  • non-zero-int
  • int<0, 100>
  • int<min, 100>
  • int<50, max>

Similar to how strings can be a non-empty-string but not an empty-string, as they can be typed with a single literal: ''

Suggested change
* @return ($step is zero ? never : static<int, int>)
* @return ($step is 0 ? never : static<int, int>)

@alipowerful7 alipowerful7 deleted the refactor/improve-doc-block branch February 7, 2026 17:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

Comments