forked from phpstan/phpstan-src
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbug-3842.php
More file actions
62 lines (51 loc) · 1.29 KB
/
bug-3842.php
File metadata and controls
62 lines (51 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php declare(strict_types = 1);
namespace Bug3842;
use function PHPStan\Testing\assertType;
class ClassA
{
public static function callback(): void
{
}
}
class ClassB
{
public function callback(): void
{
}
}
function testIsArrayOnCallable(callable $value): void {
if (is_array($value)) {
assertType('array<mixed, mixed>&callable(): mixed', $value);
assertType('class-string|object', $value[0]);
assertType('string', $value[1]);
}
}
/** @param callable-array $value */
function testCallableArrayPhpDoc(array $value): void {
assertType('array&callable(): mixed', $value);
assertType('class-string|object', $value[0]);
assertType('string', $value[1]);
}
function testIsStringOnCallable(callable $value): void {
if (is_string($value)) {
assertType('callable-string', $value);
}
}
/** @param array{string|object, string} $values */
function check(array $values): void {
}
/** @param array{class-string|object, string} $values */
function checkClassString(array $values): void {
}
/** @param 0|1 $offset */
function testCallableArrayUnionOffset(callable $value, int $offset): void {
if (is_array($value)) {
assertType('object|string', $value[$offset]);
}
}
function testPassCallableArray(callable $value): void {
if (is_array($value)) {
check($value);
checkClassString($value);
}
}