-
Notifications
You must be signed in to change notification settings - Fork 153
Add isNegativeInteger and notNegativeInteger #301
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
shadowhand
merged 7 commits into
webmozarts:master
from
Dropelikeit:feature/add-non-negative-integer-and-negative-integer-asserts
Dec 1, 2025
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
e3615f5
Addition of two new assert functions for better validation of differe…
Dropelikeit 79cb09f
Merge branch 'master' into feature/add-non-negative-integer-and-negat…
Dropelikeit a126a5e
Refactor: Update array syntax in tests and improve return type annota…
Dropelikeit f023a68
Refactor: Add strict typing and replace parameter types with `mixed` …
Dropelikeit fca4d83
Refactor: Delegate integer type check to `Assert::integer` in positiv…
Dropelikeit ac818f0
Refactor: Rename `nonNegativeInteger` to `notNegativeInteger` across …
Dropelikeit 60f7b21
Fix: Correct `CHANGELOG.md` entry for `notNegativeInteger` and `negat…
Dropelikeit File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Webmozart\Assert\Tests\StaticAnalysis; | ||
|
|
||
| use Webmozart\Assert\Assert; | ||
|
|
||
| /** | ||
| * @psalm-pure | ||
| * | ||
| * @param mixed $value | ||
| * | ||
| * @psalm-return negative-int | ||
| */ | ||
| function negativeInteger(mixed $value): int | ||
| { | ||
| Assert::negativeInteger($value); | ||
|
|
||
| return $value; | ||
| } | ||
|
|
||
| /** | ||
| * @psalm-pure | ||
| * | ||
| * @param mixed $value | ||
| * | ||
| * @psalm-return negative-int|null | ||
| */ | ||
| function nullOrNegativeInteger(mixed $value): ?int | ||
| { | ||
| Assert::nullOrNegativeInteger($value); | ||
|
|
||
| return $value; | ||
| } | ||
|
|
||
| /** | ||
| * @psalm-pure | ||
| * | ||
| * @param mixed $value | ||
| * | ||
| * @return iterable<negative-int> | ||
| */ | ||
| function allNegativeInteger(mixed $value): iterable | ||
| { | ||
| Assert::allNegativeInteger($value); | ||
|
|
||
| return $value; | ||
| } | ||
|
|
||
| /** | ||
| * @psalm-pure | ||
| * | ||
| * @param mixed $value | ||
| * | ||
| * @return iterable<negative-int|null> | ||
| */ | ||
| function allNullOrNegativeInteger(mixed $value): iterable | ||
| { | ||
| Assert::allNullOrNegativeInteger($value); | ||
|
|
||
| return $value; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Webmozart\Assert\Tests\StaticAnalysis; | ||
|
|
||
| use Webmozart\Assert\Assert; | ||
|
|
||
| /** | ||
| * @psalm-pure | ||
| * | ||
| * @param mixed $value | ||
| * | ||
| * @psalm-return non-negative-int | ||
| */ | ||
| function nonNegativeInteger(mixed $value): int | ||
| { | ||
| Assert::notNegativeInteger($value); | ||
|
|
||
| $value *= -1; | ||
|
|
||
| return $value; | ||
| } | ||
|
|
||
| /** | ||
| * @psalm-pure | ||
| * | ||
| * @param mixed $value | ||
| * | ||
| * @psalm-return non-negative-int|null | ||
| */ | ||
| function nullOrNonNegativeInteger(mixed $value): ?int | ||
| { | ||
| Assert::nullOrNotNegativeInteger($value); | ||
|
|
||
| return $value; | ||
| } | ||
|
|
||
| /** | ||
| * @psalm-pure | ||
| * | ||
| * @param mixed $value | ||
| * | ||
| * @return iterable<non-negative-int> | ||
| */ | ||
| function allNonNegativeInteger(mixed $value): iterable | ||
| { | ||
| Assert::allNotNegativeInteger($value); | ||
|
|
||
| return $value; | ||
| } | ||
|
|
||
| /** | ||
| * @psalm-pure | ||
| * | ||
| * @param mixed $value | ||
| * | ||
| * @return iterable<non-negative-int|null> | ||
| */ | ||
| function allNullOrNonNegativeInteger(mixed $value): iterable | ||
| { | ||
| Assert::allNullOrPositiveInteger($value); | ||
|
|
||
| return $value; | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.