Skip to content

Commit 86a52b1

Browse files
committed
refactor(rules): Rename 'implement' to 'nativeThrowable'
- Updated configuration and rule files to use 'nativeThrowable' instead of 'implement'. - Improved clarity in the code by using more descriptive terminology. - Ensured consistency across all related files for better maintainability.
1 parent d5e5e38 commit 86a52b1

File tree

4 files changed

+11
-11
lines changed

4 files changed

+11
-11
lines changed

config/rules.neon

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ parameters:
66
guanguans:
77
allRules: true
88
exceptionMustImplementNativeThrowable:
9-
implement: \Throwable
9+
nativeThrowable: \Throwable
1010
enabled: %guanguans.allRules%
1111

1212
parametersSchema:
1313
guanguans: structure([
1414
allRules: bool()
1515
exceptionMustImplementNativeThrowable: structure([
16-
implement: string()
16+
nativeThrowable: string()
1717
enabled: bool(),
1818
])
1919
])
@@ -22,4 +22,4 @@ services:
2222
-
2323
class: Guanguans\PHPStanRules\Rule\ExceptionMustImplementNativeThrowableRule
2424
arguments:
25-
implement: %guanguans.exceptionMustImplementNativeThrowable.implement%
25+
nativeThrowable: %guanguans.exceptionMustImplementNativeThrowable.nativeThrowable%

phpstan.neon.dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ parameters:
6363
enabled: false
6464
guanguans:
6565
exceptionMustImplementNativeThrowable:
66-
implement: Guanguans\PHPStanRules\Contract\ThrowableContract
66+
nativeThrowable: Guanguans\PHPStanRules\Contract\ThrowableContract
6767
enabled: false
6868
cognitive_complexity:
6969
class: 42

src/Rule/ExceptionMustImplementNativeThrowableRule.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,14 @@ final class ExceptionMustImplementNativeThrowableRule implements Rule
3232
{
3333
/** @api */
3434
public const ERROR_MESSAGE = 'The exception [%s] must implement the native throwable [%s].';
35-
private string $implement;
35+
private string $nativeThrowable;
3636

3737
/**
38-
* @param class-string<\Throwable> $implement
38+
* @param class-string<\Throwable> $nativeThrowable
3939
*/
40-
public function __construct(string $implement)
40+
public function __construct(string $nativeThrowable)
4141
{
42-
$this->implement = $implement;
42+
$this->nativeThrowable = $nativeThrowable;
4343
}
4444

4545
public function getNodeType(): string
@@ -58,7 +58,7 @@ public function processNode(Node $node, Scope $scope): array
5858
/** 暂不处理匿名类 `new class() extends Exception {}` 的情况. */
5959
!$node->class instanceof Name
6060
|| !is_subclass_of($class = $node->class->toString(), \Throwable::class)
61-
|| is_subclass_of($class, $this->implement)
61+
|| is_subclass_of($class, $this->nativeThrowable)
6262
) {
6363
return [];
6464
}
@@ -72,6 +72,6 @@ public function processNode(Node $node, Scope $scope): array
7272

7373
private function createErrorMessage(string $class): string
7474
{
75-
return \sprintf(self::ERROR_MESSAGE, $class, $this->implement);
75+
return \sprintf(self::ERROR_MESSAGE, $class, $this->nativeThrowable);
7676
}
7777
}

tests/Rule/ExceptionMustImplementNativeThrowableRule/config/configured_rule.neon

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ parameters:
55
guanguans:
66
allRules: false
77
exceptionMustImplementNativeThrowable:
8-
implement: Guanguans\PHPStanRules\Contract\ThrowableContract
8+
nativeThrowable: Guanguans\PHPStanRules\Contract\ThrowableContract
99
enabled: true

0 commit comments

Comments
 (0)