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

Check types #89

Merged
merged 1 commit into from Jan 18, 2023
Merged

Check types #89

merged 1 commit into from Jan 18, 2023

Conversation

garak
Copy link
Contributor

@garak garak commented Jan 16, 2023

Fix #88

Copy link
Contributor

@JellyBellyDev JellyBellyDev left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@garak garak force-pushed the check-types branch 2 times, most recently from 51899a8 to 20214ef Compare January 16, 2023 09:32

private function isNullable(string $property): bool
{
if (PHP_MAJOR_VERSION < 8 || !property_exists($this, $property)) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why do we need to check the PHP version 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.

Because the reflection feature is not available in PHP 7

Copy link
Collaborator

Choose a reason for hiding this comment

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

I see, so PHP 7 users will always have this method return false, which would result in the property not being assigned a null value, leaving it as whatever its default value is.

Would you mind adding a unit test that shows this new logic in action?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So maybe it's better to return true in this case, so for PHP 7 the behaviour will be the same as the old one.
About testing, it should be already covered in the current test suite, the only problem I see is that the actions workflow runs only on PHP 8.0 (while it should run on every supported PHP version)

Copy link
Collaborator

Choose a reason for hiding this comment

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

I agree that keeping the behaviour the same as it was for platforms that don't support the new changes is a good idea

Copy link
Collaborator

Choose a reason for hiding this comment

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

I've added PHP 7.4 to the CI builds here: #90. You may need to rebase to pull in that change.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I just changed the return value, squashed my commits and then rebased. I guess something has gone wrong since I see now two commits in this PR, but I'm confident that the superfluous commit will be ignored when merged

Copy link
Collaborator

@robbieaverill robbieaverill left a comment

Choose a reason for hiding this comment

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

LGTM, thank you

@robbieaverill robbieaverill merged commit 31d67ac into KnpLabs:master Jan 18, 2023
@garak garak deleted the check-types branch January 21, 2023 08:17
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.

Cannot assign null to property Packagist\Api\Result\Package::$type of type string
3 participants