-
Notifications
You must be signed in to change notification settings - Fork 529
Fix/nullable templates #4267
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
Fix/nullable templates #4267
Conversation
19e6bbe
to
e20136d
Compare
This fixes issues like #13048. Currently, T of (A|null) subtracted by A is T of mixed
e20136d
to
ed9d037
Compare
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.
- This fixes a bunch of other issues, please check https://github.com/phpstan/phpstan-src/actions/runs/17309059596 and add regression tests for them too.
- This has to be modified
phpstan-src/src/Rules/Generics/TemplateTypeCheck.php
Lines 119 to 142 in 07a29ab
if ( $boundTypeClass !== MixedType::class && $boundTypeClass !== ConstantArrayType::class && $boundTypeClass !== ArrayType::class && $boundTypeClass !== ConstantStringType::class && $boundTypeClass !== StringType::class && $boundTypeClass !== ConstantIntegerType::class && $boundTypeClass !== IntegerType::class && $boundTypeClass !== FloatType::class && $boundTypeClass !== BooleanType::class && $boundTypeClass !== ObjectWithoutClassType::class && $boundTypeClass !== ObjectType::class && $boundTypeClass !== ObjectShapeType::class && $boundTypeClass !== GenericObjectType::class && $boundTypeClass !== KeyOfType::class && $boundTypeClass !== IterableType::class && !$boundType instanceof UnionType && !$boundType instanceof IntersectionType && !$boundType instanceof TemplateType ) { $messages[] = RuleErrorBuilder::message(sprintf($notSupportedBoundMessage, $templateTagName, $boundType->describe(VerbosityLevel::typeOnly()))) ->identifier('generics.notSupportedBound') ->build(); } of null
is now supported.
This also fixes phpstan/phpstan#12894 and phpstan/phpstan#12989 |
3b94c27
to
4e21244
Compare
4e21244
to
22ace72
Compare
This pull request has been marked as ready for review. |
This text has to be in the main PR description in order to auto-close the issues. I'll do it manually for this one. |
Thank you. |
Fixed phpstan/phpstan#13048. Essentially,
T of (A|null)
subtracted byA
isT of mixed