Fix issues detected with static analyzer. #188
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Running vimeo/psalm on the library yields lots of errors. This PR fixes all the errors. In general, most of them are trivial to fix (type confusions, default values that don't make sense, etc).
The most difficult cases to deal with are those where we need to change the signature of a public method, namely
XMLSecEnc::locateKeyInfo()
andXMLSecEnc::staticLocateKeyInfo()
. However, in both cases it doesn't really make sense to have the base key as an optional parameter (best-case-scenario, the method returnsnull
; worst-case-scenario, the code breaks because we try to call theloadKey()
method on a null variable).Another slightly more complicated case is
XMLSecurityDSig::getXPathObj()
. Originally, it was returningnull
whenxPathCtx
andsigNode
were bothnull
. That's only possible if someone is messing up withsigNode
manually (since the property is public), setting it tonull
, which wouldn't make any sense (you cannot expect the library to give you an XPath context that you can use to search a node, if you have actually cleared that node and there's nowhere you can search in). The proposed change assumesgetXPathObj()
will always return a validXPath
object, or raise an exception if none can be created (as per the case described above).