Skip to content
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
8 changes: 4 additions & 4 deletions PHPCSUtils/Utils/PassedParameters.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ public static function hasParameters(File $phpcsFile, $stackPtr)
* 'name_end' => int, // The stack pointer to the last token in the parameter name.
* // This will normally be the colon, but may be different in
* // PHPCS versions prior to the version adding support for
* // named parameters (PHPCS x.x.x).
* // named parameters (PHPCS 3.6.0).
* 'name' => string, // The parameter name as a string (without the colon).
* 'start' => int, // The stack pointer to the first token in the parameter value.
* 'end' => int, // The stack pointer to the last token in the parameter value.
Expand Down Expand Up @@ -262,7 +262,7 @@ public static function getParameters(File $phpcsFile, $stackPtr)
$firstNonEmpty = $phpcsFile->findNext(Tokens::$emptyTokens, $paramStart, ($paramEnd + 1), true);
if ($firstNonEmpty !== $paramEnd) {
/*
* BC: Prior to support for named parameters being added to PHPCS in PHPCS 3.6.0 (?), the
* BC: Prior to support for named parameters being added to PHPCS in PHPCS 3.6.0, the
* parameter name + the colon would in most cases be tokenized as one token: T_GOTO_LABEL.
*/
if ($tokens[$firstNonEmpty]['code'] === \T_GOTO_LABEL) {
Expand All @@ -271,7 +271,7 @@ public static function getParameters(File $phpcsFile, $stackPtr)
$parameters[$cnt]['name'] = \substr($tokens[$firstNonEmpty]['content'], 0, -1);
$paramStart = ($firstNonEmpty + 1);
} else {
// PHPCS 3.6.0 (?) and select situations in PHPCS < 3.6.0 (?).
// PHPCS 3.6.0 and select situations in PHPCS < 3.6.0.
$secondNonEmpty = $phpcsFile->findNext(
Tokens::$emptyTokens,
($firstNonEmpty + 1),
Expand All @@ -280,7 +280,7 @@ public static function getParameters(File $phpcsFile, $stackPtr)
);

/*
* BC: Checking the content of the colon token instead of the token type as in PHPCS < 3.6.0 (?)
* BC: Checking the content of the colon token instead of the token type as in PHPCS < 3.6.0
* the colon _may_ be tokenized as `T_STRING` or even `T_INLINE_ELSE`.
*/
if ($tokens[$secondNonEmpty]['content'] === ':'
Expand Down
3 changes: 2 additions & 1 deletion Tests/Utils/PassedParameters/GetParameterFromStackTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

namespace PHPCSUtils\Tests\Utils\PassedParameters;

use PHPCSUtils\BackCompat\Helper;
use PHPCSUtils\TestUtils\UtilityMethodTestCase;
use PHPCSUtils\Utils\PassedParameters;

Expand Down Expand Up @@ -236,7 +237,7 @@ public function dataGetParameterFromStack()
* Work around to account for the different token positions due to the old tokenization
* to T_GOTO_LABEL which joins two tokens into one (incorrectly).
*/
$namedParamsInPhpcs = false;
$namedParamsInPhpcs = \version_compare(Helper::getVersion(), '3.6.0', '>=');

return [
'all-params-all-positional' => [
Expand Down
3 changes: 2 additions & 1 deletion Tests/Utils/PassedParameters/GetParametersNamedTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

namespace PHPCSUtils\Tests\Utils\PassedParameters;

use PHPCSUtils\BackCompat\Helper;
use PHPCSUtils\TestUtils\UtilityMethodTestCase;
use PHPCSUtils\Utils\PassedParameters;

Expand Down Expand Up @@ -89,7 +90,7 @@ public function dataGetParameters()
* the `match` control structure is not supported in PHPCS yet.
*/
$php8Names = parent::usesPhp8NameTokens();
$namedParamsInPhpcs = false;
$namedParamsInPhpcs = \version_compare(Helper::getVersion(), '3.6.0', '>=');
$matchIsKeyword = \version_compare(\PHP_VERSION_ID, '80000', '>=');

return [
Expand Down