catalog(); $problems = []; foreach (ShortformMap::types() as $type) { $name = ModuleCatalog::normalize($type); if (! $catalog->has($name)) { $problems[] = $name . ': unknown module'; continue; } foreach (ShortformMap::fields($type) as $field => $spec) { if (! $catalog->isKnownPath($name, (string) $spec['path'])) { $problems[] = sprintf( '%s.%s: unknown path %s (closest: %s)', $type, $field, $spec['path'], implode(', ', $catalog->suggestions($name, (string) $spec['path'])) ); } } $child = ShortformMap::childType($type); if ($child !== null && ! in_array(ModuleCatalog::normalize($child), $catalog->childrenOf($name), true)) { $problems[] = sprintf('%s: %s is no allowed child (%s)', $type, $child, implode(', ', $catalog->childrenOf($name))); } } if ($problems !== []) { WP_CLI::error("Short form does not match the catalog:\n" . implode("\n", $problems)); } WP_CLI::success(sprintf( '%d short-form modules match the catalog of %d modules (%.0f ms).', count(ShortformMap::types()), count($catalog->names()), (microtime(true) - $started) * 1000 ));