Skip to content

Commit

Permalink
Update deprecation warning (#2640)
Browse files Browse the repository at this point in the history
  • Loading branch information
SamRemis authored Feb 17, 2023
1 parent ceb929c commit 5db91ee
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/AwsClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,7 @@ public static function emitDeprecationWarning() {
$phpVersion = PHP_VERSION_ID;
if ($phpVersion < 70205) {
$phpVersionString = phpversion();
trigger_error(
@trigger_error(

This comment has been minimized.

Copy link
@rquadling

rquadling Aug 1, 2023

Contributor

Doesn't the @ suppress the entire error, essentially making this method pointless?

"This installation of the SDK is using PHP version"
. " {$phpVersionString}, which will be deprecated on August"
. " 15th, 2023. Please upgrade your PHP version to a minimum of"
Expand Down
20 changes: 18 additions & 2 deletions tests/AwsClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -610,15 +610,20 @@ public function testThrowsDeprecationWarning() {
$expectsDeprecation = PHP_VERSION_ID < 70205;
if ($expectsDeprecation) {
try {
$this->expectDeprecation();
$this->expectDeprecationMessage("This installation of the SDK is using PHP version");
set_error_handler(function ($e, $message) {
$this->assertStringContainsString("This installation of the SDK is using PHP version", $message);
$this->assertEquals($e, E_USER_DEPRECATED);
throw new Exception("This test successfully triggered the deprecation");
});
$client = new StsClient([
'region' => 'us-west-2',
'version' => 'latest'
]);
$this->fail("This test should have thrown the deprecation");
} catch (Exception $exception) {
} finally {
putenv("AWS_SUPPRESS_PHP_DEPRECATION_WARNING={$storeEnvVariable}");
restore_error_handler();
}
} else {
$client = new StsClient([
Expand All @@ -642,12 +647,17 @@ public function testCanDisableWarningWithClientConfig() {
$expectsDeprecation = PHP_VERSION_ID < 70205;
if ($expectsDeprecation) {
try {
set_error_handler(function ($e, $message) {
$this->assertStringNotContainsString("This installation of the SDK is using PHP version", $message);
});
$client = new StsClient([
'region' => 'us-west-2',
'version' => 'latest',
'suppress_php_deprecation_warning' => true
]);
restore_error_handler();
} catch (Exception $exception) {
restore_error_handler();
$this->fail("This test should not have thrown the deprecation");
}
} else {
Expand All @@ -663,11 +673,17 @@ public function testCanDisableWarningWithEnvVar() {
$expectsDeprecation = PHP_VERSION_ID < 70205;
if ($expectsDeprecation) {
try {
set_error_handler(function ($e, $message) {
echo "hi";
$this->assertStringNotContainsString("This installation of the SDK is using PHP version", $message);
});
$client = new StsClient([
'region' => 'us-west-2',
'version' => 'latest'
]);
restore_error_handler();
} catch (Exception $exception) {
restore_error_handler();
$this->fail("This test should not have thrown the deprecation");
}
} else {
Expand Down

0 comments on commit 5db91ee

Please sign in to comment.