$method->getName(), array_filter( (new ReflectionClass(CloudPublicNetworkAddressPolicy::class)) ->getMethods(ReflectionMethod::IS_PUBLIC), static fn (ReflectionMethod $method): bool => $method->getDeclaringClass()->getName() === CloudPublicNetworkAddressPolicy::class ) )); sort($methods, SORT_STRING); if ($methods !== [ 'addressSelectable', 'assertIdentity', 'assertSelectable', 'contract', ]) { throw new RuntimeException('Address policy public seam drifted.'); } foreach ([ 'DB::', 'lockForUpdate(', '::find(', '->save(', '->update(', '->insert(', '->delete(', ] as $forbidden) { if (str_contains($policy, $forbidden) || str_contains($catalog, $forbidden)) { throw new RuntimeException( 'Pure public-network policy/catalog performs persistence: ' . $forbidden ); } } $catalogMethods = array_values(array_map( static fn (ReflectionMethod $method): string => $method->getName(), array_filter( (new ReflectionClass(CloudPublicNetworkCandidateCatalog::class)) ->getMethods(ReflectionMethod::IS_PUBLIC), static fn (ReflectionMethod $method): bool => $method->getDeclaringClass()->getName() === CloudPublicNetworkCandidateCatalog::class ) )); $expectedCatalogMethods = [ 'fromLocked', 'planAllocation', 'planTransition', ]; sort($catalogMethods, SORT_STRING); sort($expectedCatalogMethods, SORT_STRING); $plan = new ReflectionClass(CloudPublicNetworkCandidatePlan::class); $planMethods = array_values(array_map( static fn (ReflectionMethod $method): string => $method->getName(), array_filter( $plan->getMethods(ReflectionMethod::IS_PUBLIC), static fn (ReflectionMethod $method): bool => $method->getDeclaringClass()->getName() === CloudPublicNetworkCandidatePlan::class ) )); sort($planMethods, SORT_STRING); if ($catalogMethods !== $expectedCatalogMethods || $planMethods !== [ '__construct', 'allocationSelection', 'attachment', 'candidates', 'changedFamilies', 'pools', ] || !$plan->isFinal() || !$plan->isReadOnly()) { throw new RuntimeException('Candidate catalog public seam drifted.'); } $iterator = new RecursiveIteratorIterator( new RecursiveDirectoryIterator($root, FilesystemIterator::SKIP_DOTS) ); foreach ($iterator as $file) { if (!$file->isFile() || $file->getExtension() !== 'php') { continue; } $contents = file_get_contents($file->getPathname()); if (is_string($contents) && (str_contains($contents, 'rawAddressAllowedByPool') || str_contains($contents, 'rawAddressBelongsToPool'))) { throw new RuntimeException( 'Retired duplicate address-policy helper returned: ' . $file->getFilename() ); } } echo "Public-network shared address-policy contracts passed.\n";