Skip to content

[TypeInfo] Add ExplicitStringType and ClassLikeStringType classes to hold specific type details for string builtin types #59833

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

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
CS
  • Loading branch information
DerManoMann committed Feb 22, 2025
commit c3a12af02d9af2de7fdb02edae50fdfed6a65aaf
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,11 @@ public static function resolveDataProvider(): iterable
yield [Type::explicitString('html-escaped-string'), 'html-escaped-string'];

yield [Type::explicitString('class-string'), 'class-string'];
yield [Type::classLikeString('class-string', Type::object(Dummy::class)), sprintf('class-string<%s>', Dummy::class)];
yield [Type::classLikeString('class-string', Type::object(Dummy::class)), \sprintf('class-string<%s>', Dummy::class)];
yield [Type::explicitString('trait-string'), 'trait-string'];
yield [Type::classLikeString('trait-string', Type::object(DummyTrait::class)), sprintf('trait-string<%s>', DummyTrait::class)];
yield [Type::classLikeString('trait-string', Type::object(DummyTrait::class)), \sprintf('trait-string<%s>', DummyTrait::class)];
yield [Type::explicitString('interface-string'), 'interface-string'];
yield [Type::classLikeString('interface-string', Type::object(DummyInterface::class)), sprintf('interface-string<%s>', DummyInterface::class)];
yield [Type::classLikeString('interface-string', Type::object(DummyInterface::class)), \sprintf('interface-string<%s>', DummyInterface::class)];

// nullable
yield [Type::nullable(Type::int()), '?int'];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@ public function getObjectType(): ObjectType

public function __toString(): string
{
return sprintf('%s<%s>', $this->getExplicitType(), $this->objectType);
return \sprintf('%s<%s>', $this->getExplicitType(), $this->objectType);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ private function getTypeFromNode(TypeNode $node, ?TypeContext $typeContext): Typ
}

if ($type instanceof ExplicitStringType
&& in_array($type->getExplicitType(), ['class-string', 'interface-string', 'trait-string'], true)
&& \in_array($type->getExplicitType(), ['class-string', 'interface-string', 'trait-string'], true)
&& 1 === \count($variableTypes) && $variableTypes[0] instanceof Type\ObjectType) {
return Type::classLikeString($type->getExplicitType(), $variableTypes[0]);
}
Expand Down
Loading
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy