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

alternative take on type projections #7

Closed

Conversation

jiripudil
Copy link
Owner

No description provided.


$variance = TemplateTypeVariance::createInvariant();
foreach ($references as $reference) {
if ($reference->getType() === $type) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is totally OK when traversing. We have === logic in many places:

	public function traverse(callable $cb): Type
	{
		$keyType = $cb($this->keyType);
		$itemType = $cb($this->itemType);

		if ($keyType !== $this->keyType || $itemType !== $this->itemType) {
			if ($keyType instanceof NeverType && $itemType instanceof NeverType) {
				return new ConstantArrayType([], []);
			}

			return new self($keyType, $itemType);
		}

		return $this;
	}

@jiripudil jiripudil closed this Sep 18, 2023
@jiripudil jiripudil deleted the type-projections-alternative-take branch September 18, 2023 11:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants