Author: Shivam Mathur (shivammathur)
Date: 2026-04-02T06:41:34+05:30

Commit: 
https://github.com/php/web-downloads/commit/51dd6e77dc0cb59cde8a28d15a0a06e3aa0ba9a5
Raw diff: 
https://github.com/php/web-downloads/commit/51dd6e77dc0cb59cde8a28d15a0a06e3aa0ba9a5.diff

Skip non-matching files in WinlibsCommand::parseFiles

Changed paths:
  M  src/Console/Command/WinlibsCommand.php
  M  tests/Console/Command/WinlibsCommandTest.php


Diff:

diff --git a/src/Console/Command/WinlibsCommand.php 
b/src/Console/Command/WinlibsCommand.php
index 686d362..44dc7ed 100644
--- a/src/Console/Command/WinlibsCommand.php
+++ b/src/Console/Command/WinlibsCommand.php
@@ -77,7 +77,9 @@ public function parseFiles(array $files): array
         foreach ($files as $file) {
             $fileName = basename($file);
             $pattern = 
'/^(?P<artifact>.+?)-(?P<version>\d.*)-(?P<vs>v[c|s]\d+)-(?P<arch>[^.]+)\.zip$/';
-            preg_match($pattern, $fileName, $matches);
+            if (!preg_match($pattern, $fileName, $matches)) {
+                continue;
+            }
             $data[] = [
                 'file_path'     => $file,
                 'file_name'     => $fileName,
diff --git a/tests/Console/Command/WinlibsCommandTest.php 
b/tests/Console/Command/WinlibsCommandTest.php
index 4629c15..42fc22d 100644
--- a/tests/Console/Command/WinlibsCommandTest.php
+++ b/tests/Console/Command/WinlibsCommandTest.php
@@ -272,6 +272,13 @@ public function testParseFiles($file, $expected): void
         $this->assertEquals($expected, $result[0]);
     }
 
+    public function testParseFilesSkipsNonMatchingFiles(): void
+    {
+        $command = new WinlibsCommand();
+        $result = $command->parseFiles(['/tmp/not-a-valid-file.txt']);
+        $this->assertEmpty($result);
+    }
+
     public static function fileProvider(): array
     {
         return [

Reply via email to