@@ -139,8 +139,9 @@ final class ResolvedPhpDocBlock
139139/** @var bool|'notLoaded'|null */
140140private bool |string |null $ isPure = 'notLoaded ' ;
141141
142- /** @var bool|'notLoaded'|null */
143- private bool |string |null $ defaultMethodPurity = 'notLoaded ' ;
142+ private ?bool $ areAllMethodsPure = null ;
143+
144+ private ?bool $ areAllMethodsImpure = null ;
144145
145146private ?bool $ isReadOnly = null ;
146147
@@ -236,7 +237,8 @@ public static function createEmpty(): self
236237$ self ->isInternal = false ;
237238$ self ->isFinal = false ;
238239$ self ->isPure = null ;
239- $ self ->defaultMethodPurity = null ;
240+ $ self ->areAllMethodsPure = false ;
241+ $ self ->areAllMethodsImpure = false ;
240242$ self ->isReadOnly = false ;
241243$ self ->isImmutable = false ;
242244$ self ->isAllowedPrivateMutation = false ;
@@ -302,7 +304,8 @@ public function merge(array $parents, array $parentPhpDocBlocks): self
302304$ result ->isInternal = $ this ->isInternal ();
303305$ result ->isFinal = $ this ->isFinal ();
304306$ result ->isPure = self ::mergePureTags ($ this ->isPure (), $ parents );
305- $ result ->defaultMethodPurity = $ this ->getDefaultMethodPurity ();
307+ $ result ->areAllMethodsPure = $ this ->areAllMethodsPure ();
308+ $ result ->areAllMethodsImpure = $ this ->areAllMethodsImpure ();
306309$ result ->isReadOnly = $ this ->isReadOnly ();
307310$ result ->isImmutable = $ this ->isImmutable ();
308311$ result ->isAllowedPrivateMutation = $ this ->isAllowedPrivateMutation ();
@@ -423,7 +426,6 @@ public function changeParameterNamesByMapping(array $parameterNameMapping): self
423426$ self ->isInternal = $ this ->isInternal ;
424427$ self ->isFinal = $ this ->isFinal ;
425428$ self ->isPure = $ this ->isPure ;
426- $ self ->defaultMethodPurity = $ this ->defaultMethodPurity ;
427429
428430return $ self ;
429431}
@@ -833,29 +835,18 @@ public function isPure(): ?bool
833835return $ this ->isPure ;
834836}
835837
836- public function getDefaultMethodPurity (): ? bool
838+ public function areAllMethodsPure (): bool
837839{
838- if ($ this ->defaultMethodPurity === 'notLoaded ' ) {
839- $ pure = $ this ->phpDocNodeResolver ->resolveAllMethodsArePure (
840- $ this ->phpDocNode ,
841- );
842- if ($ pure ) {
843- $ this ->defaultMethodPurity = true ;
844- return $ this ->defaultMethodPurity ;
845- }
846-
847- $ impure = $ this ->phpDocNodeResolver ->resolveAllMethodsAreImpure (
848- $ this ->phpDocNode ,
849- );
850- if ($ impure ) {
851- $ this ->defaultMethodPurity = false ;
852- return $ this ->defaultMethodPurity ;
853- }
854-
855- $ this ->defaultMethodPurity = null ;
856- }
840+ return $ this ->areAllMethodsPure ??= $ this ->phpDocNodeResolver ->resolveAllMethodsPure (
841+ $ this ->phpDocNode ,
842+ );
843+ }
857844
858- return $ this ->defaultMethodPurity ;
845+ public function areAllMethodsImpure (): bool
846+ {
847+ return $ this ->areAllMethodsImpure ??= $ this ->phpDocNodeResolver ->resolveAllMethodsImpure (
848+ $ this ->phpDocNode ,
849+ );
859850}
860851
861852public function isReadOnly (): bool
0 commit comments