Skip to content

Commit 57f52e6

Browse files
committed
DeprecatableReflection::getDeprecatedDescription() is already available on the interface
1 parent 48be9c9 commit 57f52e6

12 files changed

+14
-69
lines changed

src/Rules/Deprecations/AccessDeprecatedPropertyRule.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,7 @@ public function processNode(Node $node, Scope $scope): array
5555
}
5656

5757
if ($propertyReflection->isDeprecated()) {
58-
$description = null;
59-
if (method_exists($propertyReflection, 'getDeprecatedDescription')) {
60-
$description = $propertyReflection->getDeprecatedDescription();
61-
}
62-
58+
$description = $propertyReflection->getDeprecatedDescription();
6359
if ($description === null) {
6460
return [sprintf(
6561
'Access to deprecated property $%s of class %s.',

src/Rules/Deprecations/AccessDeprecatedStaticPropertyRule.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,7 @@ function (Type $type) use ($propertyName): bool {
8181
}
8282

8383
if ($property instanceof DeprecatableReflection && $property->isDeprecated()) {
84-
$description = null;
85-
if (method_exists($property, 'getDeprecatedDescription')) {
86-
$description = $property->getDeprecatedDescription();
87-
}
88-
84+
$description = $property->getDeprecatedDescription();
8985
if ($description === null) {
9086
return [sprintf(
9187
'Access to deprecated static property $%s of class %s.',

src/Rules/Deprecations/CallToDeprecatedFunctionRule.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,7 @@ public function processNode(Node $node, Scope $scope): array
4646
}
4747

4848
if ($function->isDeprecated()) {
49-
$description = null;
50-
if (method_exists($function, 'getDeprecatedDescription')) {
51-
$description = $function->getDeprecatedDescription();
52-
}
53-
49+
$description = $function->getDeprecatedDescription();
5450
if ($description === null) {
5551
return [sprintf(
5652
'Call to deprecated function %s().',

src/Rules/Deprecations/CallToDeprecatedMethodRule.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,7 @@ public function processNode(Node $node, Scope $scope): array
5858
continue;
5959
}
6060

61-
$description = null;
62-
if (method_exists($methodReflection, 'getDeprecatedDescription')) {
63-
$description = $methodReflection->getDeprecatedDescription();
64-
}
65-
61+
$description = $methodReflection->getDeprecatedDescription();
6662
if ($description === null) {
6763
return [sprintf(
6864
'Call to deprecated method %s() of class %s.',

src/Rules/Deprecations/CallToDeprecatedStaticMethodRule.php

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,7 @@ function (Type $type) use ($methodName): bool {
8383
}
8484

8585
if ($class->isDeprecated()) {
86-
$classDescription = null;
87-
if (method_exists($class, 'getDeprecatedDescription')) {
88-
$classDescription = $class->getDeprecatedDescription();
89-
}
90-
86+
$classDescription = $class->getDeprecatedDescription();
9187
if ($classDescription === null) {
9288
$errors[] = sprintf(
9389
'Call to method %s() of deprecated class %s.',
@@ -108,11 +104,7 @@ function (Type $type) use ($methodName): bool {
108104
continue;
109105
}
110106

111-
$description = null;
112-
if (method_exists($methodReflection, 'getDeprecatedDescription')) {
113-
$description = $methodReflection->getDeprecatedDescription();
114-
}
115-
107+
$description = $methodReflection->getDeprecatedDescription();
116108
if ($description === null) {
117109
$errors[] = sprintf(
118110
'Call to deprecated method %s() of class %s.',

src/Rules/Deprecations/FetchingClassConstOfDeprecatedClassRule.php

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,7 @@ function (Type $type) use ($constantName): bool {
8080
}
8181

8282
if ($class->isDeprecated()) {
83-
$classDescription = null;
84-
if (method_exists($class, 'getDeprecatedDescription')) {
85-
$classDescription = $class->getDeprecatedDescription();
86-
}
87-
83+
$classDescription = $class->getDeprecatedDescription();
8884
if ($classDescription === null) {
8985
$errors[] = sprintf(
9086
'Fetching class constant %s of deprecated class %s.',
@@ -111,11 +107,7 @@ function (Type $type) use ($constantName): bool {
111107
continue;
112108
}
113109

114-
$description = null;
115-
if (method_exists($constantReflection, 'getDeprecatedDescription')) {
116-
$description = $constantReflection->getDeprecatedDescription();
117-
}
118-
110+
$description = $constantReflection->getDeprecatedDescription();
119111
if ($description === null) {
120112
$errors[] = sprintf(
121113
'Fetching deprecated class constant %s of class %s.',

src/Rules/Deprecations/ImplementationOfDeprecatedInterfaceRule.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,7 @@ public function processNode(Node $node, Scope $scope): array
5757
$interface = $this->broker->getClass($interfaceName);
5858

5959
if ($interface->isDeprecated()) {
60-
$description = null;
61-
if (method_exists($interface, 'getDeprecatedDescription')) {
62-
$description = $interface->getDeprecatedDescription();
63-
}
60+
$description = $interface->getDeprecatedDescription();
6461
if (!$class->isAnonymous()) {
6562
if ($description === null) {
6663
$errors[] = sprintf(

src/Rules/Deprecations/InheritanceOfDeprecatedClassRule.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,7 @@ public function processNode(Node $node, Scope $scope): array
5454

5555
try {
5656
$parentClass = $this->broker->getClass($parentClassName);
57-
$description = null;
58-
if (method_exists($parentClass, 'getDeprecatedDescription')) {
59-
$description = $parentClass->getDeprecatedDescription();
60-
}
61-
57+
$description = $parentClass->getDeprecatedDescription();
6258
if ($parentClass->isDeprecated()) {
6359
if (!$class->isAnonymous()) {
6460
if ($description === null) {

src/Rules/Deprecations/InheritanceOfDeprecatedInterfaceRule.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,7 @@ public function processNode(Node $node, Scope $scope): array
6060
continue;
6161
}
6262

63-
$description = null;
64-
if (method_exists($parentInterface, 'getDeprecatedDescription')) {
65-
$description = $parentInterface->getDeprecatedDescription();
66-
}
67-
63+
$description = $parentInterface->getDeprecatedDescription();
6864
if ($description === null) {
6965
$errors[] = sprintf(
7066
'Interface %s extends deprecated interface %s.',

src/Rules/Deprecations/InstantiationOfDeprecatedClassRule.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,7 @@ function (): bool {
8282
continue;
8383
}
8484

85-
$description = null;
86-
if (method_exists($class, 'getDeprecatedDescription')) {
87-
$description = $class->getDeprecatedDescription();
88-
}
89-
85+
$description = $class->getDeprecatedDescription();
9086
if ($description === null) {
9187
$errors[] = sprintf(
9288
'Instantiation of deprecated class %s.',

0 commit comments

Comments
 (0)