Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
staabm committed Jan 8, 2023
1 parent 1742555 commit 0a4f077
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/Reflection/InitializerExprTypeResolver.php
Expand Up @@ -337,7 +337,10 @@ public function getType(Expr $expr, InitializerExprContext $context): Type

if ($expr instanceof MagicConst\Class_) {
if ($context->getTraitName() !== null) {
return new StringType();
return new IntersectionType([
new ClassStringType(),
new AccessoryLiteralStringType(),
]);
}

if ($context->getClassName() === null) {
Expand All @@ -349,7 +352,10 @@ public function getType(Expr $expr, InitializerExprContext $context): Type

if ($expr instanceof MagicConst\Namespace_) {
if ($context->getTraitName() !== null) {
return new StringType();
return new IntersectionType([
new StringType(),
new AccessoryLiteralStringType(),
]);
}

return new ConstantStringType($context->getNamespace() ?? '');
Expand Down

0 comments on commit 0a4f077

Please sign in to comment.