Skip to content

Commit 01ade6e

Browse files
committed
Simplify code thanks to BetterReflection update
1 parent d5a6a63 commit 01ade6e

File tree

3 files changed

+6
-33
lines changed

3 files changed

+6
-33
lines changed

src/Reflection/Php/PhpPropertyReflection.php

Lines changed: 3 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -234,14 +234,7 @@ public function isAbstract(): TrinaryLogic
234234

235235
public function isFinal(): TrinaryLogic
236236
{
237-
if ($this->reflection->isFinal()) {
238-
return TrinaryLogic::createYes();
239-
}
240-
if ($this->reflection->isPrivate()) {
241-
return TrinaryLogic::createNo();
242-
}
243-
244-
return TrinaryLogic::createFromBoolean($this->isPrivateSet());
237+
return TrinaryLogic::createFromBoolean($this->reflection->isFinal());
245238
}
246239

247240
public function isVirtual(): TrinaryLogic
@@ -277,32 +270,12 @@ public function getHook(string $hookType): ExtendedMethodReflection
277270

278271
public function isProtectedSet(): bool
279272
{
280-
if ($this->reflection->isProtectedSet()) {
281-
return true;
282-
}
283-
284-
if ($this->isReadOnly()) {
285-
return !$this->isPrivate() && !$this->reflection->isPrivateSet();
286-
}
287-
288-
return false;
273+
return $this->reflection->isProtectedSet();
289274
}
290275

291276
public function isPrivateSet(): bool
292277
{
293-
if ($this->reflection->isPrivateSet()) {
294-
return true;
295-
}
296-
297-
if ($this->reflection->isProtectedSet()) {
298-
return false;
299-
}
300-
301-
if ($this->isReadOnly()) {
302-
return $this->isPrivate();
303-
}
304-
305-
return false;
278+
return $this->reflection->isPrivateSet();
306279
}
307280

308281
}

tests/PHPStan/Rules/Properties/AccessPropertiesInAssignRuleTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,11 +150,11 @@ public function testAsymmetricVisibility(): void
150150
70,
151151
],
152152
[
153-
'Assign to protected(set) property WriteAsymmetricVisibility\ReadonlyProps::$b.',
153+
'Access to protected property WriteAsymmetricVisibility\ReadonlyProps::$b.',
154154
71,
155155
],
156156
[
157-
'Assign to private(set) property WriteAsymmetricVisibility\ReadonlyProps::$c.',
157+
'Access to private property WriteAsymmetricVisibility\ReadonlyProps::$c.',
158158
72,
159159
],
160160
[

tests/PHPStan/Rules/Properties/PropertyAssignRefRuleTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public function testRule(): void
2626

2727
$this->analyse([__DIR__ . '/data/property-assign-ref.php'], [
2828
[
29-
'Property PropertyAssignRef\Foo::$foo with private(set) visibility is assigned by reference.',
29+
'Property PropertyAssignRef\Foo::$foo with private visibility is assigned by reference.',
3030
25,
3131
],
3232
[

0 commit comments

Comments
 (0)