-
Notifications
You must be signed in to change notification settings - Fork 504
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added regression test #3062
Added regression test #3062
Conversation
@@ -201,7 +200,8 @@ public static function union(Type ...$types): Type | |||
if ($types[$i] instanceof StringType && !$types[$i] instanceof ClassStringType) { | |||
$hasGenericScalarTypes[ConstantStringType::class] = true; | |||
} | |||
if ($types[$i] instanceof EnumCaseObjectType) { | |||
$enumCases = $types[$i]->getEnumCases(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reverts #2985
This pull request has been marked as ready for review. |
after this PR we now have both cases fast:
|
will be AFK for a few hours |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah this looks good 👍
src/Type/ObjectType.php
Outdated
@@ -94,6 +94,9 @@ class ObjectType implements TypeWithClassName, SubtractableType | |||
|
|||
private ?string $cachedDescription = null; | |||
|
|||
/** @var array<class-string, list<EnumCaseObjectType>> */ | |||
private static array $enumCasesCache = []; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs to be reset in resetCaches()
src/Type/ObjectType.php
Outdated
foreach ($this->subtractedType->getEnumCases() as $enumCase) { | ||
$subtracted[$enumCase->getEnumCaseName()] = true; | ||
$className = $classReflection->getName(); | ||
if (array_key_exists($className, self::$enumCasesCache)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The cache key needs to be $this->describeCache()
.
69a9068
to
168d145
Compare
this one is good to go. I will have a look at the other remaining open PRs after this one is merged, whether there is still meaningful impact
|
cs Update ObjectType.php
} | ||
|
||
$errors = $this->runAnalyse(__DIR__ . '/data/bug-10979.php'); | ||
$this->assertCount(80, $errors); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please fix the example so that it's valid and does not report any errors? And make sure it still reproduces the performance problem.
I'm worrying that the number 80 is going to fluctuate and is going to fail quite often as we work on PHPStan.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we now have a zero errors repro
Thank you! |
closes phpstan/phpstan#10979
reverting the fix for #2985 does not regress the test of said PR.I need to dive deeper why the test no longer reproduces the perf problem we had at the time #2985 was created
I had a typo locally .. investigating..