Automattic\WooCommerce\Vendor\GraphQL\Utils

BreakingChangesFinder::findInterfacesRemovedFromObjectTypes │ public static │ WC 1.0

Method of the class: BreakingChangesFinder{}

No Hooks.

Returns

array<int, Change>.

Usage

$result = BreakingChangesFinder::findInterfacesRemovedFromObjectTypes( $oldSchema, $newSchema ): array;
$oldSchema(Schema) (required)
.
$newSchema(Schema) (required)
.

BreakingChangesFinder::findInterfacesRemovedFromObjectTypes() code WC 11.1.2

public static function findInterfacesRemovedFromObjectTypes(
    Schema $oldSchema,
    Schema $newSchema
): array {
    $oldTypeMap = $oldSchema->getTypeMap();
    $newTypeMap = $newSchema->getTypeMap();
    $breakingChanges = [];

    foreach ($oldTypeMap as $typeName => $oldType) {
        $newType = $newTypeMap[$typeName] ?? null;
        if (! ($oldType instanceof ImplementingType) || ! ($newType instanceof ImplementingType)) {
            continue;
        }

        $oldInterfaces = $oldType->getInterfaces();
        $newInterfaces = $newType->getInterfaces();
        foreach ($oldInterfaces as $oldInterface) {
            $interfaceWasRemoved = true;
            foreach ($newInterfaces as $newInterface) {
                if ($oldInterface->name === $newInterface->name) {
                    $interfaceWasRemoved = false;
                }
            }

            if ($interfaceWasRemoved) {
                $breakingChanges[] = [
                    'type' => self::BREAKING_CHANGE_IMPLEMENTED_INTERFACE_REMOVED,
                    'description' => "{$typeName} no longer implements interface {$oldInterface->name}.",
                ];
            }
        }
    }

    return $breakingChanges;
}