Skip to content

Assert not null#189

Merged
roxblnfk merged 5 commits into
php-testo:1.xfrom
burn1ngbear:feature/assert-not-null
May 20, 2026
Merged

Assert not null#189
roxblnfk merged 5 commits into
php-testo:1.xfrom
burn1ngbear:feature/assert-not-null

Conversation

@burn1ngbear
Copy link
Copy Markdown
Contributor

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

  • Closes #
  • Tested
    • Tested manually
    • Unit tests added (plugin/assert/tests/Self/AssertNotNull.php)
  • Documentation

@burn1ngbear burn1ngbear requested a review from a team as a code owner May 20, 2026 13:27
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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() to plugin/assert/Assert.php with 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.

Comment thread plugin/assert/Assert.php Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Comment thread plugin/assert/Assert.php Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@roxblnfk roxblnfk merged commit 6523c6a into php-testo:1.x May 20, 2026
10 checks passed
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