This repository was archived by the owner on Sep 1, 2023. It is now read-only.
File tree 2 files changed +6
-9
lines changed 2 files changed +6
-9
lines changed Original file line number Diff line number Diff line change @@ -67,7 +67,7 @@ final class ShapeSpec extends TypeSpec<shape()> {
67
67
68
68
<<__Override >>
69
69
public function assertType (mixed $value ): shape() {
70
- if (! \HH \ is_dict_or_darray ($value )) {
70
+ if (! ( \HH \ is_php_array ($value ) || ( $value is dict < _ , _ > ) )) {
71
71
throw IncorrectTypeException :: withValue(
72
72
$this -> getTrace(),
73
73
' shape' ,
@@ -80,9 +80,7 @@ final class ShapeSpec extends TypeSpec<shape()> {
80
80
foreach ($this -> inners as $key => $spec ) {
81
81
$trace = $this -> getTrace()-> withFrame(' shape[' . $key . ' ]' );
82
82
if (C \contains_key ($value , $key )) {
83
- // Using idx() even though we just checked the key's existence, to avoid
84
- // a Hack error.
85
- $out [$key ] = $spec -> withTrace($trace )-> assertType(idx ($value , $key ));
83
+ $out [$key ] = $spec -> withTrace($trace )-> assertType($value [$key ] ?? null );
86
84
continue ;
87
85
}
88
86
Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ final class TupleSpec extends TypeSpec<BogusTuple> {
22
22
23
23
<<__Override >>
24
24
public function coerceType (mixed $value ): BogusTuple {
25
- if (! \HH \ is_vec_or_varray ($value )) {
25
+ if (! ( \HH \ is_php_array ($value ) || ( $value is vec < _ > ) )) {
26
26
throw
27
27
TypeCoercionException :: withValue($this -> getTrace(), ' tuple' , $value );
28
28
}
@@ -49,13 +49,12 @@ final class TupleSpec extends TypeSpec<BogusTuple> {
49
49
50
50
<<__Override >>
51
51
public function assertType (mixed $value ): BogusTuple {
52
- if (! \HH \ is_vec_or_varray ($value )) {
52
+ if (\HH \ is_php_array ($value )) {
53
+ $value = vec ($value );
54
+ } else if (! ($value is vec < _ > )) {
53
55
throw
54
56
IncorrectTypeException :: withValue($this -> getTrace(), ' tuple' , $value );
55
57
}
56
- if (! $value is vec < _ > ) {
57
- $value = vec ($value );
58
- }
59
58
$values = $value ;
60
59
61
60
$count = \count ($values );
You can’t perform that action at this time.
0 commit comments