File: ReflectionClosure3Test.php

package info (click to toggle)
php-laravel-serializable-closure 1.3.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 400 kB
  • sloc: php: 3,956; makefile: 8
file content (95 lines) | stat: -rw-r--r-- 1,797 bytes parent folder | download | duplicates (2)
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<?php

// Fake
use Foo\Bar;
use Foo\Baz as Qux;

test('resolve arguments', function () {
    $f1 = function (?Bar $p) {
    };
    $e1 = 'function (?\Foo\Bar $p) {
    }';

    $f2 = function (?Bar\Test $p) {
    };
    $e2 = 'function (?\Foo\Bar\Test $p) {
    }';

    $f3 = function (?Qux $p) {
    };
    $e3 = 'function (?\Foo\Baz $p) {
    }';

    $f4 = function (?Qux\Test $p) {
    };
    $e4 = 'function (?\Foo\Baz\Test $p) {
    }';

    $f5 = function (?array $p, ?string $x) {
    };
    $e5 = 'function (?array $p, ?string $x) {
    }';

    expect($f1)->toBeCode($e1);
    expect($f2)->toBeCode($e2);
    expect($f3)->toBeCode($e3);
    expect($f4)->toBeCode($e4);
    expect($f5)->toBeCode($e5);
});

test('resolve return type', function () {
    $f1 = function (): ?Bar {
    };
    $e1 = 'function (): ?\Foo\Bar {
    }';

    $f2 = function (): ?Bar\Test {
    };
    $e2 = 'function (): ?\Foo\Bar\Test {
    }';

    $f3 = function (): ?Qux {
    };
    $e3 = 'function (): ?\Foo\Baz {
    }';

    $f4 = function (): ?Qux\Test {
    };
    $e4 = 'function (): ?\Foo\Baz\Test {
    }';

    $f5 = function (): ?\Foo {
    };
    $e5 = 'function (): ?\Foo {
    }';

    $f6 = function (): ?Foo {
    };
    $e6 = 'function (): ?\Foo {
    }';

    $f7 = function (): ?array {
    };
    $e7 = 'function (): ?array {
    }';

    $f8 = function (): ?string {
    };
    $e8 = 'function (): ?string {
    }';

    $f9 = function (): void {
    };
    $e9 = 'function (): void {
    }';

    expect($f1)->toBeCode($e1);
    expect($f2)->toBeCode($e2);
    expect($f3)->toBeCode($e3);
    expect($f4)->toBeCode($e4);
    expect($f5)->toBeCode($e5);
    expect($f6)->toBeCode($e6);
    expect($f7)->toBeCode($e7);
    expect($f8)->toBeCode($e8);
    expect($f9)->toBeCode($e9);
});