Skip to content

Improve ReflectionEnum->getCases() performance #2088

Improve ReflectionEnum->getCases() performance

Improve ReflectionEnum->getCases() performance #2088

Triggered via pull request March 22, 2024 22:12
@staabmstaabm
synchronize #1410
staabm:fast
Status Failure
Total duration 11m 34s
Artifacts

continuous-integration.yml

on: pull_request
Matrix: Check Backward Compatibility
Matrix: Run benchmarks
Matrix: Check Coding Standards
Matrix: Test Compatibility
Matrix: Check Demo Scripts
Matrix: Mutation tests
Matrix: PHPUnit tests
Matrix: Static Analysis by PHPStan
Matrix: Static Analysis by Psalm
Fit to window
Zoom out
Zoom in

Annotations

25 errors and 8 warnings
InvalidArgument: src/Reflection/Adapter/ReflectionEnum.php#L44
src/Reflection/Adapter/ReflectionEnum.php:44:36: InvalidArgument: Argument 1 of Roave\BetterReflection\Util\Memoize::__construct expects null|pure-Closure():mixed, but impure-Closure():list<Roave\BetterReflection\Reflection\Adapter\ReflectionEnumBackedCase|Roave\BetterReflection\Reflection\Adapter\ReflectionEnumUnitCase> provided (see https://psalm.dev/004)
ImpureMethodCall: src/Reflection/Adapter/ReflectionEnum.php#L553
src/Reflection/Adapter/ReflectionEnum.php:553:30: ImpureMethodCall: Cannot call a possibly-mutating method Roave\BetterReflection\Util\Memoize::get from a mutation-free context (see https://psalm.dev/203)
MixedInferredReturnType: src/Util/Memoize.php#L19
src/Util/Memoize.php:19:17: MixedInferredReturnType: Could not verify return type 'T' for Roave\BetterReflection\Util\Memoize::get (see https://psalm.dev/047)
InaccessibleProperty: src/Util/Memoize.php#L23
src/Util/Memoize.php:23:13: InaccessibleProperty: Roave\BetterReflection\Util\Memoize::$cached is marked readonly (see https://psalm.dev/054)
MixedReturnStatement: src/Util/Memoize.php#L27
src/Util/Memoize.php:27:16: MixedReturnStatement: Possibly-mixed return value (see https://psalm.dev/138)
Static Analysis by Psalm (locked, 8.3, ubuntu-latest)
Process completed with exit code 2.
Static Analysis by PHPStan (locked, 8.2, ubuntu-latest): src/Reflection/Adapter/ReflectionEnum.php#L38
PHPDoc tag @var for property Roave\BetterReflection\Reflection\Adapter\ReflectionEnum::$cases contains generic type Roave\BetterReflection\Util\Memoize<array<int, Roave\BetterReflection\Reflection\Adapter\ReflectionEnumBackedCase|Roave\BetterReflection\Reflection\Adapter\ReflectionEnumUnitCase>> but class Roave\BetterReflection\Util\Memoize is not generic.
Static Analysis by PHPStan (locked, 8.2, ubuntu-latest): src/Reflection/Adapter/ReflectionEnum.php#L553
Method Roave\BetterReflection\Reflection\Adapter\ReflectionEnum::getCases() should return array<int, Roave\BetterReflection\Reflection\Adapter\ReflectionEnumBackedCase|Roave\BetterReflection\Reflection\Adapter\ReflectionEnumUnitCase> but returns Roave\BetterReflection\Util\T.
Static Analysis by PHPStan (locked, 8.2, ubuntu-latest): src/Util/Memoize.php#L12
Class Roave\BetterReflection\Util\Memoize has an uninitialized readonly property $cached. Assign it in the constructor.
Static Analysis by PHPStan (locked, 8.2, ubuntu-latest): src/Util/Memoize.php#L15
PHPDoc tag @param for parameter $cb contains unresolvable type.
Static Analysis by PHPStan (locked, 8.2, ubuntu-latest): src/Util/Memoize.php#L15
PHPDoc type for property Roave\BetterReflection\Util\Memoize::$cb contains unresolvable type.
Static Analysis by PHPStan (locked, 8.2, ubuntu-latest): src/Util/Memoize.php#L15
PHPDoc type for property Roave\BetterReflection\Util\Memoize::$cb with type mixed is not subtype of native type Closure|null.
Static Analysis by PHPStan (locked, 8.2, ubuntu-latest): src/Util/Memoize.php#L20
Method Roave\BetterReflection\Util\Memoize::get() has invalid return type Roave\BetterReflection\Util\T.
Static Analysis by PHPStan (locked, 8.2, ubuntu-latest): src/Util/Memoize.php#L23
Readonly property Roave\BetterReflection\Util\Memoize::$cached is assigned outside of the constructor.
Static Analysis by PHPStan (locked, 8.2, ubuntu-latest)
Process completed with exit code 1.
Static Analysis by PHPStan (locked, 8.3, ubuntu-latest)
The job was canceled because "locked_8_2_ubuntu-latest" failed.
Static Analysis by PHPStan (locked, 8.3, ubuntu-latest): src/Reflection/Adapter/ReflectionEnum.php#L38
PHPDoc tag @var for property Roave\BetterReflection\Reflection\Adapter\ReflectionEnum::$cases contains generic type Roave\BetterReflection\Util\Memoize<array<int, Roave\BetterReflection\Reflection\Adapter\ReflectionEnumBackedCase|Roave\BetterReflection\Reflection\Adapter\ReflectionEnumUnitCase>> but class Roave\BetterReflection\Util\Memoize is not generic.
Static Analysis by PHPStan (locked, 8.3, ubuntu-latest): src/Reflection/Adapter/ReflectionEnum.php#L553
Method Roave\BetterReflection\Reflection\Adapter\ReflectionEnum::getCases() should return array<int, Roave\BetterReflection\Reflection\Adapter\ReflectionEnumBackedCase|Roave\BetterReflection\Reflection\Adapter\ReflectionEnumUnitCase> but returns Roave\BetterReflection\Util\T.
Static Analysis by PHPStan (locked, 8.3, ubuntu-latest): src/Util/Memoize.php#L12
Class Roave\BetterReflection\Util\Memoize has an uninitialized readonly property $cached. Assign it in the constructor.
Static Analysis by PHPStan (locked, 8.3, ubuntu-latest): src/Util/Memoize.php#L15
PHPDoc tag @param for parameter $cb contains unresolvable type.
Static Analysis by PHPStan (locked, 8.3, ubuntu-latest): src/Util/Memoize.php#L15
PHPDoc type for property Roave\BetterReflection\Util\Memoize::$cb contains unresolvable type.
Static Analysis by PHPStan (locked, 8.3, ubuntu-latest): src/Util/Memoize.php#L15
PHPDoc type for property Roave\BetterReflection\Util\Memoize::$cb with type mixed is not subtype of native type Closure|null.
Static Analysis by PHPStan (locked, 8.3, ubuntu-latest): src/Util/Memoize.php#L20
Method Roave\BetterReflection\Util\Memoize::get() has invalid return type Roave\BetterReflection\Util\T.
Static Analysis by PHPStan (locked, 8.3, ubuntu-latest): src/Util/Memoize.php#L23
Readonly property Roave\BetterReflection\Util\Memoize::$cached is assigned outside of the constructor.
Static Analysis by PHPStan (locked, 8.3, ubuntu-latest)
The operation was canceled.
Mutation tests (locked, 8.3, ubuntu-latest): src/Reflection/ReflectionFunctionAbstract.php#L368
Escaped Mutant for Mutator "InstanceOf_": --- Original +++ New @@ @@ } /** @psalm-var mixed $nodePropertyArrayItem */ foreach ($nodeProperty as $nodePropertyArrayItem) { - if ($nodePropertyArrayItem instanceof Node && $this->nodeIsOrContainsYield($nodePropertyArrayItem)) { + if (true && $this->nodeIsOrContainsYield($nodePropertyArrayItem)) { return true; } }
Mutation tests (locked, 8.3, ubuntu-latest): src/Reflection/ReflectionFunctionAbstract.php#L504
Escaped Mutant for Mutator "InstanceOf_": --- Original +++ New @@ @@ if ($returnType === null) { return null; } - assert($returnType instanceof Node\Identifier || $returnType instanceof Node\Name || $returnType instanceof Node\NullableType || $returnType instanceof Node\UnionType || $returnType instanceof Node\IntersectionType); + assert(true || $returnType instanceof Node\Name || $returnType instanceof Node\NullableType || $returnType instanceof Node\UnionType || $returnType instanceof Node\IntersectionType); return ReflectionType::createFromNode($this->reflector, $this, $returnType); } /** @return list<ReflectionAttribute> */
Mutation tests (locked, 8.3, ubuntu-latest): src/Reflection/ReflectionFunctionAbstract.php#L504
Escaped Mutant for Mutator "InstanceOf_": --- Original +++ New @@ @@ if ($returnType === null) { return null; } - assert($returnType instanceof Node\Identifier || $returnType instanceof Node\Name || $returnType instanceof Node\NullableType || $returnType instanceof Node\UnionType || $returnType instanceof Node\IntersectionType); + assert($returnType instanceof Node\Identifier || true || $returnType instanceof Node\NullableType || $returnType instanceof Node\UnionType || $returnType instanceof Node\IntersectionType); return ReflectionType::createFromNode($this->reflector, $this, $returnType); } /** @return list<ReflectionAttribute> */
Mutation tests (locked, 8.3, ubuntu-latest): src/Reflection/ReflectionFunctionAbstract.php#L504
Escaped Mutant for Mutator "InstanceOf_": --- Original +++ New @@ @@ if ($returnType === null) { return null; } - assert($returnType instanceof Node\Identifier || $returnType instanceof Node\Name || $returnType instanceof Node\NullableType || $returnType instanceof Node\UnionType || $returnType instanceof Node\IntersectionType); + assert($returnType instanceof Node\Identifier || $returnType instanceof Node\Name || true || $returnType instanceof Node\UnionType || $returnType instanceof Node\IntersectionType); return ReflectionType::createFromNode($this->reflector, $this, $returnType); } /** @return list<ReflectionAttribute> */
Mutation tests (locked, 8.3, ubuntu-latest): src/Reflection/ReflectionFunctionAbstract.php#L504
Escaped Mutant for Mutator "InstanceOf_": --- Original +++ New @@ @@ if ($returnType === null) { return null; } - assert($returnType instanceof Node\Identifier || $returnType instanceof Node\Name || $returnType instanceof Node\NullableType || $returnType instanceof Node\UnionType || $returnType instanceof Node\IntersectionType); + assert($returnType instanceof Node\Identifier || $returnType instanceof Node\Name || $returnType instanceof Node\NullableType || true || $returnType instanceof Node\IntersectionType); return ReflectionType::createFromNode($this->reflector, $this, $returnType); } /** @return list<ReflectionAttribute> */
Mutation tests (locked, 8.3, ubuntu-latest): src/Reflection/ReflectionFunctionAbstract.php#L504
Escaped Mutant for Mutator "InstanceOf_": --- Original +++ New @@ @@ if ($returnType === null) { return null; } - assert($returnType instanceof Node\Identifier || $returnType instanceof Node\Name || $returnType instanceof Node\NullableType || $returnType instanceof Node\UnionType || $returnType instanceof Node\IntersectionType); + assert($returnType instanceof Node\Identifier || $returnType instanceof Node\Name || $returnType instanceof Node\NullableType || $returnType instanceof Node\UnionType || true); return ReflectionType::createFromNode($this->reflector, $this, $returnType); } /** @return list<ReflectionAttribute> */
Mutation tests (locked, 8.3, ubuntu-latest): src/Reflection/ReflectionFunctionAbstract.php#L504
Escaped Mutant for Mutator "InstanceOf_": --- Original +++ New @@ @@ if ($returnType === null) { return null; } - assert($returnType instanceof Node\Identifier || $returnType instanceof Node\Name || $returnType instanceof Node\NullableType || $returnType instanceof Node\UnionType || $returnType instanceof Node\IntersectionType); + assert($returnType instanceof Node\Identifier || $returnType instanceof Node\Name || $returnType instanceof Node\NullableType || $returnType instanceof Node\UnionType || false); return ReflectionType::createFromNode($this->reflector, $this, $returnType); } /** @return list<ReflectionAttribute> */
Mutation tests (locked, 8.3, ubuntu-latest): src/Reflection/ReflectionFunctionAbstract.php#L504
Escaped Mutant for Mutator "LogicalOrAllSubExprNegation": --- Original +++ New @@ @@ if ($returnType === null) { return null; } - assert($returnType instanceof Node\Identifier || $returnType instanceof Node\Name || $returnType instanceof Node\NullableType || $returnType instanceof Node\UnionType || $returnType instanceof Node\IntersectionType); + assert(!$returnType instanceof Node\Identifier || !$returnType instanceof Node\Name || !$returnType instanceof Node\NullableType || !$returnType instanceof Node\UnionType || !$returnType instanceof Node\IntersectionType); return ReflectionType::createFromNode($this->reflector, $this, $returnType); } /** @return list<ReflectionAttribute> */