-
-
Notifications
You must be signed in to change notification settings - Fork 112
Support mixed for getContent method
#820
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
base: main
Are you sure you want to change the base?
Conversation
mixed for getContent methodmixed for getContent method
3206ead to
6606004
Compare
| private PlatformInterface $platform, | ||
| private string $model, | ||
| private LoggerInterface $logger = new NullLogger(), | ||
| private readonly PlatformInterface $platform, |
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.
PHPStan complained about the readonly class btw. I guess this is a new rule?
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.
yes, it is, see symfony/symfony#62168 (comment)
| public function getId(): mixed; | ||
|
|
||
| public function getContent(): string; | ||
| public function getContent(): mixed; |
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.
Maybe string|object is a good alternative if we want to be a bit stricter? Because the platform normalizers also mostly assume that you're passing either strings or data classes.
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.
If possible I would vote to use string|object instead of mixed, WDYT @chr-hertel ?
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.
Yes, i would agree, currently the invoke also is explicit on the $input witharray|string|object so it would be more consistent to be explicit here as well => string|object
6606004 to
2287f60
Compare
As the Vectorizer currently makes assumptions about having to pass string data to `PlatformInterface::invoke`, when that method can actually take about any sort of input. `Platform` implementations decide what data types they can handle through their normalizers. Therefore, it should be up to `platform` to handle types and not up to `store` to decide that it should only pass strings.
2287f60 to
d3c8093
Compare
chr-hertel
left a comment
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.
Sorry for he late response, let's go with string|object here - or do we need array as well?
As the Vectorizer currently makes assumptions about having to pass string data to
PlatformInterface::invoke, when that method can actually take about any sort of input.Platformimplementations decide what data types they can handle through their normalizers. Therefore, it should be up toplatformto handle types and not up tostoreto decide that it should only pass strings.