-
Notifications
You must be signed in to change notification settings - Fork 264
PHPLIB-1679 Call DocumentCodec::encode()
only on objects
#1687
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
base: v2.0
Are you sure you want to change the base?
Conversation
DocumentCodec::encode()
only on objects
I should add tests, probably in |
@@ -306,6 +308,10 @@ | |||
// $args[0] was already validated above. Since DocumentCodec::encode will always return a Document | |||
// instance, there is no need to re-validate the returned value here. | |||
if ($codec) { | |||
if (! is_object($args[0])) { |
Check notice
Code scanning / Psalm
MixedArrayAccess Note
@@ -306,6 +308,10 @@ | |||
// $args[0] was already validated above. Since DocumentCodec::encode will always return a Document | |||
// instance, there is no need to re-validate the returned value here. | |||
if ($codec) { | |||
if (! is_object($args[0])) { | |||
throw UnsupportedValueException::invalidEncodableValue($args[0]); |
Check notice
Code scanning / Psalm
MixedArrayAccess Note
@@ -341,6 +347,10 @@ | |||
} | |||
|
|||
if ($codec) { | |||
if (! is_object($args[1])) { |
Check notice
Code scanning / Psalm
MixedArrayAccess Note
@@ -341,6 +347,10 @@ | |||
} | |||
|
|||
if ($codec) { | |||
if (! is_object($args[1])) { | |||
throw UnsupportedValueException::invalidEncodableValue($args[1]); |
Check notice
Code scanning / Psalm
MixedArrayAccess Note
I don't think we should add the error checks here. The template annotation on the I wonder if we should instead document the parameter as |
What I understand is that calling
The Throwing the error before or inside |
Fix PHPLIB-1679
DocumentCodec::encode()
DocumentCodec::encode()
as the typeMongoDB\BSON\Document
is enforced.