7
7
use Exception ;
8
8
use InvalidArgumentException ;
9
9
use PHPUnit \Framework \TestCase ;
10
+ use Throwable ;
11
+ use function fopen ;
12
+ use function serialize ;
13
+ use function unserialize ;
10
14
11
15
/**
12
16
* @coversDefaultClass \phpDocumentor\Reflection\DocBlock\Tags\InvalidTag
@@ -38,17 +42,17 @@ public function testCreationWithError() : void
38
42
39
43
self ::assertSame ('name ' , $ tag ->getName ());
40
44
self ::assertSame ('@name Body ' , $ tag ->render ());
41
- self ::assertSame ('Body ' , (string )$ tag );
45
+ self ::assertSame ('Body ' , (string ) $ tag );
42
46
self ::assertSame ($ exception , $ tag ->getException ());
43
47
}
44
48
45
49
public function testCreationWithErrorContainingClosure () : void
46
50
{
47
51
try {
48
52
$ this ->throwExceptionFromClosureWithClosureArgument ();
49
- } catch (Exception $ e ) {
53
+ } catch (Throwable $ e ) {
50
54
$ parentException = new Exception ('test ' , 0 , $ e );
51
- $ tag = InvalidTag::create ('Body ' , 'name ' )->withError ($ parentException );
55
+ $ tag = InvalidTag::create ('Body ' , 'name ' )->withError ($ parentException );
52
56
self ::assertSame ('name ' , $ tag ->getName ());
53
57
self ::assertSame ('@name Body ' , $ tag ->render ());
54
58
self ::assertSame ($ parentException , $ tag ->getException ());
@@ -58,36 +62,36 @@ public function testCreationWithErrorContainingClosure() : void
58
62
}
59
63
}
60
64
61
- private function throwExceptionFromClosureWithClosureArgument ()
65
+ private function throwExceptionFromClosureWithClosureArgument () : void
62
66
{
63
- $ function = function () {
67
+ $ function = static function () : void {
64
68
throw new InvalidArgumentException ();
65
69
};
66
70
67
71
$ function ($ function );
68
72
}
69
73
70
- public function testCreationWithErrorContainingResource ()
74
+ public function testCreationWithErrorContainingResource () : void
71
75
{
72
76
try {
73
77
$ this ->throwExceptionWithResourceArgument ();
74
- } catch (Exception $ e ) {
78
+ } catch (Throwable $ e ) {
75
79
$ parentException = new Exception ('test ' , 0 , $ e );
76
- $ tag = InvalidTag::create ('Body ' , 'name ' )->withError ($ parentException );
80
+ $ tag = InvalidTag::create ('Body ' , 'name ' )->withError ($ parentException );
77
81
self ::assertSame ('name ' , $ tag ->getName ());
78
82
self ::assertSame ('@name Body ' , $ tag ->render ());
79
83
self ::assertSame ($ parentException , $ tag ->getException ());
80
84
self ::assertStringStartsWith (
81
85
'resource(stream) ' ,
82
- $ tag ->getException ()->getPrevious ()->getTrace ()[0 ]['args ' ][0 ])
83
- ;
86
+ $ tag ->getException ()->getPrevious ()->getTrace ()[0 ]['args ' ][0 ]
87
+ ) ;
84
88
self ::assertEquals ($ parentException , unserialize (serialize ($ parentException )));
85
89
}
86
90
}
87
91
88
- private function throwExceptionWithResourceArgument ()
92
+ private function throwExceptionWithResourceArgument () : void
89
93
{
90
- $ function = function () {
94
+ $ function = static function () : void {
91
95
throw new InvalidArgumentException ();
92
96
};
93
97
0 commit comments