Skip to content

alternative take on type projections - #7

Closed
jiripudil wants to merge 1 commit into
type-projections-3from
type-projections-alternative-take
Closed

jiripudil wants to merge 1 commit into
type-projections-3from
type-projections-alternative-take

Conversation

@jiripudil

Copy link
Copy Markdown
Owner

No description provided.


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

Copy link
Copy Markdown

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

Development

Successfully merging this pull request may close these issues.

2 participants