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

Bugfix/#6151 typedoesnotcontainnull on return value from dom import simplexml #7489

Merged
merged 3 commits into from Jan 27, 2022
Merged

Bugfix/#6151 typedoesnotcontainnull on return value from dom import simplexml #7489

merged 3 commits into from Jan 27, 2022

Conversation

KevinVanSonsbeek
Copy link
Contributor

Fixes #6151

@orklah
Copy link
Collaborator

orklah commented Jan 25, 2022

Thanks!

I believe the false was not possible even before PHP 8, Am I mistaken on this?

@KevinVanSonsbeek
Copy link
Contributor Author

I believe the false was not possible even before PHP 8, Am I mistaken on this?

That actually is true yeah. I'll change the callmaps when i get home later today.

Comment on lines +312 to +315
'dom_import_simplexml' => [
'old' => ['DOMElement|null', 'node'=>'SimpleXMLElement'],
'new' => ['DOMElement', 'node'=>'SimpleXMLElement'],
],
Copy link
Collaborator

Choose a reason for hiding this comment

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

Was a null return possible in PHP < 8.0 when using correct parameters? If the only time null is returned is because the parameters are invalid and Psalm correctly catches that we can exclude the null return value (it's basically there because PHP before 8.0 was really lenient on some function calls and returned null instead of throwing an error for incorrect arguments, eg https://3v4l.org/W9kUt).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

From looking at the old source code, it could return null if the supplied nodetype was invalid. (This behavior was changed in php/php-src@8fef83d)

if (nodep && nodeobj && (nodep->type == XML_ELEMENT_NODE || nodep->type == XML_ATTRIBUTE_NODE)) {
	DOM_RET_OBJ((xmlNodePtr) nodep, &ret, (dom_object *)nodeobj);
} else {
	php_error_docref(NULL, E_WARNING, "Invalid Nodetype to import");
	RETURN_NULL();
}

Edit: If i'm reading the old source code correctly atleast. As my C knowledge is limited.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Fine by me then :)

@orklah orklah added the release:fix The PR will be included in 'Fixes' section of the release notes label Jan 27, 2022
@orklah
Copy link
Collaborator

orklah commented Jan 27, 2022

Thanks!

@orklah orklah merged commit f6a8921 into vimeo:4.x Jan 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release:fix The PR will be included in 'Fixes' section of the release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TypeDoesNotContainNull: on return value from dom_import_simplexml()
3 participants