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

DisableConstructorPatch: make optional constructor parameters nullable explicitly #632

Merged
merged 1 commit into from
Oct 11, 2024

Conversation

W0rma
Copy link
Contributor

@W0rma W0rma commented Oct 3, 2024

This PR tries to fix #625 (comment)

@W0rma W0rma force-pushed the php84-explicit-nullable-types branch from 2e0f1c9 to 07cfbb9 Compare October 4, 2024 04:27
@@ -55,6 +56,16 @@ public function apply(ClassNode $node)
\assert($constructor !== null);
foreach ($constructor->getArguments() as $argument) {
$argument->setDefault(null);
if (\PHP_VERSION_ID < 80400) {
Copy link
Member

Choose a reason for hiding this comment

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

I suggest doing that for all versions instead, to avoid different behavior between PHP versions (making a type explicitly nullable is supported on PHP 7.1+, which covers more than our target versions)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

}

$types = $argument->getTypeNode()->getNonNullTypes();
if ([] == $types || ['mixed'] == $types) {
Copy link
Member

Choose a reason for hiding this comment

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

please use strict comparisons here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

@W0rma W0rma force-pushed the php84-explicit-nullable-types branch from 07cfbb9 to 1442852 Compare October 4, 2024 16:54
Implicitly nullable types are deprecated in PHP 8.4
@W0rma W0rma force-pushed the php84-explicit-nullable-types branch from 1442852 to 731031d Compare October 4, 2024 17:39
@W0rma
Copy link
Contributor Author

W0rma commented Oct 4, 2024

#633 should fix the CI (cs fixer + phpstan)

@Jean85
Copy link
Contributor

Jean85 commented Oct 11, 2024

This should receive the PHP 8.4 label

@stof stof added the PHP8.4 label Oct 11, 2024
@stof stof merged commit f425512 into phpspec:master Oct 11, 2024
10 of 12 checks passed
@W0rma W0rma deleted the php84-explicit-nullable-types branch October 12, 2024 08:52
Jean85 added a commit to facile-it/paraunit that referenced this pull request Oct 30, 2024
Jean85 added a commit to facile-it/paraunit that referenced this pull request Nov 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants