Skip to content

[Serializer] error handling inconsistencies fixed in the serializer decoders #9586

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

Closed
wants to merge 14 commits into from
Closed

Conversation

rodrigodiez
Copy link

Q A
Bug fix? no
New feature? no
BC breaks? no
Deprecations? yes
Tests pass? yes
Fixed tickets #9393
License MIT
Doc PR none

if (!function_exists('json_last_error_msg')) {
switch (json_last_error()) {
default:
$message = 'Unknown error';
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of using variable, you can use return:

if (!function_exists('json_last_error_msg')) {
    switch (json_last_error()) {
        default:
            return 'Unknown error';
    }
}

return json_last_error_msg();

Copy link
Author

Choose a reason for hiding this comment

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

updated

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, default should probably be the last case.

Copy link
Author

Choose a reason for hiding this comment

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

updated

switch (json_last_error()) {
default:
return 'Unknown error';
break;
Copy link
Contributor

Choose a reason for hiding this comment

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

As you call return, the break is redundant here.

Copy link
Author

Choose a reason for hiding this comment

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

updated

@@ -26,6 +26,8 @@
* @param array $context options that normalizers/encoders have access to.
*
* @return scalar
*
* @throws UnexpectedValueException
Copy link
Contributor

Choose a reason for hiding this comment

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

don't you need also here the use statement?

Copy link
Author

Choose a reason for hiding this comment

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

Yep. Sorry guys, first code PR, still learning

Copy link
Contributor

Choose a reason for hiding this comment

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

doing great! ;)

Copy link
Contributor

Choose a reason for hiding this comment

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

I am learning too 👶

@@ -5,6 +5,8 @@ CHANGELOG
-----

* added `$context` support for XMLEncoder.
* [DEPRECATION] JsonEncode and JsonDecoder where modified to throw
Copy link
Contributor

Choose a reason for hiding this comment

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

JsonDecode

*
* @see http://php.net/manual/en/function.json-last-error.php json_last_error
*/
* @deprecated Decoder throws exception if an error is found
Copy link
Member

Choose a reason for hiding this comment

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

The deprecation message should not be the short description of the method. It should go with the @see tag (the first line of the phpdoc is special).

and you should remove the extra indentation space you added.

Copy link
Author

Choose a reason for hiding this comment

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

You are right, updated all

@rodrigodiez
Copy link
Author

Seems ok to you guys?

@rodrigodiez
Copy link
Author

Ping

@fabpot
Copy link
Member

fabpot commented Dec 28, 2013

Closing this one in favor of #9876 as you seem to have removed your Symfony fork.

@fabpot fabpot closed this Dec 28, 2013
fabpot added a commit that referenced this pull request Dec 28, 2013
…e serializer decoders (fabpot)

This PR was merged into the 2.5-dev branch.

Discussion
----------

[Serializer] error handling inconsistencies fixed in the serializer decoders

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | yes
| Tests pass?   | yes
| Fixed tickets | #9393
| License       | MIT
| Doc PR        | none

see #9586 for the original PR

Commits
-------

a1ab939 [Serializer] fixed CS
6d9f0be Json encoder classes now throws UnexpectedValueException as XML classes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants