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

Refactor code to never do casts #10

Merged
merged 5 commits into from
May 29, 2024
Merged

Refactor code to never do casts #10

merged 5 commits into from
May 29, 2024

Conversation

SilasKenneth
Copy link
Member

Given the code

if ($parseNode->getBooleanValue() !== null) {
    $result->setBoolean($parseNode->getBooleanValue());
} else if ($parseNode->getFloatValue() !== null) {
    $result->setDouble($parseNode->getFloatValue());
} else if ($parseNode->getIntegerValue() !== null) {
    $result->setInteger($parseNode->getIntegerValue());
} else if ($parseNode->getStringValue() !== null) {
    $result->setString($parseNode->getStringValue());
}

With the current ParseNode implementation, the code will always never go to other branches of the if (unless getBooleanValue() returns null) since anything can be cast to boolean making the first branch of the if always true.

This work is part of
microsoft/kiota#2827

@SilasKenneth SilasKenneth self-assigned this May 28, 2024
@SilasKenneth SilasKenneth requested a review from a team as a code owner May 28, 2024 13:31
@SilasKenneth SilasKenneth changed the base branch from main to dev May 28, 2024 13:31
src/FormParseNodeFactory.php Outdated Show resolved Hide resolved
CODE_OF_CONDUCT.md Outdated Show resolved Hide resolved
andrueastman
andrueastman previously approved these changes May 29, 2024
@SilasKenneth SilasKenneth dismissed andrueastman’s stale review May 29, 2024 08:35

The merge-base changed after approval.

@SilasKenneth SilasKenneth requested a review from andrueastman May 29, 2024 08:37
Copy link

@SilasKenneth SilasKenneth merged commit caa82a4 into dev May 29, 2024
8 checks passed
@SilasKenneth SilasKenneth deleted the fix/parsenode branch May 29, 2024 09:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants