Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
wip
  • Loading branch information
zonuexe committed Aug 1, 2025
commit e4e54cb87979a99832261ce73b744e217cf1ff77
5 changes: 5 additions & 0 deletions src/Reflection/Annotations/AnnotationMethodReflection.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,11 @@ public function isPure(): TrinaryLogic
return TrinaryLogic::createMaybe();
}

public function getPureUnlessCallableIsImpureParameters(): array
{
return [];
}

public function getAttributes(): array
{
return [];
Expand Down
5 changes: 5 additions & 0 deletions src/Reflection/Dummy/ChangedTypeMethodReflection.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,11 @@ public function isPure(): TrinaryLogic
return $this->reflection->isPure();
}

public function getPureUnlessCallableIsImpureParameters(): array
{
return [];
}

public function getAttributes(): array
{
return $this->reflection->getAttributes();
Expand Down
5 changes: 5 additions & 0 deletions src/Reflection/Dummy/DummyConstructorReflection.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,11 @@ public function isPure(): TrinaryLogic
return TrinaryLogic::createYes();
}

public function getPureUnlessCallableIsImpureParameters(): array
{
return [];
}

public function getAttributes(): array
{
return [];
Expand Down
5 changes: 5 additions & 0 deletions src/Reflection/Dummy/DummyMethodReflection.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,11 @@ public function isPure(): TrinaryLogic
return TrinaryLogic::createMaybe();
}

public function getPureUnlessCallableIsImpureParameters(): array
{
return [];
}

public function getAttributes(): array
{
return [];
Expand Down
5 changes: 5 additions & 0 deletions src/Reflection/ExtendedMethodReflection.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ public function isBuiltin(): TrinaryLogic|bool;
*/
public function isPure(): TrinaryLogic;

/**
* @return array<string, bool>
*/
public function getPureUnlessCallableIsImpureParameters(): array;

/**
* @return list<AttributeReflection>
*/
Expand Down
5 changes: 5 additions & 0 deletions src/Reflection/FunctionReflection.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ public function returnsByReference(): TrinaryLogic;
*/
public function isPure(): TrinaryLogic;

/**
* @return array<string, bool>
*/
public function getPureUnlessCallableIsImpureParameters(): array;

/**
* @return list<AttributeReflection>
*/
Expand Down
5 changes: 5 additions & 0 deletions src/Reflection/Native/NativeFunctionReflection.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,11 @@ public function isPure(): TrinaryLogic
return $this->hasSideEffects->negate();
}

public function getPureUnlessCallableIsImpureParameters(): array
{
return [];
}

private function isVoid(): bool
{
foreach ($this->variants as $variant) {
Expand Down
5 changes: 5 additions & 0 deletions src/Reflection/Native/NativeMethodReflection.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,11 @@ public function isPure(): TrinaryLogic
return $this->hasSideEffects->negate();
}

public function getPureUnlessCallableIsImpureParameters(): array
{
return [];
}

private function isVoid(): bool
{
foreach ($this->variants as $variant) {
Expand Down
5 changes: 5 additions & 0 deletions src/Reflection/Php/ClosureCallMethodReflection.php
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,11 @@ public function isPure(): TrinaryLogic
return $this->nativeMethodReflection->isPure();
}

public function getPureUnlessCallableIsImpureParameters(): array
{
return [];
}

public function getAttributes(): array
{
return $this->nativeMethodReflection->getAttributes();
Expand Down
5 changes: 5 additions & 0 deletions src/Reflection/Php/EnumCasesMethodReflection.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,11 @@ public function isPure(): TrinaryLogic
return TrinaryLogic::createYes();
}

public function getPureUnlessCallableIsImpureParameters(): array
{
return [];
}

public function getAttributes(): array
{
return [];
Expand Down
5 changes: 5 additions & 0 deletions src/Reflection/Php/ExitFunctionReflection.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,11 @@ public function isPure(): TrinaryLogic
return TrinaryLogic::createNo();
}

public function getPureUnlessCallableIsImpureParameters(): array
{
return [];
}

public function getAttributes(): array
{
return [];
Expand Down
6 changes: 5 additions & 1 deletion src/Reflection/Php/PhpClassReflectionExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -840,10 +840,13 @@ public function createUserlandMethodReflection(ClassReflection $fileDeclaringCla
$isInternal = $resolvedPhpDoc->isInternal();
$isFinal = $resolvedPhpDoc->isFinal();
$isPure = null;
$pureUnlessCallableIsImpureParameters = [];
foreach ($actualDeclaringClass->getAncestors() as $className => $ancestor) {
if ($this->signatureMapProvider->hasMethodMetadata($className, $methodReflection->getName())) {
$hasSideEffects = $this->signatureMapProvider->getMethodMetadata($className, $methodReflection->getName())['hasSideEffects'] ?? true;
$methodMetadata = $this->signatureMapProvider->getMethodMetadata($className, $methodReflection->getName());
$hasSideEffects = $methodMetadata['hasSideEffects'] ?? true;
$isPure = !$hasSideEffects;
$pureUnlessCallableIsImpureParameters += $methodMetadata['pureUnlessCallableIsImpureParameters'] ?? [];

break;
}
Expand Down Expand Up @@ -879,6 +882,7 @@ public function createUserlandMethodReflection(ClassReflection $fileDeclaringCla
$closureThisParameters,
$acceptsNamedArguments,
$this->attributeReflectionFactory->fromNativeReflection($methodReflection->getAttributes(), InitializerExprContext::fromClassMethod($actualDeclaringClass->getName(), $declaringTraitName, $methodReflection->getName(), $actualDeclaringClass->getFileName())),
$pureUnlessCallableIsImpureParameters,
);
}

Expand Down
5 changes: 5 additions & 0 deletions src/Reflection/Php/PhpFunctionFromParserNodeReflection.php
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,11 @@ public function isPure(): TrinaryLogic
return TrinaryLogic::createFromBoolean($this->isPure);
}

public function getPureUnlessCallableIsImpureParameters(): array
{
return [];
}

public function getAttributes(): array
{
return $this->attributes;
Expand Down
5 changes: 5 additions & 0 deletions src/Reflection/Php/PhpFunctionReflection.php
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,11 @@ public function isPure(): TrinaryLogic
return TrinaryLogic::createFromBoolean($this->isPure);
}

public function getPureUnlessCallableIsImpureParameters(): array
{
return [];
}

public function isBuiltin(): bool
{
return $this->reflection->isInternal();
Expand Down
8 changes: 8 additions & 0 deletions src/Reflection/Php/PhpMethodReflection.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
* @param array<string, Type> $phpDocClosureThisTypeParameters
* @param list<AttributeReflection> $attributes
*/
public function __construct(

Check failure on line 74 in src/Reflection/Php/PhpMethodReflection.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.2, ubuntu-latest)

Method PHPStan\Reflection\Php\PhpMethodReflection::__construct() has parameter $pureUnlessCallableIsImpureParameters with no value type specified in iterable type array.

Check failure on line 74 in src/Reflection/Php/PhpMethodReflection.php

View workflow job for this annotation

GitHub Actions / PHPStan with result cache (8.2)

Method PHPStan\Reflection\Php\PhpMethodReflection::__construct() has parameter $pureUnlessCallableIsImpureParameters with no value type specified in iterable type array.

Check failure on line 74 in src/Reflection/Php/PhpMethodReflection.php

View workflow job for this annotation

GitHub Actions / PHPStan with result cache (8.5)

Method PHPStan\Reflection\Php\PhpMethodReflection::__construct() has parameter $pureUnlessCallableIsImpureParameters with no value type specified in iterable type array.

Check failure on line 74 in src/Reflection/Php/PhpMethodReflection.php

View workflow job for this annotation

GitHub Actions / PHPStan with result cache (8.3)

Method PHPStan\Reflection\Php\PhpMethodReflection::__construct() has parameter $pureUnlessCallableIsImpureParameters with no value type specified in iterable type array.

Check failure on line 74 in src/Reflection/Php/PhpMethodReflection.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.4, ubuntu-latest)

Method PHPStan\Reflection\Php\PhpMethodReflection::__construct() has parameter $pureUnlessCallableIsImpureParameters with no value type specified in iterable type array.

Check failure on line 74 in src/Reflection/Php/PhpMethodReflection.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.3, ubuntu-latest)

Method PHPStan\Reflection\Php\PhpMethodReflection::__construct() has parameter $pureUnlessCallableIsImpureParameters with no value type specified in iterable type array.

Check failure on line 74 in src/Reflection/Php/PhpMethodReflection.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.5, ubuntu-latest)

Method PHPStan\Reflection\Php\PhpMethodReflection::__construct() has parameter $pureUnlessCallableIsImpureParameters with no value type specified in iterable type array.

Check failure on line 74 in src/Reflection/Php/PhpMethodReflection.php

View workflow job for this annotation

GitHub Actions / PHPStan with result cache (8.4)

Method PHPStan\Reflection\Php\PhpMethodReflection::__construct() has parameter $pureUnlessCallableIsImpureParameters with no value type specified in iterable type array.

Check failure on line 74 in src/Reflection/Php/PhpMethodReflection.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.1, ubuntu-latest)

Method PHPStan\Reflection\Php\PhpMethodReflection::__construct() has parameter $pureUnlessCallableIsImpureParameters with no value type specified in iterable type array.

Check failure on line 74 in src/Reflection/Php/PhpMethodReflection.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.0, ubuntu-latest)

Method PHPStan\Reflection\Php\PhpMethodReflection::__construct() has parameter $pureUnlessCallableIsImpureParameters with no value type specified in iterable type array.

Check failure on line 74 in src/Reflection/Php/PhpMethodReflection.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.2, windows-latest)

Method PHPStan\Reflection\Php\PhpMethodReflection::__construct() has parameter $pureUnlessCallableIsImpureParameters with no value type specified in iterable type array.

Check failure on line 74 in src/Reflection/Php/PhpMethodReflection.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.4, windows-latest)

Method PHPStan\Reflection\Php\PhpMethodReflection::__construct() has parameter $pureUnlessCallableIsImpureParameters with no value type specified in iterable type array.

Check failure on line 74 in src/Reflection/Php/PhpMethodReflection.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.5, windows-latest)

Method PHPStan\Reflection\Php\PhpMethodReflection::__construct() has parameter $pureUnlessCallableIsImpureParameters with no value type specified in iterable type array.

Check failure on line 74 in src/Reflection/Php/PhpMethodReflection.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.3, windows-latest)

Method PHPStan\Reflection\Php\PhpMethodReflection::__construct() has parameter $pureUnlessCallableIsImpureParameters with no value type specified in iterable type array.

Check failure on line 74 in src/Reflection/Php/PhpMethodReflection.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.1, windows-latest)

Method PHPStan\Reflection\Php\PhpMethodReflection::__construct() has parameter $pureUnlessCallableIsImpureParameters with no value type specified in iterable type array.

Check failure on line 74 in src/Reflection/Php/PhpMethodReflection.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.0, windows-latest)

Method PHPStan\Reflection\Php\PhpMethodReflection::__construct() has parameter $pureUnlessCallableIsImpureParameters with no value type specified in iterable type array.
private InitializerExprTypeResolver $initializerExprTypeResolver,
private ClassReflection $declaringClass,
private ?ClassReflection $declaringTrait,
Expand All @@ -91,12 +91,13 @@
private ?bool $isPure,
private Assertions $asserts,
private bool $acceptsNamedArguments,
private ?Type $selfOutType,

Check failure on line 94 in src/Reflection/Php/PhpMethodReflection.php

View workflow job for this annotation

GitHub Actions / PHPStan (7.4, ubuntu-latest)

Property PHPStan\Reflection\Php\PhpMethodReflection::$pureUnlessCallableIsImpureParameters type has no value type specified in iterable type array.

Check failure on line 94 in src/Reflection/Php/PhpMethodReflection.php

View workflow job for this annotation

GitHub Actions / PHPStan (7.4, windows-latest)

Property PHPStan\Reflection\Php\PhpMethodReflection::$pureUnlessCallableIsImpureParameters type has no value type specified in iterable type array.
private ?string $phpDocComment,
private array $phpDocParameterOutTypes,
private array $immediatelyInvokedCallableParameters,
private array $phpDocClosureThisTypeParameters,
private array $attributes,
private array $pureUnlessCallableIsImpureParameters,
)
{
}
Expand All @@ -110,7 +111,7 @@
{
return $this->declaringTrait;
}

Check failure on line 114 in src/Reflection/Php/PhpMethodReflection.php

View workflow job for this annotation

GitHub Actions / PHPStan (7.4, ubuntu-latest)

Method PHPStan\Reflection\Php\PhpMethodReflection::__construct() has parameter $pureUnlessCallableIsImpureParameters with no value type specified in iterable type array.

Check failure on line 114 in src/Reflection/Php/PhpMethodReflection.php

View workflow job for this annotation

GitHub Actions / PHPStan (7.4, windows-latest)

Method PHPStan\Reflection\Php\PhpMethodReflection::__construct() has parameter $pureUnlessCallableIsImpureParameters with no value type specified in iterable type array.
/**
* @return self|MethodPrototypeReflection
*/
Expand Down Expand Up @@ -452,6 +453,11 @@
return TrinaryLogic::createFromBoolean($this->isPure);
}

public function getPureUnlessCallableIsImpureParameters(): array
{
return $this->pureUnlessCallableIsImpureParameters;
}

public function changePropertyGetHookPhpDocType(Type $phpDocType): self
{
return new self(
Expand Down Expand Up @@ -479,6 +485,7 @@
$this->immediatelyInvokedCallableParameters,
$this->phpDocClosureThisTypeParameters,
$this->attributes,
$this->pureUnlessCallableIsImpureParameters,
);
}

Expand Down Expand Up @@ -512,6 +519,7 @@
$this->immediatelyInvokedCallableParameters,
$this->phpDocClosureThisTypeParameters,
$this->attributes,
$this->pureUnlessCallableIsImpureParameters,
);
}

Expand Down
2 changes: 2 additions & 0 deletions src/Reflection/Php/PhpMethodReflectionFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ interface PhpMethodReflectionFactory
* @param array<string, TrinaryLogic> $immediatelyInvokedCallableParameters
* @param array<string, Type> $phpDocClosureThisTypeParameters
* @param list<AttributeReflection> $attributes
* @param array<string, bool> $pureUnlessCallableIsImpureParameters
*/
public function create(
ClassReflection $declaringClass,
Expand All @@ -41,6 +42,7 @@ public function create(
array $phpDocClosureThisTypeParameters,
bool $acceptsNamedArguments,
array $attributes,
array $pureUnlessCallableIsImpureParameters,
): PhpMethodReflection;

}
5 changes: 5 additions & 0 deletions src/Reflection/ResolvedMethodReflection.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,11 @@ public function isPure(): TrinaryLogic
return $this->reflection->isPure();
}

public function getPureUnlessCallableIsImpureParameters(): array
{
return $this->reflection->getPureUnlessCallableIsImpureParameters();
}

public function getAsserts(): Assertions
{
return $this->asserts ??= $this->reflection->getAsserts()->mapTypes(fn (Type $type) => TemplateTypeHelper::resolveTemplateTypes(
Expand Down
5 changes: 5 additions & 0 deletions src/Reflection/Type/IntersectionTypeMethodReflection.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,11 @@ public function isPure(): TrinaryLogic
return TrinaryLogic::lazyMaxMin($this->methods, static fn (ExtendedMethodReflection $method): TrinaryLogic => $method->isPure());
}

public function getPureUnlessCallableIsImpureParameters(): array
{
return [];
}

public function getDocComment(): ?string
{
return null;
Expand Down
5 changes: 5 additions & 0 deletions src/Reflection/Type/UnionTypeMethodReflection.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,11 @@ public function isPure(): TrinaryLogic
return TrinaryLogic::lazyExtremeIdentity($this->methods, static fn (ExtendedMethodReflection $method): TrinaryLogic => $method->isPure());
}

public function getPureUnlessCallableIsImpureParameters(): array
{
return [];
}

public function getDocComment(): ?string
{
return null;
Expand Down
5 changes: 5 additions & 0 deletions src/Reflection/WrappedExtendedMethodReflection.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,11 @@ public function isPure(): TrinaryLogic
return TrinaryLogic::createMaybe();
}

public function getPureUnlessCallableIsImpureParameters(): array
{
return [];
}

public function getAsserts(): Assertions
{
return Assertions::createEmpty();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,11 @@ public function isPure(): TrinaryLogic
return $this->methodReflection->isPure();
}

public function getPureUnlessCallableIsImpureParameters(): array
{
return $this->methodReflection->getPureUnlessCallableIsImpureParameters();
}

public function getAttributes(): array
{
return $this->methodReflection->getAttributes();
Expand Down
Loading