Skip to content

Commit e0f8cb0

Browse files
committed
Removed type restrictions from CompoundType
1 parent 4049da2 commit e0f8cb0

23 files changed

+63
-33
lines changed

src/type/ArrayType.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ protected function typeAssignableBy(Type $type): bool {
3232
return $keysCompatible && $elementsCompatible;
3333
}
3434

35-
public function equals(Type $type): bool {
35+
public function typeEquals(Type $type): bool {
3636
if (!($type instanceof ArrayType)) {
3737
return false;
3838
}

src/type/BooleanType.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ protected function typeAssignableBy(Type $type): bool {
1919
return $this->equals($type);
2020
}
2121

22-
public function equals(Type $type): bool {
22+
public function typeEquals(Type $type): bool {
2323
return $type instanceof BooleanType;
2424
}
2525

src/type/CompoundType.php

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,7 @@ class CompoundType extends Type {
1818
* @param array<Type> $types
1919
*/
2020
private function __construct(array $types) {
21-
$restrictedValues = [];
22-
foreach ($types as $type) {
23-
if($type->getRestrictedValues() !== null) {
24-
$restrictedValues = array_merge($restrictedValues, $type->getRestrictedValues());
25-
} else {
26-
$restrictedValues = null;
27-
break;
28-
}
29-
}
30-
parent::__construct($restrictedValues);
21+
parent::__construct();
3122
$this->types = $types;
3223
}
3324

@@ -121,7 +112,7 @@ protected function typeAssignableBy(Type $type): bool {
121112
}
122113
}
123114

124-
public function equals(Type $type): bool {
115+
public function typeEquals(Type $type): bool {
125116
if($type instanceof CompoundType) {
126117
if(count($type->types) !== count($this->types)) {
127118
return false;

src/type/DateIntervalType.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ protected function typeAssignableBy(Type $type): bool {
1515
return $this->equals($type);
1616
}
1717

18-
public function equals(Type $type): bool {
18+
public function typeEquals(Type $type): bool {
1919
return $type instanceof DateIntervalType;
2020
}
2121

src/type/DateTimeImmutableType.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ protected function typeAssignableBy(Type $type): bool {
1616
return $this->equals($type);
1717
}
1818

19-
public function equals(Type $type): bool {
19+
public function typeEquals(Type $type): bool {
2020
return $type instanceof DateTimeImmutableType;
2121
}
2222

src/type/EnumInstanceType.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ protected function typeAssignableBy(Type $type): bool {
1919
return $type instanceof EnumInstanceType && $this->enumType->equals($type->enumType);
2020
}
2121

22-
public function equals(Type $type): bool {
22+
public function typeEquals(Type $type): bool {
2323
return $type instanceof EnumInstanceType && $this->enumType->equals($type->enumType);
2424
}
2525

src/type/FloatType.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ protected function typeAssignableBy(Type $type): bool {
1717
return $this->equals($type);
1818
}
1919

20-
public function equals(Type $type): bool {
20+
public function typeEquals(Type $type): bool {
2121
return $type instanceof FloatType;
2222
}
2323

src/type/IntegerType.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ protected function typeAssignableBy(Type $type): bool {
1717
return $this->equals($type);
1818
}
1919

20-
public function equals(Type $type): bool {
20+
public function typeEquals(Type $type): bool {
2121
return $type instanceof IntegerType;
2222
}
2323

src/type/MemberAccsessType.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ protected function typeAssignableBy(Type $type): bool {
2424
return $this->equals($type);
2525
}
2626

27-
public function equals(Type $type): bool {
27+
public function typeEquals(Type $type): bool {
2828
return ($type instanceof MemberAccsessType) && $type->memberIdentifier === $this->memberIdentifier;
2929
}
3030

src/type/MixedType.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ protected function typeAssignableBy(Type $type): bool {
2222
return true;
2323
}
2424

25-
public function equals(Type $type): bool {
25+
public function typeEquals(Type $type): bool {
2626
return $type instanceof MixedType;
2727
}
2828

0 commit comments

Comments
 (0)