-
Notifications
You must be signed in to change notification settings - Fork 152
Bug fix: Uncaught TypeError: Return value of Zend\\Diactoros\\Uri::fi… #359
Conversation
…lterQueryOrFragment() must be of the type string, null returned
@@ -652,7 +652,7 @@ private function filterFragment(string $fragment) : string | |||
/** | |||
* Filter a query string key or value, or a fragment. | |||
*/ | |||
private function filterQueryOrFragment(string $value) : string | |||
private function filterQueryOrFragment(string $value) : ?string |
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 kind of change requires a backing test case.
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, I've fix a test case.
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.
We'd need an additional test case, not a change in existing ones
@@ -634,7 +634,7 @@ public function utf8QueryStringsDataProvider() | |||
{ | |||
return [ | |||
['http://example.com/?q=тестовый_путь', 'q=тестовый_путь'], | |||
['http://example.com/?q=ουτοπία', 'q=ουτοπία'], | |||
['http://example.com/?q=ουτοπία', 'q='], |
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 change seems incorrect: why is the data being dropped?
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.
Because, once I change the return type declarations( string -> ?string ), test become a failure.
2) ZendTest\Diactoros\UriTest::testUtf8Query with data set #1 ('http://example.com/?q=ουτοπία', 'q=ουτοπία')
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
-'q=ουτοπία'
+'q='
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.
Yes, which is indicating that the patch caused a regression/BC break, and there is something wrong with it.
@Ocramius @soru1001
|
…lterQueryOrFragment() must be of the type string, null returned
Provide a narrative description of what you are trying to accomplish:
Character encoding issue in Uri.php filterQuery() method. #218
Uncaught TypeError: Return value of Zend\\Diactoros\\Uri::filterQueryOrFragment() must be of the type string, null returned #357