Skip to content

Commit e84de7f

Browse files
authored
Merge pull request #952 from PHPCSStandards/php84/feature/various-sniffs-add-tests-with-final-properties
PHP 8.4 | Various sniffs: add tests with final properties
2 parents 5946d53 + 228605e commit e84de7f

15 files changed

+93
-0
lines changed

src/Standards/Generic/Tests/CodeAnalysis/UnnecessaryFinalModifierUnitTest.1.inc

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,25 @@ class Regular_Class_Regular_Constants {
5454
protected const PROTECTED_CONST = 'foo';
5555
private const PRIVATE_CONST = true;
5656
}
57+
58+
final class Final_Class_Final_Properties {
59+
final readonly public ?MyType $final_public;
60+
protected final $final_protected = 'foo';
61+
}
62+
63+
final class Final_Class_Regular_Properties {
64+
public $public = 23;
65+
protected string $protected = 'foo';
66+
private $private = true;
67+
}
68+
69+
class Regular_Class_Final_Properties {
70+
public static final $final_public = 23;
71+
final readonly $final_protected = 'foo';
72+
}
73+
74+
class Regular_Class_Regular_Properties {
75+
public $public = 23;
76+
protected $protected = 'foo';
77+
private static bool $private = true;
78+
}

src/Standards/Generic/Tests/CodeAnalysis/UnnecessaryFinalModifierUnitTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ public function getWarningList($testFile='')
5858
33 => 1,
5959
37 => 1,
6060
38 => 1,
61+
59 => 1,
62+
60 => 1,
6163
];
6264
default:
6365
return [];

src/Standards/Squiz/Tests/Classes/LowercaseClassKeywordsUnitTest.inc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,7 @@ ReadOnly class MyClass
1414
$a = new CLASS() {};
1515

1616
$anon = new ReadOnly class() {};
17+
18+
class FinalProperties {
19+
FINAL int $prop = 1;
20+
}

src/Standards/Squiz/Tests/Classes/LowercaseClassKeywordsUnitTest.inc.fixed

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,7 @@ readonly class MyClass
1414
$a = new class() {};
1515

1616
$anon = new readonly class() {};
17+
18+
class FinalProperties {
19+
final int $prop = 1;
20+
}

src/Standards/Squiz/Tests/Classes/LowercaseClassKeywordsUnitTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ public function getErrorList()
4141
11 => 1,
4242
14 => 1,
4343
16 => 1,
44+
19 => 1,
4445
];
4546

4647
return $errors;

src/Standards/Squiz/Tests/Commenting/BlockCommentUnitTest.inc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,3 +307,10 @@ abstract class MyClass
307307
enum MyEnum {
308308

309309
}
310+
311+
class FinalProperties {
312+
/**
313+
* Comment should be ignored.
314+
*/
315+
final int $prop = 1;
316+
}

src/Standards/Squiz/Tests/Commenting/BlockCommentUnitTest.inc.fixed

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,3 +309,10 @@ abstract class MyClass
309309
enum MyEnum {
310310

311311
}
312+
313+
class FinalProperties {
314+
/**
315+
* Comment should be ignored.
316+
*/
317+
final int $prop = 1;
318+
}

src/Standards/Squiz/Tests/Scope/MemberVarScopeUnitTest.inc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,7 @@ class MyClass {
7070
interface Base {
7171
protected $anonymous;
7272
}
73+
74+
class PHP84FinalProperties {
75+
final int $final;
76+
}

src/Standards/Squiz/Tests/Scope/MemberVarScopeUnitTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ public function getErrorList()
3939
41 => 1,
4040
66 => 2,
4141
67 => 1,
42+
75 => 1,
4243
];
4344

4445
}//end getErrorList()

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,3 +415,16 @@ final class BlankLinesBetweenVsAttributesWithoutCommentIssueSquiz3594
415415

416416
public $property2;
417417
}
418+
419+
class PHP84FinalProperties {
420+
final int $finalA;
421+
422+
/**
423+
* Docblock
424+
*/
425+
public final string $publicfinal;
426+
#[AnAttribute]
427+
final bool $finalB;
428+
429+
final private bool $finalPrivate;
430+
}

0 commit comments

Comments
 (0)