44
55namespace Devlop \PHPUnit ;
66
7+ use PHPUnit \Framework \Assert ;
78use Throwable ;
89
910trait ExceptionAssertions
@@ -16,7 +17,7 @@ trait ExceptionAssertions
1617 * @param callable $callback
1718 * @return void
1819 */
19- public function assertExceptionThrown (string $ expectedException , callable $ callback , ?callable $ validator = null ) : Throwable
20+ public static function assertExceptionThrown (string $ expectedException , callable $ callback , ?callable $ validator = null ) : void
2021 {
2122 $ thrownException = null ;
2223
@@ -26,7 +27,7 @@ public function assertExceptionThrown(string $expectedException, callable $callb
2627 $ thrownException = $ e ;
2728 }
2829
29- $ this -> assertInstanceOf (
30+ Assert:: assertInstanceOf (
3031 $ expectedException ,
3132 $ thrownException ,
3233 $ thrownException === null
@@ -41,8 +42,6 @@ public function assertExceptionThrown(string $expectedException, callable $callb
4142 if ($ validator !== null ) {
4243 $ validator ($ thrownException );
4344 }
44-
45- return $ thrownException ;
4645 }
4746
4847 /**
@@ -54,7 +53,7 @@ public function assertExceptionThrown(string $expectedException, callable $callb
5453 * @param callable $callback
5554 * @return void
5655 */
57- public function assertExceptionNotThrown (string $ expectedException , callable $ callback ) : void
56+ public static function assertExceptionNotThrown (string $ expectedException , callable $ callback ) : void
5857 {
5958 $ thrownException = null ;
6059
@@ -64,7 +63,7 @@ public function assertExceptionNotThrown(string $expectedException, callable $ca
6463 $ thrownException = $ e ;
6564 }
6665
67- $ this -> assertNotInstanceOf (
66+ Assert:: assertNotInstanceOf (
6867 $ expectedException ,
6968 $ thrownException ,
7069 \sprintf (
@@ -80,7 +79,7 @@ public function assertExceptionNotThrown(string $expectedException, callable $ca
8079 * @param callable $callback
8180 * @return void
8281 */
83- public function assertNoExceptionsThrown (callable $ callback ) : void
82+ public static function assertNoExceptionsThrown (callable $ callback ) : void
8483 {
8584 $ thrownException = null ;
8685
@@ -90,7 +89,7 @@ public function assertNoExceptionsThrown(callable $callback) : void
9089 $ thrownException = $ e ;
9190 }
9291
93- $ this -> assertNull (
92+ Assert:: assertNull (
9493 $ thrownException ,
9594 \sprintf (
9695 'Failed asserting that no exceptions was thrown, exception of type "%1$s was thrown. ' ,
0 commit comments