This repository was archived by the owner on Sep 1, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +10
-7
lines changed
Expand file tree Collapse file tree 3 files changed +10
-7
lines changed Original file line number Diff line number Diff line change @@ -67,7 +67,7 @@ final class ShapeSpec extends TypeSpec<shape()> {
6767
6868 <<__Override >>
6969 public function assertType (mixed $value ): shape() {
70- if (! (\ is_array ($value ) || ( $value is dict < _ , _ > ) )) {
70+ if (! \ HH \ is_dict_or_darray ($value )) {
7171 throw IncorrectTypeException :: withValue(
7272 $this -> getTrace(),
7373 ' shape' ,
@@ -80,7 +80,9 @@ final class ShapeSpec extends TypeSpec<shape()> {
8080 foreach ($this -> inners as $key => $spec ) {
8181 $trace = $this -> getTrace()-> withFrame(' shape[' . $key . ' ]' );
8282 if (C \contains_key ($value , $key )) {
83- $out [$key ] = $spec -> withTrace($trace )-> assertType($value [$key ] ?? null );
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 ));
8486 continue ;
8587 }
8688
Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ final class TupleSpec extends TypeSpec<BogusTuple> {
2222
2323 <<__Override >>
2424 public function coerceType (mixed $value ): BogusTuple {
25- if (! (\ is_array ($value ) || ( $value is vec < _ > ) )) {
25+ if (! \ HH \ is_vec_or_varray ($value )) {
2626 throw
2727 TypeCoercionException :: withValue($this -> getTrace(), ' tuple' , $value );
2828 }
@@ -49,12 +49,13 @@ final class TupleSpec extends TypeSpec<BogusTuple> {
4949
5050 <<__Override >>
5151 public function assertType (mixed $value ): BogusTuple {
52- if (\is_array ($value )) {
53- $value = vec ($value );
54- } else if (! ($value is vec < _ > )) {
52+ if (! \HH \ is_vec_or_varray ($value )) {
5553 throw
5654 IncorrectTypeException :: withValue($this -> getTrace(), ' tuple' , $value );
5755 }
56+ if (! $value is vec < _ > ) {
57+ $value = vec ($value );
58+ }
5859 $values = $value ;
5960
6061 $count = \count ($values );
Original file line number Diff line number Diff line change @@ -31,7 +31,7 @@ final class UntypedArraySpec extends TypeSpec<varray_or_darray<mixed>> {
3131
3232 <<__Override >>
3333 public function assertType (mixed $value ): varray_or_darray <mixed > {
34- if (! \is_array ($value )) {
34+ if (! \HH \ is_php_array ($value )) {
3535 throw
3636 IncorrectTypeException :: withValue($this -> getTrace(), ' array' , $value );
3737 }
You can’t perform that action at this time.
0 commit comments