Skip to content
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

Generic/UnnecessaryFinalModifier: improve code coverage #241

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 @@ -32,3 +32,25 @@ final readonly class Foo_Bar {
public final function fooBar() {}
final protected function fool() {}
}

final class Final_Class_Final_Constants {
final public const FINAL_PUBLIC_CONST = 23;
protected final const FINAL_PROTECTED_CONST = 'foo';
}

final class Final_Class_Regular_Constants {
public const PUBLIC_CONST = 23;
protected const PROTECTED_CONST = 'foo';
private const PRIVATE_CONST = true;
}

class Regular_Class_Final_Constants {
public final const FINAL_PUBLIC_CONST = 23;
final protected const FINAL_PROTECTED_CONST = 'foo';
}

class Regular_Class_Regular_Constants {
public const PUBLIC_CONST = 23;
protected const PROTECTED_CONST = 'foo';
private const PRIVATE_CONST = true;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php

// Intentional parse error (class without body). Testing that the sniff is *not* triggered
// in this case.
final class Missing_Body
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,27 @@ public function getErrorList()
* The key of the array should represent the line number and the value
* should represent the number of warnings that should occur on that line.
*
* @param string $testFile The name of the test file being tested.
*
* @return array<int, int>
*/
public function getWarningList()
public function getWarningList($testFile='')
{
return [
11 => 1,
12 => 1,
15 => 1,
18 => 1,
32 => 1,
33 => 1,
];
switch ($testFile) {
case 'UnnecessaryFinalModifierUnitTest.1.inc':
return [
11 => 1,
12 => 1,
15 => 1,
18 => 1,
32 => 1,
33 => 1,
37 => 1,
38 => 1,
];
default:
return [];
}

}//end getWarningList()

Expand Down