Skip to content

Make AbstractAnnotation::$_context non-nullable#2008

Merged
DerManoMann merged 2 commits into
zircote:masterfrom
krissss:fix/2007-non-nullable-context
Apr 29, 2026
Merged

Make AbstractAnnotation::$_context non-nullable#2008
DerManoMann merged 2 commits into
zircote:masterfrom
krissss:fix/2007-non-nullable-context

Conversation

@krissss

@krissss krissss commented Apr 29, 2026

Copy link
Copy Markdown
Contributor

Closes #2007

Summary

  • Change AbstractAnnotation::$_context type from ?Context to Context
  • The constructor guarantees a non-null Context across all three initialization branches
  • The nullable type was a leftover from the pre-native-type PHPDoc @var Context|null, converted in Code cleanup #1947

Test plan

  • Full test suite passes (1037 tests)
  • CI matrix

krissss added 2 commits April 29, 2026 13:58
The constructor guarantees `$_context` is always initialized to a
non-null `Context` instance across all three branches. The nullable
type was a leftover from the pre-native-type PHPDoc `@var Context|null`.
PHPStan correctly flags `!$annotation->_context` as always false now
that `$_context` is typed as non-nullable `Context`.
@DerManoMann DerManoMann merged commit ede7ae7 into zircote:master Apr 29, 2026
17 checks passed
@DerManoMann

Copy link
Copy Markdown
Collaborator

Thanks @krissss

@github-actions

Copy link
Copy Markdown
Contributor

Created backport PR for 5.x:

Please cherry-pick the changes locally and resolve any conflicts.

git fetch origin backport-2008-to-5.x
git worktree add --checkout .worktree/backport-2008-to-5.x backport-2008-to-5.x
cd .worktree/backport-2008-to-5.x
git reset --hard HEAD^
git cherry-pick -x ede7ae7d989edb272f73172d5c33e1476b8dba26

@krissss krissss deleted the fix/2007-non-nullable-context branch April 29, 2026 07:53
DerManoMann added a commit that referenced this pull request Apr 29, 2026
…able (#2009)

---------

Co-authored-by: kriss <462679766@qq.com>
Co-authored-by: DerManoMann <mano@radebatz.net>
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.

AbstractAnnotation::$_context is typed as nullable but can never be null

2 participants