diff --git a/PHPCSUtils/TestUtils/UtilityMethodTestCase.php b/PHPCSUtils/TestUtils/UtilityMethodTestCase.php index ebbabcdf..c70d032b 100644 --- a/PHPCSUtils/TestUtils/UtilityMethodTestCase.php +++ b/PHPCSUtils/TestUtils/UtilityMethodTestCase.php @@ -329,6 +329,7 @@ public static function usesPhp8NameTokens() * @since 1.0.0 * @since 1.0.0-alpha4 Will throw an exception whether the delimiter comment or the target * token is not found. + * @since 1.0.0-alpha4 This method is now `static`, which allows for it to be used in "set up before class". * * @param string $commentString The complete delimiter comment to look for as a string. * This string should include the comment opener and closer. @@ -340,7 +341,7 @@ public static function usesPhp8NameTokens() * @throws \PHPCSUtils\Exceptions\TestMarkerNotFound When the delimiter comment for the test was not found. * @throws \PHPCSUtils\Exceptions\TestTargetNotFound When the target token cannot be found. */ - public function getTargetToken($commentString, $tokenType, $tokenContent = null) + public static function getTargetToken($commentString, $tokenType, $tokenContent = null) { $start = (self::$phpcsFile->numTokens - 1); $comment = self::$phpcsFile->findPrevious( diff --git a/Tests/TestUtils/UtilityMethodTestCase/GetTargetTokenTest.php b/Tests/TestUtils/UtilityMethodTestCase/GetTargetTokenTest.php index fed4121c..162da8f5 100644 --- a/Tests/TestUtils/UtilityMethodTestCase/GetTargetTokenTest.php +++ b/Tests/TestUtils/UtilityMethodTestCase/GetTargetTokenTest.php @@ -54,7 +54,7 @@ public function testGetTargetToken($expected, $commentString, $tokenType, $token if (isset($tokenContent)) { $result = $this->getTargetToken($commentString, $tokenType, $tokenContent); } else { - $result = $this->getTargetToken($commentString, $tokenType); + $result = self::getTargetToken($commentString, $tokenType); } $this->assertSame($expected, $result); @@ -147,6 +147,6 @@ public function testGetTargetTokenNotFoundException() $this->expectException('PHPCSUtils\Exceptions\TestTargetNotFound'); $this->expectExceptionMessage('Failed to find test target token for comment string: '); - $this->getTargetToken('/* testNotFindingTarget */', [\T_VARIABLE], '$a'); + self::getTargetToken('/* testNotFindingTarget */', [\T_VARIABLE], '$a'); } }