-
Notifications
You must be signed in to change notification settings - Fork 473
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
Fix typo in ObjectType #3206
Fix typo in ObjectType #3206
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1230,15 +1230,15 @@ public function getEnumCases(): array | |
$className = $classReflection->getName(); | ||
|
||
if ($this->subtractedType !== null) { | ||
$subtracedEnumCaseNames = []; | ||
$subtractedEnumCaseNames = []; | ||
|
||
foreach ($this->subtractedType->getEnumCases() as $subtractedCase) { | ||
$subtracedEnumCaseNames[$subtractedCase->getEnumCaseName()] = true; | ||
$subtractedEnumCaseNames[$subtractedCase->getEnumCaseName()] = true; | ||
} | ||
|
||
$cases = []; | ||
foreach ($classReflection->getEnumCases() as $enumCase) { | ||
if (array_key_exists($enumCase->getName(), $subtracedEnumCaseNames)) { | ||
if (array_key_exists($enumCase->getName(), $subtractedEnumCaseNames)) { | ||
continue; | ||
} | ||
$cases[] = new EnumCaseObjectType($className, $enumCase->getName(), $classReflection); | ||
|
@@ -1371,27 +1371,20 @@ public function changeSubtractedType(?Type $subtractedType): Type | |
{ | ||
if ($subtractedType !== null) { | ||
$classReflection = $this->getClassReflection(); | ||
$allowedSubTypesList = $classReflection !== null ? $classReflection->getAllowedSubTypes() : null; | ||
if ($allowedSubTypesList !== null) { | ||
$allowedSubTypes = []; | ||
foreach ($allowedSubTypesList as $allowedSubType) { | ||
$allowedSubTypes[$allowedSubType->describe(VerbosityLevel::precise())] = $allowedSubType; | ||
staabm marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
$allowedSubTypes = $classReflection !== null ? $classReflection->getAllowedSubTypes() : null; | ||
if ($allowedSubTypes !== null) { | ||
$preciseVerbosity = VerbosityLevel::precise(); | ||
|
||
$originalAllowedSubTypes = $allowedSubTypes; | ||
$subtractedSubTypes = []; | ||
|
||
$subtractedTypesList = TypeUtils::flattenTypes($subtractedType); | ||
$subtractedTypes = []; | ||
foreach ($subtractedTypesList as $type) { | ||
$subtractedTypes[$type->describe(VerbosityLevel::precise())] = $type; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we don't need the key of this array and building up the descriptions shows up in profiles of phpstan/phpstan#11263 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. after getting rid of the key, it seems we can get rid of the whole loop |
||
} | ||
|
||
$subtractedTypes = TypeUtils::flattenTypes($subtractedType); | ||
foreach ($subtractedTypes as $subType) { | ||
foreach ($allowedSubTypes as $description => $allowedSubType) { | ||
foreach ($allowedSubTypes as $key => $allowedSubType) { | ||
if ($subType->equals($allowedSubType)) { | ||
$description = $allowedSubType->describe($preciseVerbosity); | ||
$subtractedSubTypes[$description] = $subType; | ||
unset($allowedSubTypes[$description]); | ||
unset($allowedSubTypes[$key]); | ||
continue 2; | ||
} | ||
} | ||
|
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.
typo-fix