Skip to content
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

Document possibly-null member variables #8945

Merged
merged 1 commit into from
Aug 23, 2021

Conversation

greg0ire
Copy link
Member

Many of the variables in AbstractHydrator are not initialized in the
constructor, and should be documented as possibly null because of that.
Introducing accessors that perform null checks allows to to have to do
these null checks when using the accessors.
Making the member variables private would be a backwards-compatibility
break and could be considered for the next major version.

This makes Psalm's and PHPStan's baselines smaller, and should make
implementing new hydrators easier.

This should help with #8919

use ReflectionClass;
use TypeError;

use function array_map;
use function array_merge;
use function assert;
Copy link
Member

Choose a reason for hiding this comment

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

This is never used, is it?

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh right, it's a remnant from a first attempt at fixing this, I'll remove it 👍

Many of the variables in AbstractHydrator are not initialized in the
constructor, and should be documented as possibly null because of that.
Introducing accessors that perform null checks allows to to have to do
these null checks when using the accessors.
Making the member variables private would be a backwards-compatibility
break and could be considered for the next major version.

This makes Psalm's and PHPStan's baselines smaller, and should make
implementing new hydrators easier.
@greg0ire greg0ire force-pushed the document-possible-null-variable branch from 626016a to af4ecba Compare August 22, 2021 20:12
@greg0ire greg0ire merged commit 9350843 into doctrine:2.10.x Aug 23, 2021
@greg0ire greg0ire deleted the document-possible-null-variable branch August 23, 2021 12:22
@greg0ire greg0ire added this to the 2.10.0 milestone Aug 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants