Skip to content

PHP 8.4 | Various sniffs: add tests with final properties #952

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

Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,25 @@ class Regular_Class_Regular_Constants {
protected const PROTECTED_CONST = 'foo';
private const PRIVATE_CONST = true;
}

final class Final_Class_Final_Properties {
final readonly public ?MyType $final_public;
protected final $final_protected = 'foo';
}

final class Final_Class_Regular_Properties {
public $public = 23;
protected string $protected = 'foo';
private $private = true;
}

class Regular_Class_Final_Properties {
public static final $final_public = 23;
final readonly $final_protected = 'foo';
}

class Regular_Class_Regular_Properties {
public $public = 23;
protected $protected = 'foo';
private static bool $private = true;
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ public function getWarningList($testFile='')
33 => 1,
37 => 1,
38 => 1,
59 => 1,
60 => 1,
];
default:
return [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,7 @@ ReadOnly class MyClass
$a = new CLASS() {};

$anon = new ReadOnly class() {};

class FinalProperties {
FINAL int $prop = 1;
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,7 @@ readonly class MyClass
$a = new class() {};

$anon = new readonly class() {};

class FinalProperties {
final int $prop = 1;
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public function getErrorList()
11 => 1,
14 => 1,
16 => 1,
19 => 1,
];

return $errors;
Expand Down
7 changes: 7 additions & 0 deletions src/Standards/Squiz/Tests/Commenting/BlockCommentUnitTest.inc
Original file line number Diff line number Diff line change
Expand Up @@ -307,3 +307,10 @@ abstract class MyClass
enum MyEnum {

}

class FinalProperties {
/**
* Comment should be ignored.
*/
final int $prop = 1;
}
Original file line number Diff line number Diff line change
Expand Up @@ -309,3 +309,10 @@ abstract class MyClass
enum MyEnum {

}

class FinalProperties {
/**
* Comment should be ignored.
*/
final int $prop = 1;
}
4 changes: 4 additions & 0 deletions src/Standards/Squiz/Tests/Scope/MemberVarScopeUnitTest.inc
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,7 @@ class MyClass {
interface Base {
protected $anonymous;
}

class PHP84FinalProperties {
final int $final;
}
1 change: 1 addition & 0 deletions src/Standards/Squiz/Tests/Scope/MemberVarScopeUnitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public function getErrorList()
41 => 1,
66 => 2,
67 => 1,
75 => 1,
];

}//end getErrorList()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -415,3 +415,16 @@ final class BlankLinesBetweenVsAttributesWithoutCommentIssueSquiz3594

public $property2;
}

class PHP84FinalProperties {
final int $finalA;

/**
* Docblock
*/
public final string $publicfinal;
#[AnAttribute]
final bool $finalB;

final private bool $finalPrivate;
}
Original file line number Diff line number Diff line change
Expand Up @@ -400,3 +400,18 @@ final class BlankLinesBetweenVsAttributesWithoutCommentIssueSquiz3594
#[SingleAttribute]
public $property2;
}

class PHP84FinalProperties {

final int $finalA;

/**
* Docblock
*/
public final string $publicfinal;

#[AnAttribute]
final bool $finalB;

final private bool $finalPrivate;
}
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ public function getErrorList($testFile='')
412 => 1,
415 => 1,
416 => 1,
420 => 1,
427 => 1,
];

default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,3 +187,8 @@ class ConstantVisibility {
protected const PROTECTED_SPACING_INCORRECT = true;
private const PRIVATE_SPACING_INCORRECT = true;
}

class FinalProperties {
final readonly public ?MyType $spacing_correct;
protected final $spacing_incorrect = 'foo';
}
Original file line number Diff line number Diff line change
Expand Up @@ -180,3 +180,8 @@ class ConstantVisibility {
protected const PROTECTED_SPACING_INCORRECT = true;
private const PRIVATE_SPACING_INCORRECT = true;
}

class FinalProperties {
final readonly public ?MyType $spacing_correct;
protected final $spacing_incorrect = 'foo';
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ public function getErrorList($testFile='')
186 => 1,
187 => 1,
188 => 1,
193 => 2,
];

case 'ScopeKeywordSpacingUnitTest.3.inc':
Expand Down