Skip to content

Commit

Permalink
Merge pull request #382 from PHPCSStandards/testutils/utilitymethodte…
Browse files Browse the repository at this point in the history
…stcase-make-gettargettoken-method-static

UtilityMethodTestCase::getTargetToken(): change to a static method
  • Loading branch information
jrfnl committed Oct 23, 2022
2 parents e11d8f9 + 8aebf8a commit 3f75cc5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion PHPCSUtils/TestUtils/UtilityMethodTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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(
Expand Down
4 changes: 2 additions & 2 deletions Tests/TestUtils/UtilityMethodTestCase/GetTargetTokenTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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');
}
}

0 comments on commit 3f75cc5

Please sign in to comment.