Skip to content
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

[Contributing] [Standards] Add note about trigger_error() and deprecation messages #5840

Merged
merged 1 commit into from
Dec 28, 2015

Conversation

phansys
Copy link
Contributor

@phansys phansys commented Oct 26, 2015

Q A
Doc fix? no
New docs? no
Applies to 2.3+
Fixed tickets

Add note and example on how to trigger proper deprecation messages.
Related to #5525.

@xabbuh
Copy link
Member

xabbuh commented Oct 26, 2015

Thanks for proposing this change Javier. However, we already have an example in http://symfony.com/doc/current/contributing/code/conventions.html#deprecations. Isn't that enough?

@phansys
Copy link
Contributor Author

phansys commented Oct 26, 2015

Thank you for the feedback @xabbuh. That example is what I've referenced before.
Indeed I think this PR aims to use an standardized syntax for messages inside trigger_error() calls (the same which is currently used for exception messages), regardless they are for deprecation notices or not.

@xabbuh
Copy link
Member

xabbuh commented Nov 1, 2015

I think you should then also add a link to the other section.

@phansys
Copy link
Contributor Author

phansys commented Nov 19, 2015

@xabbuh, I don't know how to create a link to another doc's anchor. Moreover, I can't find anything documented at Adding Links section.

Could you please give me some clue?
Thanks in advance.

@xabbuh
Copy link
Member

xabbuh commented Dec 10, 2015

Sorry for not replying earlier. I completely missed your question. You can link to that section by using the sections label with the refrole like this, for example:

Read more at :ref:`contributing-code-conventions-deprecations`.

@phansys
Copy link
Contributor Author

phansys commented Dec 18, 2015

Thank you @xabbuh. I've updated the PR with your feedback.

@@ -1,2 +1,3 @@
/_build
*.pyc
/nbproject/private/
Copy link
Member

Choose a reason for hiding this comment

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

this should be reverted

…cation messages

| Q             | A
| ------------- | ---
| Doc fix?      | no
| New docs?     | no
| Applies to    | 2.3+
| Fixed tickets |

Add note and example on how to trigger proper deprecation messages.
@phansys
Copy link
Contributor Author

phansys commented Dec 22, 2015

@xabbuh, comments addressed.

* Exception and error message strings should be concatenated using :phpfunction:`sprintf`.

* Calls to :phpfunction:`trigger_error` with type ``E_USER_DEPRECATED`` should be
switched to opt-in via ``@`` operator.
Copy link
Member

Choose a reason for hiding this comment

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

Just FYI, this line break will not be visible.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure @xabbuh, it's just my soft limit. Thanks.

@xabbuh
Copy link
Member

xabbuh commented Dec 23, 2015

👍

*/
public function someDeprecatedMethod()
{
@trigger_error(sprintf('The %s() method is deprecated since version 2.8 and will be removed in 3.0. Use Acme\Baz::someMethod() instead.', __METHOD__), E_USER_DEPRECATED);
Copy link
Member

Choose a reason for hiding this comment

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

Afaik, sprintf isn't used for deprecations in the code, is it?

Copy link
Member

Choose a reason for hiding this comment

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

It's mixed. Sometimes we use it, sometimes we don't.

@symfony/deciders What do you think? Should we advise to use sprintf()?

Copy link
Member

Choose a reason for hiding this comment

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

👍 to use sprintf, it is coherent with our recommandation for exception messages.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It would be nice to normalize all the calls in some point.

@weaverryan
Copy link
Member

This looks good to me, and it's a nice addition. Thanks Javier!

@weaverryan weaverryan merged commit 4c2f1fb into symfony:2.3 Dec 28, 2015
weaverryan added a commit that referenced this pull request Dec 28, 2015
…)` and deprecation messages (phansys)

This PR was merged into the 2.3 branch.

Discussion
----------

[Contributing] [Standards] Add note about `trigger_error()` and deprecation messages

| Q             | A
| ------------- | ---
| Doc fix?      | no
| New docs?     | no
| Applies to    | 2.3+
| Fixed tickets |

Add note and example on how to trigger proper deprecation messages.
Related to #5525.

Commits
-------

4c2f1fb [Contributing] [Standards] Add note about `trigger_error()` and deprecation messages
@phansys
Copy link
Contributor Author

phansys commented Dec 28, 2015

Thank you too Ryan!

@phansys phansys deleted the cs_deprecations branch December 28, 2015 20:18
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.

5 participants