-
Notifications
You must be signed in to change notification settings - Fork 518
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
Add support for not nullable mappings #1117
Comments
What about this? class MediaObject
{
/** @Vich\UploadableField(mapping="media_object", fileNameProperty="filename") */
private ?SymfonyFile $file;
protected string $filename;
// ...
public function __construct() {
$this->file = null;
$this->filename = '';
}
// ...
public function setFilename(?string $filename) {
$this->filename = $filename;
}
// ...
} |
I think this might generate an error, assigning public function setFilename(?string $filename) {
$this->filename = (string) $filename;
} This is something I can currently live with. I added the workaround into my tests and easily can remove them later. But none the less, I think as typed properties and the type system of php advances, we have to update this repository. |
What about making property nullable? |
This would not solve my problem. I see 2 problems:
|
This seems reasonable to me. |
Feature Request
Summary
I am using an entity that acts like a file object. Simple representation here:
This object is only valid as long as the file exists. So if I now want to remove the entity:
I will be greeted with this Exception:
Expected argument of type "string", "null" given at property path "filename".
.The question now is:
The text was updated successfully, but these errors were encountered: