#!/usr/bin/env php getPathname(); if (str_ends_with($filePath, '.phpt')) { $phptFiles[$filePath] = true; } } } $artifacts = []; foreach (array_keys($phptFiles) as $phptFile) { $base = substr($phptFile, 0, -5); foreach ($artifactSuffixes as $suffix) { $artifact = $base . $suffix; if (is_file($artifact)) { $artifacts[$artifact] = true; } } $binary = $root . DIRECTORY_SEPARATOR . str_replace('-', '_', basename($base)) . $binarySuffix; if (is_file($binary) && is_executable($binary)) { $artifacts[$binary] = true; } } $artifacts = array_keys($artifacts); sort($artifacts); $deleted = 0; foreach ($artifacts as $artifact) { $displayPath = relativePath($root, $artifact); if ($dryRun) { echo $displayPath, PHP_EOL; continue; } if (!unlink($artifact)) { fwrite(STDERR, "Failed to remove: {$displayPath}\n"); exit(1); } ++$deleted; } if ($dryRun) { printf("Found %d PHPT artifact file(s).\n", count($artifacts)); } else { printf("Removed %d PHPT artifact file(s).\n", $deleted); } function printUsage(string $script): void { echo <<