From 56a56e8319f482e7c8c1d4062363d01272d0e662 Mon Sep 17 00:00:00 2001 From: Sean O'Brien <60306702+stobrien89@users.noreply.github.com> Date: Mon, 14 Aug 2023 20:40:57 -0400 Subject: [PATCH] Revert "Deprecation below 7.2.5 (#2707)" This reverts commit 84d4539e72daf415e1d421dcaa0f76e607d1fd48. --- .../enhancement-php-version-bump.json | 7 ------ .github/workflows/tests.yml | 14 ++++++++---- build/packager.php | 4 ++-- build/test-phar.php | 15 ++----------- composer.json | 8 +++---- src/AwsClient.php | 4 ++++ src/ClientResolver.php | 22 +++++++++++++++++++ src/CommandPool.php | 2 +- src/Crypto/AesDecryptingStream.php | 8 +++---- src/Crypto/AesEncryptingStream.php | 8 +++---- src/Crypto/AesGcmDecryptingStream.php | 2 +- src/Crypto/AesGcmEncryptingStream.php | 2 +- src/HashingStream.php | 14 ++++++------ src/Multipart/AbstractUploadManager.php | 6 +++-- src/Rds/AuthTokenGenerator.php | 3 ++- src/S3/BatchDelete.php | 2 +- src/S3/BucketEndpointArnMiddleware.php | 2 +- src/S3/ObjectCopier.php | 3 +-- src/S3/ObjectUploader.php | 2 +- src/S3/S3Client.php | 2 +- src/S3/StreamWrapper.php | 5 ++--- src/S3/Transfer.php | 2 +- src/Token/TokenProvider.php | 6 ++--- src/Waiter.php | 3 +-- ...ApiCallAttemptMonitoringMiddlewareTest.php | 1 + tests/Crypto/RandomByteStream.php | 2 +- tests/MiddlewareTest.php | 2 +- 27 files changed, 83 insertions(+), 68 deletions(-) delete mode 100644 .changes/nextrelease/enhancement-php-version-bump.json diff --git a/.changes/nextrelease/enhancement-php-version-bump.json b/.changes/nextrelease/enhancement-php-version-bump.json deleted file mode 100644 index f287e37ad5..0000000000 --- a/.changes/nextrelease/enhancement-php-version-bump.json +++ /dev/null @@ -1,7 +0,0 @@ -[ - { - "type": "feature", - "category": "", - "description": "This version ends support for PHP versions below 7.2.5" - } -] \ No newline at end of file diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index b2e279b069..0e64ca75ca 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -16,7 +16,7 @@ jobs: strategy: #for each of the following versions of PHP, with and without --prefer-lowest matrix: - php-versions: ['7.2.5', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2'] + php-versions: ['5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2'] composer-options: ['', '--prefer-lowest'] #set the name for each job name: PHP ${{ matrix.php-versions }} ${{ matrix.composer-options }} @@ -43,6 +43,12 @@ jobs: - name: Validate composer.json and composer.lock run: composer validate + #remove incompatible xdebug file if it exists + - if: ${{ matrix.php-versions == '5.5' }} + name: PHP 5.5 + run: | + sudo rm -f /etc/php5/cli/conf.d/20-xdebug.ini + #get dependencies - name: Install dependencies run: composer update ${{ matrix.composer-options }} --no-interaction --prefer-source @@ -62,7 +68,7 @@ jobs: run: make test #static analysis - - if: ${{ matrix.php-versions < '8.0' && matrix.composer-options == '' }} + - if: ${{ matrix.php-versions >= '7.1' && matrix.php-versions < '8.0' && matrix.composer-options == '' }} name: Static analysis run: | composer require --dev nette/neon "^3.0" @@ -73,11 +79,11 @@ jobs: - if: ${{ matrix.composer-options == '' }} name: Package generation run: | - composer require guzzlehttp/psr7 "^1.9.1" -W + composer require guzzlehttp/psr7 "^1.9.1" composer update make package #generate code coverage - - if: ${{ (matrix.php-versions == '7.2.5' || matrix.php-versions == '8.0') && matrix.composer-options == '' }} + - if: ${{ (matrix.php-versions == '7.1' || matrix.php-versions == '8.0') && matrix.composer-options == '' }} name: Code coverage run: bash <(curl -s https://codecov.io/bash) diff --git a/build/packager.php b/build/packager.php index 5a08f30327..836a055e01 100644 --- a/build/packager.php +++ b/build/packager.php @@ -32,8 +32,8 @@ $autoloaderContents = [ 'Aws/functions.php', 'GuzzleHttp/functions_include.php', - 'GuzzleHttp/Psr7/Utils.php', - 'GuzzleHttp/Promise/Utils.php', + 'GuzzleHttp/Psr7/functions_include.php', + 'GuzzleHttp/Promise/functions_include.php', 'JmesPath/JmesPath.php', ]; diff --git a/build/test-phar.php b/build/test-phar.php index 48e66efced..f06ef6cfd6 100644 --- a/build/test-phar.php +++ b/build/test-phar.php @@ -20,6 +20,8 @@ // React autoloader $checks = [ + 'GuzzleHttp\\Psr7\\stream_for', + 'GuzzleHttp\\Promise\\inspect', 'JmesPath\\search', 'Aws\\dir_iterator', ]; @@ -31,17 +33,4 @@ } } -$classMethodChecks = [ - 'GuzzleHttp\\Promise\\Utils' => 'inspect', - 'GuzzleHttp\\Psr7\\Utils' => 'streamFor', -]; - -foreach ($classMethodChecks as $class => $method) { - if (!method_exists($class, $method) - ) { - echo $class . '::' . $method . ' not found'; - exit(1); - } -} - echo 'Version=' . Aws\Sdk::VERSION; diff --git a/composer.json b/composer.json index cb770080d7..e96eaff9fc 100644 --- a/composer.json +++ b/composer.json @@ -16,16 +16,16 @@ "issues": "https://github.com/aws/aws-sdk-php/issues" }, "require": { - "php": ">=7.2.5", + "php": ">=5.5", "guzzlehttp/guzzle": "^6.5.8 || ^7.4.5", "guzzlehttp/psr7": "^1.9.1 || ^2.4.5", - "guzzlehttp/promises": "^1.4.0 || ^2.0", + "guzzlehttp/promises": "^1.4.0", "mtdowling/jmespath.php": "^2.6", "ext-pcre": "*", "ext-json": "*", "ext-simplexml": "*", "aws/aws-crt-php": "^1.0.4", - "psr/http-message": "^1.0 || ^2.0" + "psr/http-message": "^1.0" }, "require-dev": { "composer/composer" : "^1.10.22", @@ -33,7 +33,7 @@ "ext-dom": "*", "ext-pcntl": "*", "ext-sockets": "*", - "phpunit/phpunit": "^5.6.3 || ^8.5 || ^9.5", + "phpunit/phpunit": "^4.8.35 || ^5.6.3 || ^9.5", "behat/behat": "~3.0", "doctrine/cache": "~1.4", "aws/aws-php-sns-message-validator": "~1.0", diff --git a/src/AwsClient.php b/src/AwsClient.php index 3b43b8260b..c4b5271f8c 100644 --- a/src/AwsClient.php +++ b/src/AwsClient.php @@ -242,6 +242,10 @@ public function __construct(array $args) $this->addRecursionDetection(); $this->addRequestBuilder(); + if (!$config['suppress_php_deprecation_warning']) { + $this->emitDeprecationWarning(); + } + if (isset($args['with_resolved'])) { $args['with_resolved']($config); } diff --git a/src/ClientResolver.php b/src/ClientResolver.php index ae74520b1d..34b2172379 100644 --- a/src/ClientResolver.php +++ b/src/ClientResolver.php @@ -280,6 +280,13 @@ class ClientResolver 'doc' => 'Set to false to disable checking for shared aws config files usually located in \'~/.aws/config\' and \'~/.aws/credentials\'. This will be ignored if you set the \'profile\' setting.', 'default' => true, ], + 'suppress_php_deprecation_warning' => [ + 'type' => 'value', + 'valid' => ['bool'], + 'doc' => 'Set to false to disable the deprecation warning of PHP versions 7.2.4 and below', + 'default' => false, + 'fn' => [__CLASS__, '_apply_suppress_php_deprecation_warning'] + ], ]; /** @@ -1019,6 +1026,21 @@ public static function _apply_idempotency_auto_fill( } } + public static function _apply_suppress_php_deprecation_warning($suppressWarning, array &$args) { + if ($suppressWarning) { + $args['suppress_php_deprecation_warning'] = true; + } elseif (!empty($_ENV["AWS_SUPPRESS_PHP_DEPRECATION_WARNING"])) { + $args['suppress_php_deprecation_warning'] = + $_ENV["AWS_SUPPRESS_PHP_DEPRECATION_WARNING"]; + } elseif (!empty($_SERVER["AWS_SUPPRESS_PHP_DEPRECATION_WARNING"])) { + $args['suppress_php_deprecation_warning'] = + $_SERVER["AWS_SUPPRESS_PHP_DEPRECATION_WARNING"]; + } elseif (!empty(getenv("AWS_SUPPRESS_PHP_DEPRECATION_WARNING"))) { + $args['suppress_php_deprecation_warning'] + = getenv("AWS_SUPPRESS_PHP_DEPRECATION_WARNING"); + } + } + public static function _default_endpoint_provider(array $args) { $service = isset($args['api']) ? $args['api'] : null; diff --git a/src/CommandPool.php b/src/CommandPool.php index d043422e21..7cb1f94a12 100644 --- a/src/CommandPool.php +++ b/src/CommandPool.php @@ -75,7 +75,7 @@ public function __construct( /** * @return PromiseInterface */ - public function promise(): PromiseInterface + public function promise() { return $this->each->promise(); } diff --git a/src/Crypto/AesDecryptingStream.php b/src/Crypto/AesDecryptingStream.php index feafc469f2..c1524cc18a 100644 --- a/src/Crypto/AesDecryptingStream.php +++ b/src/Crypto/AesDecryptingStream.php @@ -65,7 +65,7 @@ public function getCurrentIv() return $this->cipherMethod->getCurrentIv(); } - public function getSize(): ?int + public function getSize() { $plainTextSize = $this->stream->getSize(); @@ -80,12 +80,12 @@ public function getSize(): ?int return $plainTextSize; } - public function isWritable(): bool + public function isWritable() { return false; } - public function read($length): string + public function read($length) { if ($length > strlen($this->buffer)) { $this->buffer .= $this->decryptBlock( @@ -101,7 +101,7 @@ public function read($length): string return $data ? $data : ''; } - public function seek($offset, $whence = SEEK_SET): void + public function seek($offset, $whence = SEEK_SET) { if ($offset === 0 && $whence === SEEK_SET) { $this->buffer = ''; diff --git a/src/Crypto/AesEncryptingStream.php b/src/Crypto/AesEncryptingStream.php index 2cb5ab696b..3b7c446754 100644 --- a/src/Crypto/AesEncryptingStream.php +++ b/src/Crypto/AesEncryptingStream.php @@ -65,7 +65,7 @@ public function getCurrentIv() return $this->cipherMethod->getCurrentIv(); } - public function getSize(): ?int + public function getSize() { $plainTextSize = $this->stream->getSize(); @@ -79,12 +79,12 @@ public function getSize(): ?int return $plainTextSize; } - public function isWritable(): bool + public function isWritable() { return false; } - public function read($length): string + public function read($length) { if ($length > strlen($this->buffer)) { $this->buffer .= $this->encryptBlock( @@ -99,7 +99,7 @@ public function read($length): string return $data ? $data : ''; } - public function seek($offset, $whence = SEEK_SET): void + public function seek($offset, $whence = SEEK_SET) { if ($whence === SEEK_CUR) { $offset = $this->tell() + $offset; diff --git a/src/Crypto/AesGcmDecryptingStream.php b/src/Crypto/AesGcmDecryptingStream.php index 6ca750008b..76feaa158b 100644 --- a/src/Crypto/AesGcmDecryptingStream.php +++ b/src/Crypto/AesGcmDecryptingStream.php @@ -100,7 +100,7 @@ public function createStream() } } - public function isWritable(): bool + public function isWritable() { return false; } diff --git a/src/Crypto/AesGcmEncryptingStream.php b/src/Crypto/AesGcmEncryptingStream.php index 0d706e421e..13357f52fb 100644 --- a/src/Crypto/AesGcmEncryptingStream.php +++ b/src/Crypto/AesGcmEncryptingStream.php @@ -118,7 +118,7 @@ public function getTag() return $this->tag; } - public function isWritable(): bool + public function isWritable() { return false; } diff --git a/src/HashingStream.php b/src/HashingStream.php index 6622178e91..9b11e137bd 100644 --- a/src/HashingStream.php +++ b/src/HashingStream.php @@ -36,7 +36,7 @@ public function __construct( $this->callback = $onComplete; } - public function read($length): string + public function read($length) { $data = $this->stream->read($length); $this->hash->update($data); @@ -50,14 +50,14 @@ public function read($length): string return $data; } - public function seek($offset, $whence = SEEK_SET): void + public function seek($offset, $whence = SEEK_SET) { - // Seeking arbitrarily is not supported. - if ($offset !== 0) { - return; + if ($offset === 0) { + $this->hash->reset(); + return $this->stream->seek($offset); } - $this->hash->reset(); - $this->stream->seek($offset); + // Seeking arbitrarily is not supported. + return false; } } diff --git a/src/Multipart/AbstractUploadManager.php b/src/Multipart/AbstractUploadManager.php index e663245e0d..8e382c0e02 100644 --- a/src/Multipart/AbstractUploadManager.php +++ b/src/Multipart/AbstractUploadManager.php @@ -88,7 +88,7 @@ public function upload() * * @return PromiseInterface */ - public function promise(): PromiseInterface + public function promise() { if ($this->promise) { return $this->promise; @@ -218,8 +218,10 @@ abstract protected function getCompleteParams(); /** * Based on the config and service-specific workflow info, creates a * `Promise` for an `UploadState` object. + * + * @return PromiseInterface A `Promise` that resolves to an `UploadState`. */ - private function determineState(): UploadState + private function determineState() { // If the state was provided via config, then just use it. if ($this->config['state'] instanceof UploadState) { diff --git a/src/Rds/AuthTokenGenerator.php b/src/Rds/AuthTokenGenerator.php index 824d2b060e..e58b7359d0 100644 --- a/src/Rds/AuthTokenGenerator.php +++ b/src/Rds/AuthTokenGenerator.php @@ -47,7 +47,8 @@ public function createToken($endpoint, $region, $username, $lifetime = 15) { if (!is_numeric($lifetime) || $lifetime > 15 || $lifetime <= 0) { throw new \InvalidArgumentException( - "Lifetime must be a positive number less than or equal to 15, was {$lifetime}" + "Lifetime must be a positive number less than or equal to 15, was {$lifetime}", + null ); } diff --git a/src/S3/BatchDelete.php b/src/S3/BatchDelete.php index db81bebc5c..92439115cd 100644 --- a/src/S3/BatchDelete.php +++ b/src/S3/BatchDelete.php @@ -115,7 +115,7 @@ public static function fromIterator( /** * @return PromiseInterface */ - public function promise(): PromiseInterface + public function promise() { if (!$this->cachedPromise) { $this->cachedPromise = $this->createPromise(); diff --git a/src/S3/BucketEndpointArnMiddleware.php b/src/S3/BucketEndpointArnMiddleware.php index aa3dae2228..becfded6f1 100644 --- a/src/S3/BucketEndpointArnMiddleware.php +++ b/src/S3/BucketEndpointArnMiddleware.php @@ -188,7 +188,7 @@ private function generateAccessPointHost( } $host = "{$accesspointName}-" . $arn->getAccountId(); - + $useFips = $this->config['use_fips_endpoint']->isUseFipsEndpoint(); $fipsString = $useFips ? "-fips" : ""; diff --git a/src/S3/ObjectCopier.php b/src/S3/ObjectCopier.php index 66e4446d90..ca5922a92b 100644 --- a/src/S3/ObjectCopier.php +++ b/src/S3/ObjectCopier.php @@ -7,7 +7,6 @@ use Aws\Result; use Aws\S3\Exception\S3Exception; use GuzzleHttp\Promise\Coroutine; -use GuzzleHttp\Promise\PromiseInterface; use GuzzleHttp\Promise\PromisorInterface; use InvalidArgumentException; @@ -80,7 +79,7 @@ public function __construct( * * @return Coroutine */ - public function promise(): PromiseInterface + public function promise() { return Coroutine::of(function () { $headObjectCommand = $this->client->getCommand( diff --git a/src/S3/ObjectUploader.php b/src/S3/ObjectUploader.php index b73b7b1235..4bbc583a71 100644 --- a/src/S3/ObjectUploader.php +++ b/src/S3/ObjectUploader.php @@ -68,7 +68,7 @@ public function __construct( /** * @return PromiseInterface */ - public function promise(): PromiseInterface + public function promise() { /** @var int $mup_threshold */ $mup_threshold = $this->options['mup_threshold']; diff --git a/src/S3/S3Client.php b/src/S3/S3Client.php index 5cb2fa8b1d..b82bbc56bc 100644 --- a/src/S3/S3Client.php +++ b/src/S3/S3Client.php @@ -728,7 +728,7 @@ private function processEndpointV2Model() private function addBuiltIns($args) { if ($args['region'] !== 'us-east-1') { - return; + return false; } $key = 'AWS::S3::UseGlobalEndpoint'; $result = $args['s3_us_east_1_regional_endpoint'] instanceof \Closure ? diff --git a/src/S3/StreamWrapper.php b/src/S3/StreamWrapper.php index b42b6c55a8..a70e5cd52d 100644 --- a/src/S3/StreamWrapper.php +++ b/src/S3/StreamWrapper.php @@ -569,10 +569,9 @@ public function rename($path_from, $path_to) ); // Delete the original object $this->getClient()->deleteObject([ - 'Bucket' => $partsFrom['Bucket'], - 'Key' => $partsFrom['Key'], + 'Bucket' => $partsFrom['Bucket'], + 'Key' => $partsFrom['Key'] ] + $options); - return true; }); } diff --git a/src/S3/Transfer.php b/src/S3/Transfer.php index 600f441008..9228c807fc 100644 --- a/src/S3/Transfer.php +++ b/src/S3/Transfer.php @@ -146,7 +146,7 @@ public function __construct( * * @return PromiseInterface */ - public function promise(): PromiseInterface + public function promise() { // If the promise has been created, just return it. if (!$this->promise) { diff --git a/src/Token/TokenProvider.php b/src/Token/TokenProvider.php index 805bc96495..1d7014c888 100644 --- a/src/Token/TokenProvider.php +++ b/src/Token/TokenProvider.php @@ -257,10 +257,10 @@ private static function reject($msg) * @param string $filename the location of the ini file * @param array $config configuration options * - * @return SsoTokenProvider - * @see Aws\Token\SsoTokenProvider for $config details. + * @return SsoToken + * @see Aws\Token\SsoToken for $config details. */ - public static function sso($profileName, $filename, $config = []) : SsoTokenProvider + public static function sso($profileName, $filename, $config = []) { return new SsoTokenProvider($profileName, $filename, $config); } diff --git a/src/Waiter.php b/src/Waiter.php index 74b2480131..ac1e001a84 100644 --- a/src/Waiter.php +++ b/src/Waiter.php @@ -3,7 +3,6 @@ use Aws\Exception\AwsException; use GuzzleHttp\Promise\Coroutine; -use GuzzleHttp\Promise\PromiseInterface; use GuzzleHttp\Promise\PromisorInterface; use GuzzleHttp\Promise\RejectedPromise; @@ -90,7 +89,7 @@ public function __construct( /** * @return Coroutine */ - public function promise(): PromiseInterface + public function promise() { return Coroutine::of(function () { $name = $this->config['operation']; diff --git a/tests/ClientSideMonitoring/ApiCallAttemptMonitoringMiddlewareTest.php b/tests/ClientSideMonitoring/ApiCallAttemptMonitoringMiddlewareTest.php index 60bdabcba8..5d29e2daaa 100644 --- a/tests/ClientSideMonitoring/ApiCallAttemptMonitoringMiddlewareTest.php +++ b/tests/ClientSideMonitoring/ApiCallAttemptMonitoringMiddlewareTest.php @@ -9,6 +9,7 @@ use Aws\Credentials\CredentialProvider; use Aws\Credentials\Credentials; use Aws\Exception\AwsException; +use GuzzleHttp\ClientInterface; use GuzzleHttp\Psr7\Request; use GuzzleHttp\Psr7\Response; use PHPUnit\Framework\TestCase; diff --git a/tests/Crypto/RandomByteStream.php b/tests/Crypto/RandomByteStream.php index c0847b76d3..b14b7911e2 100644 --- a/tests/Crypto/RandomByteStream.php +++ b/tests/Crypto/RandomByteStream.php @@ -37,7 +37,7 @@ public function __construct($maxLength) /** * @return int|null */ - public function getSize(): ?int + public function getSize() { return $this->maxLength; } diff --git a/tests/MiddlewareTest.php b/tests/MiddlewareTest.php index f1b6410bfb..48b1fd7e22 100644 --- a/tests/MiddlewareTest.php +++ b/tests/MiddlewareTest.php @@ -39,7 +39,7 @@ public function testCanTapIntoHandlerList() $called = func_get_args(); })); $handler = $list->resolve(); - $handler(new Command('foo'), new Request('GET', 'http://exmaple.com')); + $handler(new Command('foo'), new Request('GET', 'http://example.com')); Promise\Utils::queue()->run(); $this->assertCount(2, $called); $this->assertInstanceOf(CommandInterface::class, $called[0]);