[web-downloads] main: Remove use of extract()

From: Date: Fri, 26 Sep 2025 08:56:31 +0000
Subject: [web-downloads] main: Remove use of extract()
Groups: php.webmaster 
Request: Send a blank email to php-webmaster+get-33234@lists.php.net to get a copy of this message
Author: Shivam Mathur (shivammathur) Date: 2025-09-26T14:26:23+05:30 Commit: https://github.com/php/web-downloads/commit/53d68fe113dddf519b0e48068a869088f233e11c Raw diff: https://github.com/php/web-downloads/commit/53d68fe113dddf519b0e48068a869088f233e11c.diff Remove use of extract() Changed paths: M src/Console/Command/SeriesDeleteCommand.php M src/Console/Command/SeriesInitCommand.php M src/Console/Command/SeriesStabilityCommand.php M src/Console/Command/WinlibsCommand.php M src/Http/Controllers/PeclController.php M src/Http/Controllers/PhpController.php M src/Http/Controllers/SeriesDeleteController.php M src/Http/Controllers/SeriesInitController.php M src/Http/Controllers/SeriesStabilityController.php M src/Http/Controllers/WinlibsController.php Diff: diff --git a/src/Console/Command/SeriesDeleteCommand.php b/src/Console/Command/SeriesDeleteCommand.php index d032dfb..aa7691b 100644 --- a/src/Console/Command/SeriesDeleteCommand.php +++ b/src/Console/Command/SeriesDeleteCommand.php @@ -45,8 +45,10 @@ public function handle(): int foreach ($filteredFiles as $filepath) { $data = json_decode(file_get_contents($filepath), true, 512, JSON_THROW_ON_ERROR); - extract($data); - $this->deleteSeriesFiles($php_version, $vs_version); + $this->deleteSeriesFiles( + $data['php_version'], + $data['vs_version'] + ); unlink($filepath); unlink($filepath . '.lock'); } diff --git a/src/Console/Command/SeriesInitCommand.php b/src/Console/Command/SeriesInitCommand.php index 0668e57..d2db374 100644 --- a/src/Console/Command/SeriesInitCommand.php +++ b/src/Console/Command/SeriesInitCommand.php @@ -45,8 +45,11 @@ public function handle(): int foreach ($filteredFiles as $filepath) { $data = json_decode(file_get_contents($filepath), true, 512, JSON_THROW_ON_ERROR); - extract($data); - $this->initSeriesFiles($php_version, $source_vs, $target_vs); + $this->initSeriesFiles( + $data['php_version'], + $data['source_vs'], + $data['target_vs'] + ); unlink($filepath); unlink($filepath . '.lock'); } diff --git a/src/Console/Command/SeriesStabilityCommand.php b/src/Console/Command/SeriesStabilityCommand.php index 362cbca..82ae631 100644 --- a/src/Console/Command/SeriesStabilityCommand.php +++ b/src/Console/Command/SeriesStabilityCommand.php @@ -45,8 +45,10 @@ public function handle(): int foreach ($filteredFiles as $filepath) { $data = json_decode(file_get_contents($filepath), true, 512, JSON_THROW_ON_ERROR); - extract($data); - $this->promoteSeriesFiles($php_version, $vs_version); + $this->promoteSeriesFiles( + $data['php_version'], + $data['vs_version'] + ); unlink($filepath); unlink($filepath . '.lock'); } diff --git a/src/Console/Command/WinlibsCommand.php b/src/Console/Command/WinlibsCommand.php index 78b91ca..c1b12b3 100644 --- a/src/Console/Command/WinlibsCommand.php +++ b/src/Console/Command/WinlibsCommand.php @@ -41,12 +41,17 @@ public function handle(): int foreach ($filteredDirectories as $directoryPath) { $data = json_decode(file_get_contents($directoryPath . '/data.json'), true, 512, JSON_THROW_ON_ERROR); - extract($data); $files = glob($directoryPath . '/*.zip'); $files = $this->parseFiles($files); if ($files) { - $this->copyFiles($files, $library, $vs_version_targets); - $this->updateSeriesFiles($files, $library, $php_versions, $vs_version_targets, $stability); + $this->copyFiles($files, $data['library'], $data['vs_version_targets']); + $this->updateSeriesFiles( + $files, + $data['library'], + $data['php_versions'], + $data['vs_version_targets'], + $data['stability'] + ); } (new Helpers)->rmdirr($directoryPath); diff --git a/src/Http/Controllers/PeclController.php b/src/Http/Controllers/PeclController.php index 0ea0d2f..4552229 100644 --- a/src/Http/Controllers/PeclController.php +++ b/src/Http/Controllers/PeclController.php @@ -32,8 +32,12 @@ public function validate(array $data): bool public function execute(array $data): void { try { - extract($data); - $this->fetchExtension($extension, $ref, $url, $token ?? ''); + $this->fetchExtension( + $data['extension'], + $data['ref'], + $data['url'], + $data['token'] ?? '' + ); } catch (Exception $exception) { http_response_code(500); echo 'Error: ' . $exception->getMessage(); diff --git a/src/Http/Controllers/PhpController.php b/src/Http/Controllers/PhpController.php index 41373a9..f354f80 100644 --- a/src/Http/Controllers/PhpController.php +++ b/src/Http/Controllers/PhpController.php @@ -31,8 +31,7 @@ protected function validate(array $data): bool protected function execute(array $data): void { try { - extract($data); - $this->fetchPhpBuild($url, $token); + $this->fetchPhpBuild($data['url'], $data['token']); } catch (Exception $exception) { http_response_code(500); echo 'Error: ' . $exception->getMessage(); diff --git a/src/Http/Controllers/SeriesDeleteController.php b/src/Http/Controllers/SeriesDeleteController.php index 4c66d32..b5869eb 100644 --- a/src/Http/Controllers/SeriesDeleteController.php +++ b/src/Http/Controllers/SeriesDeleteController.php @@ -28,9 +28,8 @@ protected function validate(array $data): bool protected function execute(array $data): void { - extract($data); $directory = getenv('BUILDS_DIRECTORY') . '/series'; - $hash = hash('sha256', $php_version) . time(); + $hash = hash('sha256', $data['php_version']) . time(); $file = $directory . '/series-delete-' . $hash . '.json'; file_put_contents($file, json_encode($data)); } diff --git a/src/Http/Controllers/SeriesInitController.php b/src/Http/Controllers/SeriesInitController.php index 269e828..728cca5 100644 --- a/src/Http/Controllers/SeriesInitController.php +++ b/src/Http/Controllers/SeriesInitController.php @@ -29,9 +29,8 @@ protected function validate(array $data): bool protected function execute(array $data): void { - extract($data); $directory = getenv('BUILDS_DIRECTORY') . '/series'; - $hash = hash('sha256', $php_version) . time(); + $hash = hash('sha256', $data['php_version']) . time(); $file = $directory . '/series-init-' . $hash . '.json'; file_put_contents($file, json_encode($data)); } diff --git a/src/Http/Controllers/SeriesStabilityController.php b/src/Http/Controllers/SeriesStabilityController.php index c28f328..ee7a40a 100644 --- a/src/Http/Controllers/SeriesStabilityController.php +++ b/src/Http/Controllers/SeriesStabilityController.php @@ -28,9 +28,8 @@ protected function validate(array $data): bool protected function execute(array $data): void { - extract($data); $directory = getenv('BUILDS_DIRECTORY') . '/series'; - $hash = hash('sha256', $php_version) . time(); + $hash = hash('sha256', $data['php_version']) . time(); $file = $directory . '/series-stability-' . $hash . '.json'; file_put_contents($file, json_encode($data)); } diff --git a/src/Http/Controllers/WinlibsController.php b/src/Http/Controllers/WinlibsController.php index aca9fb8..77f3374 100644 --- a/src/Http/Controllers/WinlibsController.php +++ b/src/Http/Controllers/WinlibsController.php @@ -34,9 +34,8 @@ protected function validate(array $data): bool protected function execute(array $data): void { - extract($data); - (new GetArtifacts)->handle($workflow_run_id, $token); - $directory = getenv('BUILDS_DIRECTORY') . '/winlibs/' . $workflow_run_id; + (new GetArtifacts)->handle($data['workflow_run_id'], $data['token']); + $directory = getenv('BUILDS_DIRECTORY') . '/winlibs/' . $data['workflow_run_id']; file_put_contents($directory . '/data.json', json_encode($data)); } } \ No newline at end of file

« previous php.webmaster (#33234) next »