-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
[POC] Add guessTypeForFieldDescription to TypeGuesserInterface #6839
[POC] Add guessTypeForFieldDescription to TypeGuesserInterface #6839
Conversation
The field description should have all the mapping information when is created, so it should be enough for guessing the right type.
GuessType($classOrFieldDescription, $property = null, $modelManager = null) Couldnt this be a way to change from a signature to another with BC ? |
Nope, It is not BC: https://3v4l.org/KZBXZ Method parameter types are contravariant (only allow a more general argument). |
WDYT of GuessFieldDescriptionType ? Or we can keep guessType if we make the Pr directly on master and document the BC break... |
Could you please rebase your PR and fix merge conflicts? |
@VincentLanglet on line 43, Is it wrong - SonataAdminBundle/src/Guesser/TypeGuesserChain.php Lines 35 to 43 in f80fca5
|
If I understand correctly the guessers property is protected so it shouldn't work. |
If we wanna guess type only by one method then we should keep public function guessType($fieldDescriptionOrDeprecaedClass, $deprecatedProperty, ModelManagerInterface $deprecatedModelManager) |
It will still lead to BC break in 4.0. If we want to avoid BC break we have to use a new method like |
What is diffrence beetween?: public function guessType($fieldDescriptionOrDeprecaedClass, $deprecatedProperty, ModelManagerInterface
$deprecatedModelManager)
{
if ($fieldDescriptionOrDeprecaedClass instaneof FieldDescription) {
// call guessTypeForFieldDescription() which will be merge in master or write code diretly here
return $this->guessTypeForFieldDescription($fieldDescriptionOrDeprecaedClass);
} // old code + trigger_errors
}
protected function guessTypeForFieldDescription(FieldDescription $fieldDescription) {} and public function guessType($class, $property, ModelManagerInterface $ModelManager) {}
public function guessTypeForFieldDescription(FieldDescription $fieldDescription) {} |
It's not about our implementation, it's about the developer who implement the interface and the developer who use the method. When we're introducing a deprecation, the developer can update his code in order to fix the deprecation AND avoiding a BC break in 4.0. If I need to use
But in next major, I'll have to change my code to
And I cant do the change when using the 3.x branch. If the new signature was
I could do
in 3.x directly. But as explained by @franmomu this is a BC break. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you have some time to rebase @franmomu ?
And Wdyt of guessFieldDescriptionType
instead ?
Maybe one day we will guess another Type, like a guessExportFieldType
Hey, sorry, I've been busy these days, I think I can continue this weekend.
For #6761 I had something done and created a |
I like this solution. And a field description folder is a nice idea. |
Closing in favor of #6854 |
Subject
For a long description: #6701
Basically, in persistence bundles, to guess the type we have a call to a nonexistent
ModelManagerInterface::getParentMetadataForProperty()
which fetches the mapping for a property, the field description should have all the mapping information when is created, so it should be enough for guessing the right type.I am targeting this branch, because this is BC.
Closes #6701.
Changelog
To be honest I don't like the name, but I think there is no way to reuse
guessType
without breaking BC, any other idea is welcome.