-
Notifications
You must be signed in to change notification settings - Fork 574
Expand file tree
/
Copy pathbug-5020.php
More file actions
52 lines (45 loc) · 1.17 KB
/
bug-5020.php
File metadata and controls
52 lines (45 loc) · 1.17 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
<?php
namespace Bug5020;
use function PHPStan\Testing\assertType;
interface ITransformer
{
public static function Transform(string $theInput, bool &$theErrorEncountered): string;
}
class Transformer implements ITransformer
{
public static function Transform(string $theInput, bool &$theErrorEncountered): string
{
if ($theInput === 'invalid') {
$theErrorEncountered = true;
return '';
}
return strtoupper(trim($theInput));
}
}
function testConstantStringStaticCall(): void
{
$transformer = 'Bug5020\Transformer';
$input = ' asdasda asdasd ';
$error = false;
$output = $transformer::Transform($input, $error);
assertType('string', $output);
assertType('bool', $error);
}
function testDirectStaticCall(): void
{
$input = ' asdasda asdasd ';
$error = false;
$output = Transformer::Transform($input, $error);
assertType('string', $output);
assertType('bool', $error);
}
function testClassStringStaticCall(): void
{
/** @var class-string<ITransformer> $transformer */
$transformer = 'Bug5020\Transformer';
$input = ' asdasda asdasd ';
$error = false;
$output = $transformer::Transform($input, $error);
assertType('string', $output);
assertType('bool', $error);
}