Skip to content
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

Property with Union Type “int|null” => Default null value for not-nullable property is invalid #201

Open
CreativeNative opened this issue Jul 11, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@CreativeNative
Copy link

I changed the type declaration from “?int” to Union Type “int|null” and now I get a lot of “Default null value for not-nullable property is invalid” errors, because of “WebimpressCodingStandard.Classes.NoNullValues.Invalid”.

private int|null $id = null;
This produces “Default null value for not-nullable property is invalid” error and when I automatically fix it, it deletes the part “ = null” and breaks my code. The property is nullable and has as default value null. I don't understand why it says it is not-nullable.

private ?int $id = null;
This instead produces no errors and works fine.

PHP version: 8.2

@michalbundyra michalbundyra added the bug Something isn't working label Jul 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants