has($name)) { continue; } $text = file_get_contents($file); $declaresHttpUrlWithoutPort = false; foreach (preg_split("/\r\n|\n|\r/", $text) as $line) { $line = trim($line); if (! preg_match('/^- SERVICE_(?:URL|FQDN)_([A-Z0-9_]+)$/', $line, $match) && ! preg_match('/^SERVICE_(?:URL|FQDN)_([A-Z0-9_]+):/', $line, $match)) { continue; } if (! preg_match('/_\d+$/', $match[1])) { $declaresHttpUrlWithoutPort = true; break; } } if (! $declaresHttpUrlWithoutPort) { continue; } $yamlPort = null; if (preg_match('/^#\s*port:\s*(\d+)/m', $text, $portMatch)) { $yamlPort = $portMatch[1]; } $jsonPort = data_get($templates, "{$name}.port"); if (! $yamlPort || ! filled($jsonPort)) { $missing[] = $name; } } expect($missing)->toBeEmpty('HTTP templates without SERVICE_*_PORT need # port: and JSON port: '.implode(', ', $missing)); });