Skip to content

Commit 9846969

Browse files
phpstan-botclaude
andcommitted
Refactor boolean condition in isset check for promoted properties
Apply De Morgan's law to improve readability: - `!($a && ($b || $c))` → `(!$a || (!$b && !$c))` Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 984ecd5 commit 9846969

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

src/Analyser/MutatingScope.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1069,7 +1069,7 @@ public function issetCheck(Expr $expr, callable $typeCallback, ?bool $result = n
10691069
if ($propertyReflection->hasNativeType() && !$propertyReflection->isVirtual()->yes()) {
10701070
if (!$this->hasExpressionType($expr)->yes()) {
10711071
$nativeReflection = $propertyReflection->getNativeReflection();
1072-
if ($nativeReflection === null || !($nativeReflection->isPromoted() && ($nativeReflection->isReadOnly() || $nativeReflection->isHooked()))) {
1072+
if ($nativeReflection === null || !$nativeReflection->isPromoted() || (!$nativeReflection->isReadOnly() && !$nativeReflection->isHooked())) {
10731073
if ($expr instanceof Node\Expr\PropertyFetch) {
10741074
return $this->issetCheckUndefined($expr->var);
10751075
}

src/Rules/IssetCheck.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ static function (Type $type) use ($typeMessageCallback): ?string {
186186
if (
187187
$nativeReflection !== null
188188
&& !$nativeReflection->getNativeReflection()->hasDefaultValue()
189-
&& !($nativeReflection->isPromoted() && ($nativeReflection->isReadOnly() || $nativeReflection->isHooked()))
189+
&& (!$nativeReflection->isPromoted() || (!$nativeReflection->isReadOnly() && !$nativeReflection->isHooked()))
190190
) {
191191
return null;
192192
}

0 commit comments

Comments
 (0)