[Form] Prevent trigger of E_USER_DEPRECATED for new API
[Form] Fix deprecated call method
merged branch francoispluchino/form-fix-deprecated-method (PR #6455)

This PR was merged into the master branch.

Commits
-------

16a196a [Form] Fix deprecated call method

Discussion
----------

[Form] Fix deprecated call method

Bug fix: yes
Feature addition: no
Backwards compatibility break: no
Symfony2 tests pass: -
Fixes the following tickets: -
Todo: -
License of the code: MIT
Documentation PR: -

---------------------------------------------------------------------------

by stof at 2012-12-21T13:21:50Z

This is wrong as the typehint of the constructor is still typehinting the old interface, and so this method is not available.

But the typehint should be changed to use the new interface anyway

---------------------------------------------------------------------------

by francoispluchino at 2012-12-26T09:11:49Z

@fabpot It's OK for you?
(The failure of the Travis test is caused  by the DateTime Form test only in PHP 5.3.3)

---------------------------------------------------------------------------

by bschussek at 2012-12-28T15:00:51Z

Can you please squash the commits?

---------------------------------------------------------------------------

by francoispluchino at 2012-12-28T15:57:47Z

@bschussek OK, it's done.
merged branch drak/bc (PR #6422)

This PR was merged into the master branch.

Commits
-------

7533deb [Form] Prevent trigger of E_USER_DEPRECATED for new API

Discussion
----------

[Form] Prevent trigger of E_USER_DEPRECATED for new API

Bug fix: yes
Feature addition: no
Backwards compatibility break: no
Symfony2 tests pass: yes
Fixes the following tickets:
Todo: -
License of the code: MIT

---------------------------------------------------------------------------

by stof at 2012-12-19T13:54:33Z

This is wrong as FormEvent extends DataEvent and so is also an instance.

Thus, DataEvent should never be constructed anymore (Sf2 does not instantiate it asnd there is no reason to dispatch it elsewhere). The BC is for typehints, and so the useful E_USER_DEPRECATED would be when DataEvent is used as typehint (which is not possible to detect AFAIK)

---------------------------------------------------------------------------

by drak at 2012-12-19T14:07:33Z

So in that case I should check specifically for two class names. Remember the intention here is to NOT trigger an error when the NEW class `FormEvent` is used. I'll update the PR.

---------------------------------------------------------------------------

by Tobion at 2012-12-19T14:25:42Z

I like the solution with an overridden constructor more because using the new stuff will not have the performance penalty of calling `get_class` at all.

---------------------------------------------------------------------------

by stof at 2012-12-19T14:52:47Z

@drak and why not simply ``if (!$this instanceof FormEvent)`` ?

---------------------------------------------------------------------------

by drak at 2012-12-19T15:58:28Z

@stof - if that's ok - I was just assuming other classes might have inherited.
@Tobion - the problem is the private name property we have to call parent which will ultimately call the deprecated constructor.

---------------------------------------------------------------------------

by drak at 2012-12-19T15:59:25Z

How about this?

---------------------------------------------------------------------------

by stof at 2012-12-19T16:51:26Z

@drak if your class inherit from DataEvent instead of FormEvent, it is logical to get a deprecation warning

---------------------------------------------------------------------------

by stof at 2012-12-19T16:52:50Z

@drak I think this allows removing some special error catching in a few places in Form tests (and also in the Form class if it was added)

---------------------------------------------------------------------------

by drak at 2012-12-19T17:33:51Z

@stof - yes, the whole idea is, if you inherit from FormEvent, no warning. anything else, gives warning - that's what we want right?

PR squashed and ready from my side.

---------------------------------------------------------------------------

by drak at 2012-12-20T14:00:13Z

ping @fabpot

---------------------------------------------------------------------------

by bschussek at 2012-12-28T15:19:40Z

:+1: