File tree Expand file tree Collapse file tree 2 files changed +20
-5
lines changed Expand file tree Collapse file tree 2 files changed +20
-5
lines changed Original file line number Diff line number Diff line change @@ -252,10 +252,7 @@ public static function createEmpty(): self
252252 */
253253 public function merge (array $ parents , array $ parentPhpDocBlocks ): self
254254 {
255- $ className = $ this ->nameScope !== null ? $ this ->nameScope ->getClassName () : null ;
256- $ classReflection = $ className !== null && $ this ->reflectionProvider ->hasClass ($ className )
257- ? $ this ->reflectionProvider ->getClass ($ className )
258- : null ;
255+ $ classReflection = $ this ->getClassReflection ();
259256
260257 // new property also needs to be added to createEmpty()
261258 $ result = new self ();
@@ -461,6 +458,16 @@ public function getNullableNameScope(): ?NameScope
461458 return $ this ->nameScope ;
462459 }
463460
461+ private function getClassReflection (): ?ClassReflection
462+ {
463+ $ className = $ this ->nameScope ?->getClassName();
464+ if ($ className === null || !$ this ->reflectionProvider ->hasClass ($ className )) {
465+ return null ;
466+ }
467+
468+ return $ this ->reflectionProvider ->getClass ($ className );
469+ }
470+
464471 /**
465472 * @return array<(string|int), VarTag>
466473 */
@@ -827,6 +834,14 @@ public function isPure(): ?bool
827834 return $ this ->isPure ;
828835 }
829836
837+ if ($ this ->nameScope !== null ) {
838+ $ classReflection = $ this ->getClassReflection ();
839+ if ($ classReflection !== null ) {
840+ $ this ->isPure = $ classReflection ->getDefaultMethodPurity ();
841+ return $ this ->isPure ;
842+ }
843+ }
844+
830845 $ this ->isPure = null ;
831846 }
832847
Original file line number Diff line number Diff line change @@ -892,7 +892,7 @@ public function createUserlandMethodReflection(ClassReflection $fileDeclaringCla
892892 }
893893 }
894894
895- $ isPure ??= $ resolvedPhpDoc ->isPure () ?? $ phpDocBlockClassReflection -> getDefaultMethodPurity () ;
895+ $ isPure ??= $ resolvedPhpDoc ->isPure ();
896896 $ asserts = Assertions::createFromResolvedPhpDocBlock ($ resolvedPhpDoc );
897897 $ acceptsNamedArguments = $ resolvedPhpDoc ->acceptsNamedArguments ();
898898 $ selfOutType = $ resolvedPhpDoc ->getSelfOutTag () !== null ? $ resolvedPhpDoc ->getSelfOutTag ()->getType () : null ;
You can’t perform that action at this time.
0 commit comments