Skip to content
Draft
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
26 changes: 18 additions & 8 deletions PHPCSUtils/BackCompat/BCFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ public static function getMethodParameters(File $phpcsFile, $stackPtr)
*
* Changelog for the PHPCS native function:
* - Introduced in PHPCS 0.0.5.
* - The upstream method has received no significant updates since PHPCS 3.13.0.
* - The upstream method has received no significant updates since PHPCS 3.13.3.
*
* @see \PHP_CodeSniffer\Files\File::getMethodProperties() Original source.
* @see \PHPCSUtils\Utils\FunctionDeclarations::getProperties() PHPCSUtils native improved version.
Expand Down Expand Up @@ -559,6 +559,7 @@ public static function getMethodProperties(File $phpcsFile, $stackPtr)
* 'is_static' => boolean, // TRUE if the static keyword was found.
* 'is_readonly' => boolean, // TRUE if the readonly keyword was found.
* 'is_final' => boolean, // TRUE if the final keyword was found.
* 'is_abstract' => boolean, // TRUE if the abstract keyword was found.
* 'type' => string, // The type of the var (empty if no type specified).
* 'type_token' => integer|false, // The stack pointer to the start of the type
* // or FALSE if there is no type.
Expand All @@ -573,13 +574,16 @@ public static function getMethodProperties(File $phpcsFile, $stackPtr)
*
* Changelog for the PHPCS native function:
* - Introduced in PHPCS 0.0.5.
* - PHPCS 3.13.3: support for PHP 8.4 abstract properties.
* - PHPCS 4.0: properties in interfaces (PHP 8.4+) are accepted.
* - PHPCS 4.0: will no longer throw a parse error warning.
*
* @see \PHP_CodeSniffer\Files\File::getMemberProperties() Original source.
* @see \PHPCSUtils\Utils\Variables::getMemberProperties() PHPCSUtils native improved version.
*
* @since 1.0.0
* @since 1.1.0 Sync with PHPCS 4.0.0, remove parse error warning and support PHP 8.4 properties in interfaces. PHPCS(new)#991
* @since 1.1.2 Sync with PHPCS 3.13.3, support for abstract properties. PHPCS(new)#xxx
*
* @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned.
* @param int $stackPtr The position in the stack of the `T_VARIABLE` token to
Expand Down Expand Up @@ -626,6 +630,7 @@ public static function getMemberProperties(File $phpcsFile, $stackPtr)
T_VAR => T_VAR,
T_READONLY => T_READONLY,
T_FINAL => T_FINAL,
T_ABSTRACT => T_ABSTRACT,
];

$valid += Tokens::$scopeModifiers;
Expand All @@ -637,6 +642,7 @@ public static function getMemberProperties(File $phpcsFile, $stackPtr)
$isStatic = false;
$isReadonly = false;
$isFinal = false;
$isAbstract = false;

$startOfStatement = $phpcsFile->findPrevious(
[
Expand Down Expand Up @@ -684,6 +690,9 @@ public static function getMemberProperties(File $phpcsFile, $stackPtr)
case T_FINAL:
$isFinal = true;
break;
case T_ABSTRACT:
$isAbstract = true;
break;
}
}

