Skip to content

Add IntegerRangeType#2484

Merged
ondrejmirtes merged 2 commits intophpstan:masterfrom
JanTvrdik:pr/range_type
Oct 5, 2019
Merged

Add IntegerRangeType#2484
ondrejmirtes merged 2 commits intophpstan:masterfrom
JanTvrdik:pr/range_type

Conversation

@JanTvrdik
Copy link
Copy Markdown
Contributor

No description provided.

}
return TypeCombinator::union(...$newTypes);
} elseif ($varType instanceof IntegerRangeType) {
return $varType->generalize();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could be shifted :)

/** @var int */
private $max;

public function __construct(?int $min, ?int $max)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Make constructor private and always use fromInterval?

}

if ($type instanceof ConstantIntegerType) {
return $this->min === $type->getValue() && $this->max === $type->getValue();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

IntegerRangeType(X, X) shouldn't be created in the first place?

[
[
new IntegerRangeType(1, 3),
new IntegerRangeType(7, 9),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

No test for union of range + constant integer (inside and outside)

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