Assert not null#189
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a missing Assert::notNull() assertion to complement existing Assert::null(), including static-analysis type narrowing and accompanying unit/feature tests to validate success and failure reporting.
Changes:
- Added
Assert::notNull()toplugin/assert/Assert.phpwith Psalm/PHPStan assertions. - Extended core self-test coverage to exercise the new assertion.
- Added plugin-level self/feature tests plus negative stubs to verify failure reason/context behavior.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tests/Testo/Self/AssertTest.php | Exercises the new Assert::notNull() in the existing “simple assertions” smoke test. |
| plugin/assert/tests/Stub/AssertNotNullNegative.php | Adds negative-case stubs used by feature tests. |
| plugin/assert/tests/Self/AssertNotNull.php | Adds self-tests for passing inputs and exception throwing on null. |
| plugin/assert/tests/Feature/AssertNotNullTest.php | Verifies test-runner integration and failure reason/context propagation. |
| plugin/assert/Assert.php | Introduces Assert::notNull() implementation and annotations. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
added 2 commits
May 20, 2026 18:26
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This was referenced May 20, 2026
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What was changed
Added Assert::notNull() method — the complement of the existing Assert::null(). Throws AssertionException when the actual value is null, narrows the type via @psalm-assert !null / @phpstan-assert !null.
Why?
Assert::null() existed but its counterpart was missing, forcing users to work around with Assert::notSame(null, $value) or similar.
Checklist