Skip to content

Add types to public and protected properties #51069

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
merged 1 commit into from
Jul 28, 2023

Conversation

nicolas-grekas
Copy link
Member

@nicolas-grekas nicolas-grekas commented Jul 21, 2023

Q A
Branch? 7.0
Bug fix? no
New feature? yes
Deprecations? no
Tickets -
License MIT
Doc PR -

🥵

Allowed by #45360

Follows #51068 and #51067

Copy link
Member

@derrabus derrabus left a comment

Choose a reason for hiding this comment

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

Reviewing this PR is exhausting. I've reviewed up to the HttpFoundation component and will take a break now. 😓

@nicolas-grekas
Copy link
Member Author

PR is ready for review. Needs #51121 to be 🍏

protected mixed $trueEquivalent = true;
protected mixed $falseEquivalent = false;
protected string $pathSeparator = BaseNode::DEFAULT_PATH_SEPARATOR;
protected NodeParentInterface|NodeInterface|null $parent;
Copy link
Member

Choose a reason for hiding this comment

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

The return type of end() is wider. My gut feeling is that they should match.

Copy link
Member Author

Choose a reason for hiding this comment

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

All those classes in the return type of end() implement NodeParentInterface so we could reduce this to only it. I suppose the list is here to hint the IDE for autocompletion. Maybe we should keep only NodeParentInterface as native type and use @return for the rest?

The other strange thing is about the need to add NodeInterface to make this code work:

$node = new ArrayNode($this->name, $this->parent, $this->pathSeparator);
$this->validateConcreteNode($node);
$node->setAddIfNotSet($this->addDefaults);
foreach ($this->children as $child) {
$child->parent = $node;
$node->addChild($child->getNode());
}

end() can't return an ArrayNode because of its return type. Either the return type is wrong, or what?
Up to investigate and fix this on a lower branch?

Copy link
Member

Choose a reason for hiding this comment

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

All those classes in the return type of end() implement NodeParentInterface so we could reduce this to only it. I suppose the list is here to hint the IDE for autocompletion. Maybe we should keep only NodeParentInterface as native type and use @return for the rest?

Would work for me to unblock the PR.

Up to investigate and fix this on a lower branch?

Maybe, but not right away. 🙈

Copy link
Member Author

Choose a reason for hiding this comment

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

use @return for the rest

PR updated

nicolas-grekas added a commit that referenced this pull request Jul 27, 2023
…. (nicolas-grekas)

This PR was merged into the 6.4 branch.

Discussion
----------

More short closures + isset instead of null checks + etc.

| Q             | A
| ------------- | ---
| Branch?       | 6.4
| Bug fix?      | no
| New feature?  | no
| Deprecations? | no
| Tickets       | -
| License       | MIT
| Doc PR        | -

Some of the isset() checks are needed to make #51069 green on high-deps job.

Commits
-------

3df6471 More short closures + isset instead of null checks + etc.
@nicolas-grekas nicolas-grekas force-pushed the typed-props branch 3 times, most recently from e3eabd6 to 39b070c Compare July 27, 2023 07:52
nicolas-grekas added a commit that referenced this pull request Jul 27, 2023
This PR was merged into the 6.4 branch.

Discussion
----------

Ensure all properties have a type

| Q             | A
| ------------- | ---
| Branch?       | 6.4
| Bug fix?      | no
| New feature?  | no
| Deprecations? | no
| Tickets       | -
| License       | MIT
| Doc PR        | -

Before #51069

Commits
-------

25a8615 Ensure all properties have a type
@nicolas-grekas nicolas-grekas force-pushed the typed-props branch 2 times, most recently from 2b8819e to 6c5286f Compare July 27, 2023 11:19
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.

4 participants