Conversation
8051878 to
b4945f7
Compare
|
Currently, the work in this PR is scoped at Based on this PoC I think we should make some decisions, by instance:
I'd like to use this PR as base to find the better solution for each case. Thank you in advance. |
|
Just for the record, I'm leaving here the test results with the current state: |
|
Is it a good idea to add this to the 4.0 major ? Adding param/return typehint will add a lot of breaking changes. Btw: Since there was no |
|
Since we require php 7.2, adding param type declarations is no longer a BC-break from a signature compatibility point of view, it's only a BC break for people not strictly obeying the phpdoc when calling our APIs, or in cases where our phpdoc is not accurate. So it's not a big BC-break. I would add a least the param type declarations (could even be done on 3.x if we were super confident in our phpdoc, not sure we are.) |
I think we can close the API as much as possible for 4.x release.
I guess the missing declarations could be updated later, even in other PRs.
IMO, we can't because in the majority of these cases, the added declarations are part of the public API, so the projects using these classes will break if these declarations are not updated in these projects too. |
|
Could you please rebase your PR and fix merge conflicts? |
|
Other example. Should we really keep this behavior? $this->listMapper->add('fooNameLabelFalse', null, ['label' => false]);
$this->listMapper->get('fooNameLabelFalse')->getOption('label'); // falseIMO, if possible, is preferable to return values like WDYT? |
In your exemple, the value label is set to |
|
The example is based on this test: SonataAdminBundle/tests/Datagrid/ListMapperTest.php Lines 177 to 189 in dcaef0b I agree that an option which is not restricted by an options resolver can hold anything, but in this case, the value of this option is being used as return type of a method ( SonataAdminBundle/src/Datagrid/ListMapper.php Line 109 in dcaef0b SonataAdminBundle/src/Admin/BaseFieldDescription.php Lines 372 to 375 in dcaef0b SonataAdminBundle/src/Admin/FieldDescriptionInterface.php Lines 239 to 244 in dcaef0b If we can define the return type of public function getLabel(): ?string
{
return null === $this->getOption('label') ? null : (string) $this->getOption('label');
} Otherwise, we must keep the |
IMO we shouldn't modify the logic/code just in order to add return type. If we have to wait for union type, we'll wait.
|
|
That's exactly the point @VincentLanglet. I agree with your proposal of returning |
|
@sonata-project/contributors, I'd like to achieve some consensus on this before performing more changes. |
IMO we should avoid mixed (or union types) as much as possible. Let's have a code that is easy to understand for both people and SA tools. |
That's exactly what I'm trying to avoid here 👍 |
|
Based on this concern (#6005 (comment)), I've updated all the methods intended to return model ids in order to allow only I guess this PR is RTM. |
My concern is that if we merge a half-typed method, or half-typed class, it'll be easy to miss it when we'll release the next major. And then it will be impossible to add the type before the 5.0 version. I agree that this PR is big and not easy to review, it's still possible to make a soft reset and create smaller PR now, file by file. |
Indeed. I'm not suggesting to merge a half-typed method, but try to focus this step in the methods that are already updated. |
VincentLanglet
left a comment
There was a problem hiding this comment.
I think this is the last changes needed if you don't want to touch the methods with $entity arguments of the AbstractAdmin.
VincentLanglet
left a comment
There was a problem hiding this comment.
I found other missing return type.
I promise, next time I'll approve.
IIRC, I didn't touch the extension part by hand. Those changes was applied automatically by Rector. |
I've added some "NEXT_MAJOR" comments addressing these situations.
I think the better option will be to adopt a wider perspective among the other namespaces when all the possible non-controversial narrowing was done. |
VincentLanglet
left a comment
There was a problem hiding this comment.
Sounds perfect. Nice work @phansys
|
Could you please rebase your PR and fix merge conflicts? |
54bcb38 to
7b4a19f
Compare
|
Could you please rebase your PR and fix merge conflicts? |
VincentLanglet
left a comment
There was a problem hiding this comment.
Let's try to merge this ! @sonata-project/contributors
|
Thanks a lot @phansys ! |
Subject
Narrow API.
Following Rector sets are used:
I am targeting this branch, because these changes belong to the next major.
See #5613 (comment).
Changelog
To do