From 2595de07ce1ab1bced96c4e9be98008248ce2985 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Bouc=CC=8Cek?= Date: Wed, 4 Nov 2020 12:00:21 +0100 Subject: [PATCH] AutoloadGenerator: Trigger native PHP error on platform checks fails - tests --- .../Fixtures/platform/no_extensions_required.php | 9 +++++---- .../Test/Autoload/Fixtures/platform/no_php_required.php | 9 +++++---- .../Autoload/Fixtures/platform/no_php_upper_bound.php | 9 +++++---- .../Fixtures/platform/replaced_provided_exts.php | 9 +++++---- .../Autoload/Fixtures/platform/specific_php_release.php | 9 +++++---- .../Composer/Test/Autoload/Fixtures/platform/typical.php | 9 +++++---- 6 files changed, 30 insertions(+), 24 deletions(-) diff --git a/tests/Composer/Test/Autoload/Fixtures/platform/no_extensions_required.php b/tests/Composer/Test/Autoload/Fixtures/platform/no_extensions_required.php index 69d65fb1b..188c0fae4 100644 --- a/tests/Composer/Test/Autoload/Fixtures/platform/no_extensions_required.php +++ b/tests/Composer/Test/Autoload/Fixtures/platform/no_extensions_required.php @@ -8,8 +8,9 @@ if (!(PHP_VERSION_ID >= 70200)) { $issues[] = 'Your Composer dependencies require a PHP version ">= 7.2.0". You are running ' . PHP_VERSION . '.'; } -if ($issues && !headers_sent()) { - header('HTTP/1.1 500 Internal Server Error'); - echo 'Composer detected issues in your platform:' . "\n\n" . implode("\n", $issues) . "\n\n"; - exit(104); +if ($issues) { + trigger_error( + 'Composer detected issues in your platform: ' . implode(', ', $issues), + E_USER_ERROR + ); } diff --git a/tests/Composer/Test/Autoload/Fixtures/platform/no_php_required.php b/tests/Composer/Test/Autoload/Fixtures/platform/no_php_required.php index ae5a9761f..ee7d8cacd 100644 --- a/tests/Composer/Test/Autoload/Fixtures/platform/no_php_required.php +++ b/tests/Composer/Test/Autoload/Fixtures/platform/no_php_required.php @@ -12,8 +12,9 @@ if ($missingExtensions) { $issues[] = 'Your Composer dependencies require the following PHP extensions to be installed: ' . implode(', ', $missingExtensions); } -if ($issues && !headers_sent()) { - header('HTTP/1.1 500 Internal Server Error'); - echo 'Composer detected issues in your platform:' . "\n\n" . implode("\n", $issues) . "\n\n"; - exit(104); +if ($issues) { + trigger_error( + 'Composer detected issues in your platform: ' . implode(', ', $issues), + E_USER_ERROR + ); } diff --git a/tests/Composer/Test/Autoload/Fixtures/platform/no_php_upper_bound.php b/tests/Composer/Test/Autoload/Fixtures/platform/no_php_upper_bound.php index 69d65fb1b..188c0fae4 100644 --- a/tests/Composer/Test/Autoload/Fixtures/platform/no_php_upper_bound.php +++ b/tests/Composer/Test/Autoload/Fixtures/platform/no_php_upper_bound.php @@ -8,8 +8,9 @@ if (!(PHP_VERSION_ID >= 70200)) { $issues[] = 'Your Composer dependencies require a PHP version ">= 7.2.0". You are running ' . PHP_VERSION . '.'; } -if ($issues && !headers_sent()) { - header('HTTP/1.1 500 Internal Server Error'); - echo 'Composer detected issues in your platform:' . "\n\n" . implode("\n", $issues) . "\n\n"; - exit(104); +if ($issues) { + trigger_error( + 'Composer detected issues in your platform: ' . implode(', ', $issues), + E_USER_ERROR + ); } diff --git a/tests/Composer/Test/Autoload/Fixtures/platform/replaced_provided_exts.php b/tests/Composer/Test/Autoload/Fixtures/platform/replaced_provided_exts.php index 98c4d3d1e..c530dc59d 100644 --- a/tests/Composer/Test/Autoload/Fixtures/platform/replaced_provided_exts.php +++ b/tests/Composer/Test/Autoload/Fixtures/platform/replaced_provided_exts.php @@ -11,8 +11,9 @@ if ($missingExtensions) { $issues[] = 'Your Composer dependencies require the following PHP extensions to be installed: ' . implode(', ', $missingExtensions); } -if ($issues && !headers_sent()) { - header('HTTP/1.1 500 Internal Server Error'); - echo 'Composer detected issues in your platform:' . "\n\n" . implode("\n", $issues) . "\n\n"; - exit(104); +if ($issues) { + trigger_error( + 'Composer detected issues in your platform: ' . implode(', ', $issues), + E_USER_ERROR + ); } diff --git a/tests/Composer/Test/Autoload/Fixtures/platform/specific_php_release.php b/tests/Composer/Test/Autoload/Fixtures/platform/specific_php_release.php index dc7cfa4f3..5a2d6dfed 100644 --- a/tests/Composer/Test/Autoload/Fixtures/platform/specific_php_release.php +++ b/tests/Composer/Test/Autoload/Fixtures/platform/specific_php_release.php @@ -8,8 +8,9 @@ if (!(PHP_VERSION_ID >= 70208)) { $issues[] = 'Your Composer dependencies require a PHP version ">= 7.2.8". You are running ' . PHP_VERSION . '.'; } -if ($issues && !headers_sent()) { - header('HTTP/1.1 500 Internal Server Error'); - echo 'Composer detected issues in your platform:' . "\n\n" . implode("\n", $issues) . "\n\n"; - exit(104); +if ($issues) { + trigger_error( + 'Composer detected issues in your platform: ' . implode(', ', $issues), + E_USER_ERROR + ); } diff --git a/tests/Composer/Test/Autoload/Fixtures/platform/typical.php b/tests/Composer/Test/Autoload/Fixtures/platform/typical.php index 4c78d2378..ba33b7aeb 100644 --- a/tests/Composer/Test/Autoload/Fixtures/platform/typical.php +++ b/tests/Composer/Test/Autoload/Fixtures/platform/typical.php @@ -16,8 +16,9 @@ if ($missingExtensions) { $issues[] = 'Your Composer dependencies require the following PHP extensions to be installed: ' . implode(', ', $missingExtensions); } -if ($issues && !headers_sent()) { - header('HTTP/1.1 500 Internal Server Error'); - echo 'Composer detected issues in your platform:' . "\n\n" . implode("\n", $issues) . "\n\n"; - exit(104); +if ($issues) { + trigger_error( + 'Composer detected issues in your platform: ' . implode(', ', $issues), + E_USER_ERROR + ); }