Skip to content

Added deprecated error to init() #12628

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 3 commits into from
Closed

Added deprecated error to init() #12628

wants to merge 3 commits into from

Conversation

dkvk
Copy link

@dkvk dkvk commented Nov 29, 2014

Q A
Fixed tickets [#12622]
License MIT

@@ -93,6 +93,7 @@ public function __construct($environment, $debug)
*/
public function init()
{
trigger_error('This method is going to be removed in 3.0', 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.

Can you be more explicit please? You should take the full original deprecation message, but tell the name of the method ("This" needs context, but there is none for the reader)

@dkvk
Copy link
Author

dkvk commented Nov 30, 2014

Updated error message with same message as in the annotation.

@@ -93,6 +93,7 @@ public function __construct($environment, $debug)
*/
public function init()
{
trigger_error('Deprecated since version 2.3, to be removed in 3.0. Move your logic in the constructor instead.', 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.

Should be "The Kernel::init() method was deprecated in version 2.3 and will be removed in 3.0. ..."

@dkvk
Copy link
Author

dkvk commented Dec 2, 2014

Message has been updated to comply with the format @fabpot point out

@@ -93,6 +93,7 @@ public function __construct($environment, $debug)
*/
public function init()
{
trigger_error('The Kernel::init() method was deprecated in version 2.3 and will be removed in 3.0. Move your logic to the constructor instead.', 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.

That won't work as the init() method is called in the __construct method above, so the warning will always be displayed.

@dkvk
Copy link
Author

dkvk commented Dec 2, 2014

But if we remove the init() from __construct() we will introduce a break?

@stof
Copy link
Member

stof commented Dec 4, 2014

The issue is that we would need to trigger a deprecation notice in case the method is overwritten. Your deprecation notice is triggered only when it is wrong

@nicolas-grekas
Copy link
Member

In the constructor, you need to do some reflection on $this and check if the init method has been overridden.
If yes, you trigger the notice

@nicolas-grekas nicolas-grekas mentioned this pull request Dec 13, 2014
@nicolas-grekas
Copy link
Member

Cherry-picked in #12968, thanks

fabpot added a commit that referenced this pull request Dec 20, 2014
…cmorales)

This PR was merged into the 2.7 branch.

Discussion
----------

Deprecations

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #12625, #12605, #12628, #12622, #12642, #12609, #12651, #12604,  #12607, #12667, #12648
| License       | MIT
| Doc PR        | -

Cherry-picking some pending PRs to make them move forward

Commits
-------

badf8fc [Form] Log deprecation of constants, fixes #12607 #12667
1d58df4 Fix deprecation notice on VirtualFormAwareIterator
e2a19ee Add a deprecation note about VirtualFormAwareIterator
ab4d9b8 Add a deprecation note about CsrfProviderInterface
cb70632 [HttpKernel] fix deprecation notice for Kernel::init()
b5a315d [HttpKernel] Added deprecated error to init()
70012c1 [Hackday] [2.7] Add a deprecation note about TypeTestCase
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.

4 participants