Skip to content

Commit a76ca58

Browse files
authored
Merge pull request #1187 from PHPCSStandards/php-8.4/squiz-membervarspacing-support-abstract-properties
PHP 8.4 | Squiz/MemberVarSpacing: add support for abstract properties
2 parents e74e6c1 + e665e2f commit a76ca58

File tree

4 files changed

+31
-0
lines changed

4 files changed

+31
-0
lines changed

src/Standards/Squiz/Sniffs/WhiteSpace/MemberVarSpacingSniff.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ protected function processMemberVar(File $phpcsFile, $stackPtr)
5858
$validPrefixes[] = T_FINAL;
5959
$validPrefixes[] = T_VAR;
6060
$validPrefixes[] = T_READONLY;
61+
$validPrefixes[] = T_ABSTRACT;
6162

6263
$startOfStatement = $phpcsFile->findNext($validPrefixes, ($endOfPreviousStatement + 1), $stackPtr, false, null, true);
6364
if ($startOfStatement === false) {

src/Standards/Squiz/Tests/WhiteSpace/MemberVarSpacingUnitTest.1.inc

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,3 +459,16 @@ class AsymVisibility {
459459

460460
private(set) private bool $asymPrivate;
461461
}
462+
463+
abstract class PHP84AbstractProperties {
464+
abstract int $abstractA {get;}
465+
466+
/**
467+
* Docblock
468+
*/
469+
public abstract string $publicAbstract { set; }
470+
#[AnAttribute]
471+
abstract bool $abstractB {get;}
472+
473+
abstract protected bool $abstractProtected { set; }
474+
}

src/Standards/Squiz/Tests/WhiteSpace/MemberVarSpacingUnitTest.1.inc.fixed

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,3 +446,18 @@ class AsymVisibility {
446446

447447
private(set) private bool $asymPrivate;
448448
}
449+
450+
abstract class PHP84AbstractProperties {
451+
452+
abstract int $abstractA {get;}
453+
454+
/**
455+
* Docblock
456+
*/
457+
public abstract string $publicAbstract { set; }
458+
459+
#[AnAttribute]
460+
abstract bool $abstractB {get;}
461+
462+
abstract protected bool $abstractProtected { set; }
463+
}

src/Standards/Squiz/Tests/WhiteSpace/MemberVarSpacingUnitTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ public function getErrorList($testFile='')
9191
456 => 1,
9292
457 => 1,
9393
460 => 1,
94+
464 => 1,
95+
471 => 1,
9496
];
9597

9698
default:

0 commit comments

Comments
 (0)