diff --git a/demo/auto/AutoValue_Address.php b/demo/auto/AutoValue_Address.php index 23f668c..89e67d4 100644 --- a/demo/auto/AutoValue_Address.php +++ b/demo/auto/AutoValue_Address.php @@ -108,10 +108,7 @@ public function foo() public function linesString(): string { - if (!isset($this->__memoized['linesString'])) { - $this->__memoized['linesString'] = parent::linesString(); - } - return $this->__memoized['linesString']; + return $this->__memoized['linesString'] ?? ($this->__memoized['linesString'] = parent::linesString()); } /** diff --git a/src/Memoize/MemoizeMethodProcessor.php b/src/Memoize/MemoizeMethodProcessor.php index fdde541..0549210 100644 --- a/src/Memoize/MemoizeMethodProcessor.php +++ b/src/Memoize/MemoizeMethodProcessor.php @@ -42,10 +42,7 @@ function (MethodDefinitionCollection $methodDefinitions, ReflectionMethod $metho THEPHP; } else { $methodBody = <<__memoized['$methodName'])) { - \$this->__memoized['$methodName'] = parent::$methodName(); - } - return \$this->__memoized['$methodName']; + return \$this->__memoized['$methodName'] ?? (\$this->__memoized['$methodName'] = parent::$methodName()); THEPHP; } return $methodDefinitions->withAdditionalMethodDefinition(MethodDefinition::of($method, $methodBody));