Expand Down Expand Up @@ -728,6 +737,7 @@ public static function getMemberProperties(File $phpcsFile, $stackPtr)
'is_static' => $isStatic,
'is_readonly' => $isReadonly,
'is_final' => $isFinal,
'is_abstract' => $isAbstract,
'type' => $type,
'type_token' => $typeToken,
'type_end_token' => $typeEndToken,
Expand All @@ -751,7 +761,7 @@ public static function getMemberProperties(File $phpcsFile, $stackPtr)
*
* Changelog for the PHPCS native function:
* - Introduced in PHPCS 1.3.0.
* - The upstream method has received no significant updates since PHPCS 3.13.0.
* - The upstream method has received no significant updates since PHPCS 3.13.3.
*
* @see \PHP_CodeSniffer\Files\File::getClassProperties() Original source.
* @see \PHPCSUtils\Utils\ObjectDeclarations::getClassProperties() PHPCSUtils native improved version.
Expand Down Expand Up @@ -779,7 +789,7 @@ public static function getClassProperties(File $phpcsFile, $stackPtr)
*
* Changelog for the PHPCS native function:
* - Introduced in PHPCS 0.0.5.
* - The upstream method has received no significant updates since PHPCS 3.13.0.
* - The upstream method has received no significant updates since PHPCS 3.13.3.
*
* @see \PHP_CodeSniffer\Files\File::isReference() Original source.
* @see \PHPCSUtils\Utils\Operators::isReference() PHPCSUtils native improved version.
Expand All @@ -805,7 +815,7 @@ public static function isReference(File $phpcsFile, $stackPtr)
*
* Changelog for the PHPCS native function:
* - Introduced in PHPCS 0.0.5.
* - The upstream method has received no significant updates since PHPCS 3.13.0.
* - The upstream method has received no significant updates since PHPCS 3.13.3.
*
* @see \PHP_CodeSniffer\Files\File::getTokensAsString() Original source.
* @see \PHPCSUtils\Utils\GetTokensAsString Related set of functions.
Expand Down Expand Up @@ -834,7 +844,7 @@ public static function getTokensAsString(File $phpcsFile, $start, $length, $orig
*
* Changelog for the PHPCS native function:
* - Introduced in PHPCS 2.1.0.
* - The upstream method has received no significant updates since PHPCS 3.13.0.
* - The upstream method has received no significant updates since PHPCS 3.13.3.
*
* @see \PHP_CodeSniffer\Files\File::findStartOfStatement() Original source.
*
Expand All @@ -858,7 +868,7 @@ public static function findStartOfStatement(File $phpcsFile, $start, $ignore = n
*
* Changelog for the PHPCS native function:
* - Introduced in PHPCS 2.1.0.
* - The upstream method has received no significant updates since PHPCS 3.13.0.
* - The upstream method has received no significant updates since PHPCS 3.13.3.
*
* @see \PHP_CodeSniffer\Files\File::findEndOfStatement() Original source.
*
Expand All @@ -882,7 +892,7 @@ public static function findEndOfStatement(File $phpcsFile, $start, $ignore = nul
*
* Changelog for the PHPCS native function:
* - Introduced in PHPCS 0.0.5.
* - The upstream method has received no significant updates since PHPCS 3.13.0.
* - The upstream method has received no significant updates since PHPCS 3.13.3.
*
* @see \PHP_CodeSniffer\Files\File::hasCondition() Original source.
* @see \PHPCSUtils\Utils\Conditions::hasCondition() PHPCSUtils native alternative.
Expand All @@ -907,7 +917,7 @@ public static function hasCondition(File $phpcsFile, $stackPtr, $types)
*
* Changelog for the PHPCS native function:
* - Introduced in PHPCS 1.3.0.
* - The upstream method has received no significant updates since PHPCS 3.13.0.
* - The upstream method has received no significant updates since PHPCS 3.13.3.
*
* @see \PHP_CodeSniffer\Files\File::getCondition() Original source.
* @see \PHPCSUtils\Utils\Conditions::getCondition() More versatile alternative.
Expand Down
2 changes: 1 addition & 1 deletion PHPCSUtils/BackCompat/BCTokens.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ final class BCTokens

/**
* Handle calls to (undeclared) methods for token arrays which haven't received any
* changes since PHPCS 3.13.0.
* changes since PHPCS 3.13.3.
*
* @since 1.0.0
*
Expand Down
1 change: 1 addition & 0 deletions PHPCSUtils/Tokens/Collections.php
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,7 @@ final class Collections
\T_VAR => \T_VAR,
\T_READONLY => \T_READONLY,
\T_FINAL => \T_FINAL,
\T_ABSTRACT => \T_ABSTRACT,
];

/**
Expand Down
6 changes: 6 additions & 0 deletions PHPCSUtils/Utils/Variables.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ final class Variables
* 'is_static' => boolean, // TRUE if the static keyword was found.
* 'is_readonly' => boolean, // TRUE if the readonly keyword was found.
* 'is_final' => boolean, // TRUE if the final keyword was found.
* 'is_abstract' => boolean, // TRUE if the abstract keyword was found.
* 'type' => string, // The type of the var (empty if no type specified).
* 'type_token' => integer|false, // The stack pointer to the start of the type
* // or FALSE if there is no type.
Expand Down Expand Up @@ -155,6 +156,7 @@ public static function getMemberProperties(File $phpcsFile, $stackPtr)
$isStatic = false;
$isReadonly = false;
$isFinal = false;
$isAbstract = false;

$startOfStatement = $phpcsFile->findPrevious(
[
Expand Down Expand Up @@ -211,6 +213,9 @@ public static function getMemberProperties(File $phpcsFile, $stackPtr)
case \T_FINAL:
$isFinal = true;
break;
case \T_ABSTRACT:
$isAbstract = true;
break;
}
}

Expand Down Expand Up @@ -254,6 +259,7 @@ public static function getMemberProperties(File $phpcsFile, $stackPtr)
'is_static' => $isStatic,
'is_readonly' => $isReadonly,
'is_final' => $isFinal,
'is_abstract' => $isAbstract,
'type' => $type,
'type_token' => $typeToken,
'type_end_token' => $typeEndToken,
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Whether you need to split an `array` into the individual items, are trying to de

Includes improved versions of the PHPCS native utility functions and plenty of new utility functions.

These functions are compatible with PHPCS 3.13.0 up to PHPCS `4.x`.
These functions are compatible with PHPCS 3.13.3 up to PHPCS `4.x`.

### A collection of static properties and methods for often-used token groups

Expand Down Expand Up @@ -78,7 +78,7 @@ To see detailed information about all the available abstract sniffs, utility fun
## Minimum Requirements

* PHP 5.4 or higher.
* [PHP_CodeSniffer] 3.13.0+/4.0.0+.
* [PHP_CodeSniffer] 3.13.3+/4.0.0+.
* Recommended PHP extensions for optimal functionality:
- PCRE with Unicode support (normally enabled by default)

Expand Down
24 changes: 24 additions & 0 deletions Tests/BackCompat/BCFile/GetMemberPropertiesTest.inc
Original file line number Diff line number Diff line change
Expand Up @@ -401,3 +401,27 @@ class AsymVisibility {
/* testPHP84IllegalAsymPublicProtectedSetStaticProperty */
public protected(set) static mixed $prop10;
}

abstract class WithAbstractProperties {
/* testPHP84AbstractPublicTypedProp */
abstract public string $val1 { get; }
/* testPHP84AbstractProtectedTypedProp */
abstract protected Union|Type $val2 { set; }
/* testPHP84AbstractMiddleTypedProp */
public abstract Intersection&Type $val3 { get; }
/* testPHP84AbstractImplicitVisibilityTypedProp */
abstract int $val4 { set; }
/* testPHP84AbstractImplicitVisibilityProp */
abstract $val5 { get; }
/* testPHP84AbstractNullableTypedProp */
abstract public ?string $val6 { set; }
/* testPHP84AbstractComplexTypedProp */
abstract protected (Foo&\Bar)|false $val7 { get; }

/* testPHP84IllegalAbstractPrivateProp */
private abstract string $val8 { get; }
/* testPHP84IllegalAbstractReadonlyProp */
public readonly abstract string $val9 { get; }
/* testPHP84IllegalAbstractStaticProp */
public abstract static string $val10 { get; }
}
Loading
Loading