-
-
Notifications
You must be signed in to change notification settings - Fork 140
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
The parameter and property types are not correctly returned when they are nullable #153
Comments
For me is ok, if you set null with setNullable, you should check with:
|
Why do I need to check |
Why do you ask for the type if you already know that the answer is string? In large programs you won't know where the type is set or what type it is. Example: I generate code with ->setType[$entity->getPhpType()]. |
It's just an example to reproduce the bug
So what is your point then?. Your example is clearly the reason |
I am a user, I do not participate in the development, I think it is correct to check with isNullable, otherwise you have to parse the response to know if it is nullable or string |
If you take a look at this Nette\Utils\Type::fromString public static function fromString(string $type): self
{
// ...
if ($type[0] === '?') {
return new self([substr($type, 1), 'null']);
}
// ...
} It is clear that the Anyway, let the repository owner decide on further actions regarding this report. |
This behavior is for historical reasons, because functions were created at a time when union types like |
+1 for this @dg it can be included in a major version maybe? |
@sovetski yes |
Version: 4.1.3
Bug Description
getType
does not return correct typeSteps To Reproduce
The class was generated correctly
Expected Behavior
$param->getType()
should return?string
ornull|string
instead ofstring
The text was updated successfully, but these errors were encountered: