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
Enable strict mode, fix type juggling and drop some runtime coercion broken by design #916
Conversation
@@ -108,22 +110,22 @@ public function accept($data, array $type = null, Context $context) | |||
return $visitor->visitNull($data, $type); | |||
|
|||
case 'string': | |||
return $visitor->visitString($data, $type); | |||
return $visitor->visitString((string)$data, $type); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All these changes are potentially BC breaking, but not by this PR, by already existing type hints. This only eliminates runtime type juggling.
$this->assertTrue($context->shouldSerializeNull()); | ||
|
||
$context->setSerializeNull("0"); | ||
$this->assertFalse($context->shouldSerializeNull()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is BC break-ish, incompatible with strict typing by design.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agree with getting rid of it
@@ -203,34 +205,18 @@ public function getPrimitiveTypes() | |||
'type' => 'boolean', | |||
'data' => true, | |||
), | |||
array( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All these are removed, type coerction of this sort is incompatible with strict types by design.
@@ -385,15 +387,6 @@ public function testDeserializingNull() | |||
$this->markTestSkipped('Not supported in XML.'); | |||
} | |||
|
|||
public function testDeserializeWithObjectWithToStringMethod() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Objects with __toString()
are not string
, therefore removed as incompatible with strict types.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, this "feature" can be removed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It has simple user-land workaround: (string) $stringishObject
, but imho that doesn't make much sense anyway. 😀
Checked with #917, works! |
This breaks some type juggling which is incompatible with strict mode by design (like deserializing object with
__toString()
).