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
Invalid typehints for nullable properties with union type #72
Comments
Show please your code |
Hi @dg ! Sample code to reproduce: $class = new ClassType('MyClass');
$class
->addProperty('foo')
->setType('int|string|SomeClass')
->setNullable(true);
$printer = new PsrPrinter();
$printer->printClass($class); |
Thanks, @dg ! Anyway, thank you very much! |
I think I'll leave it. So that no one sets setNullable together with setType('...|null') |
dg
added a commit
that referenced
this issue
Jan 19, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Version: 3.5.1
Bug Description
For now for nullable properties this library generates typehint with
?
, but this conflicts with PHP8 Union Types.Generated typehint for union types now looks like
?OneType|OtherType
, which is not valid PHP syntax.Could you fix this for PHP8 please?
Possible Solution
Check PHP version and if it's larger than 8.0 - replace
?
for|null
in typehint.The text was updated successfully, but these errors were encountered: