8000 [Contracts] Don't remove object type declaration from PSR interface by derrabus · Pull Request #33786 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Contracts] Don't remove object type declaration from PSR interface #33786

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

Conversation

derrabus
Copy link
Member
@derrabus derrabus commented Oct 1, 2019
Q A
Branch? 4.4
Bug fix? no
New feature? no
Deprecations? no
Tickets #32179, prepares #33497
License MIT
Doc PR N/A

In the contracts package, when extending the PSR EventDispatcherInterface, we are removing the object parameter type declaration from the dispatch() method. This is how the interface looks like upstream:

https://github.com/php-fig/event-dispatcher/blob/1.0.0/src/EventDispatcherInterface.php#L20

I don't see a reason to do that. Keeping the declaration would allow implementers to keep the object type declaration when implementing our contracts interface together with the PSR one.

@stof
Copy link
Member
stof commented Oct 1, 2019

this is broken. The object typehint requires PHP 7.2+, so we cannot make this change in SF 4.4 which supports PHP 7.1.

@derrabus
Copy link
Member Author
derrabus commented Oct 1, 2019

The object typehint requires PHP 7.2+

The code branch that was changed here is not executed on php 7.1. The PSR interface itself (which is extended here) requires php 7.2.

@stof
Copy link
Member
stof commented Oct 1, 2019

but this means that our own interface now has a different signature depending on whether the PSR interface is installed, which would be very confusing (and we cannot do it in both branches because of the PHP version).

@derrabus
Copy link
Member Author
derrabus commented Oct 1, 2019

but this means that our own interface now has a different signature depending on whether the PSR interface is installed

Correct. An implementation that supports both branches would remove object, like the EventDispatcher component's EventDispatcher already does.

Note: we already remove the upstream object type declaration from the PSR interface. All I'm doing here is changing the layer where we do it. This would allow us to deliver a small part of #33497 with 5.0 already.

@stof
Copy link
Member
stof commented Oct 1, 2019

@derrabus no, you're not only doing that. Currently, our own interface always have the same signature. You are making it an interface with a varying signature.

@derrabus
Copy link
Member Author
derrabus commented Oct 1, 2019

You are making it an interface with a varying signature.

That is correct.

@nicolas-grekas nicolas-grekas added this to the next milestone Oct 2, 2019
@nicolas-grekas
Copy link
Member

I would not make this in v1.1, but in v2.0 we would add the type to both interfaces, isn't it?

@derrabus
Copy link
Member Author
derrabus commented Oct 2, 2019

I would not make this in v1.1, but in v2.0

Agreed, let's close here. Thanks @stof and @nicolas-grekas.

we would add the type to both interfaces, isn't it?

#33497 currently proposes to merge both interfaces by making the PSR package a mandatory dependency. And yes, I've added the type declaration there.

@derrabus derrabus closed this Oct 2, 2019
@derrabus derrabus deleted the improvement/object-type-on-edi branch October 2, 2019 12:04
@nicolas-grekas nicolas-grekas modified the milestones: next, 4.4 Oct 27, 2019
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
0