Closed franmomu closed 3 years ago
Apparently it does not work in php 7.3: https://3v4l.org/glBKO 😞 but I think it could be useful for people using 7.4.
@franmomu I'm not sure we can do something about this.
When migrating from 3.x to 4.x, all the typehint should be updated. For RouteCollection, but also for all the methods were typehint was missing in 3.x ; I see this as a general rule.
But talking about Collection
, I feel weird that we have a RouteCollectionInterface
but we dont have an interface for
https://github.com/sonata-project/SonataAdminBundle/blob/master/src/Admin/FieldDescriptionCollection.php
Shouldn't FieldDescriptionCollection and RouteCollection be in a similar situation (having an interface or not) ?
When migrating from 3.x to 4.x, all the typehint should be updated.
That's the point, if users are able to update their code before upgrade to work with 3.x
, then the upgrade is much easier.
But talking about
Collection
, I feel weird that we have aRouteCollectionInterface
but we dont have an interface for https://github.com/sonata-project/SonataAdminBundle/blob/master/src/Admin/FieldDescriptionCollection.php Shouldn't FieldDescriptionCollection and RouteCollection be in a similar situation (having an interface or not) ?
In this case I was talking about AbstractAdmin::configureRoutes()
method. I think this method is usually overriden to add/remove routes, so if I can update my admins with:
protected function configureRoutes(RouteCollectionInterface $collection): void
{
// ...
}
Then it would work in 3.x
and there is no need to modify when upgrading to 4.0
.
When migrating from 3.x to 4.x, all the typehint should be updated.
That's the point, if users are able to update their code before upgrade to work with
3.x
, then the upgrade is much easier.
It will help php 7.4 users indeed.
Well we could also
AbstractAdmin::configureRoutes()
@method void configureRoutes(RouteCollectioInterface $collection)
4.x
.Apparently it does not work in php 7.3: https://3v4l.org/glBKO but I think it could be useful for people using 7.4.
Sub class cannot narrow down declaration. Only equal or extend. Its OOP
Apparently it does not work in php 7.3: https://3v4l.org/glBKO but I think it could be useful for people using 7.4.
Sub class cannot narrow down declaration. Only equal or extend. Its OOP
😕 It depends on what declaration, when overriding a method, a subclass must return the same type or a more specific one (covariance), but as argument it accepts the same type or a more general one (contravariance) and support for this was fully added in PHP 7.4: https://wiki.php.net/rfc/covariant-returns-and-contravariant-parameters
Feature Request
In order to ease the upgrade to
4.0
I think we should import RouteCollectionInterface into3.x
making it compatible withRouteCollection
, so people can prepare their code before upgrading, otherwise you'll get errors like: