Skip to content

Commit

Permalink
Fix typo in ObjectType
Browse files Browse the repository at this point in the history
  • Loading branch information
staabm authored Jul 2, 2024
1 parent 123e2ac commit f546c37
Showing 1 changed file with 10 additions and 17 deletions.
27 changes: 10 additions & 17 deletions src/Type/ObjectType.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}
$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;
}

$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;
}
}
Expand Down

0 comments on commit f546c37

Please sign in to comment.