|
| 1 | +<?php |
| 2 | +require_once 'vendor/autoload.php'; |
| 3 | + |
| 4 | +use Composer\Package\CompletePackage; |
| 5 | +use Composer\Satis\Builder\ArchiveBuilderHelper; |
| 6 | +use Symfony\Component\Console\Output\BufferedOutput; |
| 7 | + |
| 8 | +echo "=== FINAL VALIDATION: Empty Source Fields Support ===\n\n"; |
| 9 | + |
| 10 | +// Simulate the exact scenario from the issue: phpstan/phpstan with empty source fields |
| 11 | +$problematicPackage = new CompletePackage('phpstan/phpstan', '1.12.32.0', '1.12.32'); |
| 12 | +$problematicPackage->setSourceType(''); // Empty type |
| 13 | +$problematicPackage->setSourceUrl(''); // Empty URL |
| 14 | +$problematicPackage->setSourceReference(''); // Empty reference |
| 15 | + |
| 16 | +echo "1. Testing package with empty source fields (like phpstan/phpstan):\n"; |
| 17 | +echo " Package: " . $problematicPackage->getPrettyString() . "\n"; |
| 18 | +echo " Source: type='" . $problematicPackage->getSourceType() . "', url='" . $problematicPackage->getSourceUrl() . "'\n"; |
| 19 | +echo " Dist: type='" . $problematicPackage->getDistType() . "', url='" . $problematicPackage->getDistUrl() . "'\n"; |
| 20 | + |
| 21 | +$output = new BufferedOutput(); |
| 22 | +$helper = new ArchiveBuilderHelper($output, ['directory' => 'dist']); |
| 23 | + |
| 24 | +$isSkipped = $helper->isSkippable($problematicPackage); |
| 25 | +echo " Result: " . ($isSkipped ? "✅ SKIPPED (no crash!)" : "❌ NOT SKIPPED (would crash)") . "\n"; |
| 26 | +echo " Message: " . trim($output->fetch()) . "\n\n"; |
| 27 | + |
| 28 | +// Test with a normal package to ensure we didn't break anything |
| 29 | +$normalPackage = new CompletePackage('monolog/monolog', '2.0.0', '2.0.0'); |
| 30 | +$normalPackage->setSourceType('git'); |
| 31 | +$normalPackage->setSourceUrl('https://github.com/Seldaek/monolog.git'); |
| 32 | +$normalPackage->setSourceReference('abc123'); |
| 33 | + |
| 34 | +echo "2. Testing normal package (should not be skipped):\n"; |
| 35 | +echo " Package: " . $normalPackage->getPrettyString() . "\n"; |
| 36 | +echo " Source: type='" . $normalPackage->getSourceType() . "', url='" . $normalPackage->getSourceUrl() . "'\n"; |
| 37 | + |
| 38 | +$output2 = new BufferedOutput(); |
| 39 | +$helper2 = new ArchiveBuilderHelper($output2, ['directory' => 'dist']); |
| 40 | + |
| 41 | +$isSkipped2 = $helper2->isSkippable($normalPackage); |
| 42 | +echo " Result: " . ($isSkipped2 ? "❌ SKIPPED (shouldn't be)" : "✅ NOT SKIPPED (correct)") . "\n"; |
| 43 | +$message2 = trim($output2->fetch()); |
| 44 | +echo " Message: " . ($message2 ? $message2 : "(no message - correct)") . "\n\n"; |
| 45 | + |
| 46 | +// Summary |
| 47 | +echo "=== SUMMARY ===\n"; |
| 48 | +if ($isSkipped && !$isSkipped2) { |
| 49 | + echo "✅ SUCCESS: Satis now supports packages with empty source fields!\n"; |
| 50 | + echo " - Packages with empty source/dist are skipped (prevents crash)\n"; |
| 51 | + echo " - Normal packages are processed normally (no regression)\n"; |
| 52 | + echo " - Behavior matches the rest of the Composer ecosystem\n"; |
| 53 | +} else { |
| 54 | + echo "❌ ISSUE: Implementation needs adjustment\n"; |
| 55 | +} |
0 commit comments