Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UtilityMethodTestCase::getTargetToken(): change to a static method #382

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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');
}
}