Skip to content
Permalink
Browse files

Add more tests for key-of/value-of

  • Loading branch information...
muglug committed May 28, 2019
1 parent 7df8819 commit f062f9bb75f65d5abbb01ef43c10bc7cdc5493cc
Showing with 46 additions and 2 deletions.
  1. +46 −2 tests/ValueTest.php
@@ -606,7 +606,11 @@ class A {
* @param key-of<A::C> $i
*/
public static function foo(int $i) : void {}
}'
}
A::foo(1);
A::foo(2);
A::foo(3);'
],
'valueOf' => [
'<?php
@@ -621,7 +625,11 @@ class A {
* @param value-of<A::C> $j
*/
public static function bar(string $j) : void {}
}'
}
A::bar("a");
A::bar("b");
A::bar("c");'
],
];
}
@@ -798,6 +806,42 @@ function foo(string $s) : void {
}',
'error_message' => 'RedundantCondition',
],
'keyOfBadValue' => [
'<?php
class A {
const C = [
1 => "a",
2 => "b",
3 => "c"
];
/**
* @param key-of<A::C> $i
*/
public static function foo(int $i) : void {}
}
A::foo(4);',
'error_message' => 'InvalidArgument'
],
'valueOfBadValue' => [
'<?php
class A {
const C = [
1 => "a",
2 => "b",
3 => "c"
];
/**
* @param value-of<A::C> $j
*/
public static function bar(string $j) : void {}
}
A::bar("d");',
'error_message' => 'InvalidArgument'
],
];
}
}

0 comments on commit f062f9b

Please sign in to comment.
You can’t perform that action at this time.