Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: remove code for unsupported version v5 of Guzzle #2923

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changes/nextrelease/remove-guzzlev5-support.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[
{
"type": "enhancement",
"category": "Handler",
"description": "Remove code for unsupported version v5 of Guzzle."
}
]
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ we ask the same of all community contributions as well:
### Changelog Documents

A changelog document is a small JSON blob placed in the `.changes/nextrelease`
folder. It should be named a clearly and uniquely, akin to a branch name. It
folder. It should be named clearly and uniquely, akin to a branch name. It
consists of a type, category, and description as follows:

```json
Expand Down
5 changes: 0 additions & 5 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ parameters:
processTimeout: 300.0

excludePaths:
# Guzzle V5 classes & interfaces changed in V6
- %rootDir%/../../../src/Handler/GuzzleV5/*
- %rootDir%/../../../src/Crypto/Polyfill/*
- src/data/*

Expand All @@ -23,9 +21,6 @@ parameters:
- '#Property Aws\\Api\\Parser\\DecodingEventStreamIterator::\$hashContext has unknown class HashContext as its type\.#'
- '#Return typehint of method Aws\\PhpHash::getContext\(\) has invalid type HashContext\.#'

# Guzzle V5 classes & interfaces changed in V6
- '#Call to an undefined static method GuzzleHttp\\Client::getDefaultUserAgent\(\)\.#'

# There is a check for availability of constant that phpstan does not detect. https://github.com/phpstan/phpstan/issues/2971
- '#Access to undefined constant GuzzleHttp\\ClientInterface::MAJOR_VERSION#'
- '#Access to undefined constant GuzzleHttp\\ClientInterface::VERSION\.#'
Expand Down
211 changes: 0 additions & 211 deletions src/Handler/GuzzleV5/GuzzleHandler.php

This file was deleted.

24 changes: 0 additions & 24 deletions src/Handler/GuzzleV5/GuzzleStream.php

This file was deleted.

34 changes: 0 additions & 34 deletions src/Handler/GuzzleV5/PsrStream.php

This file was deleted.

50 changes: 2 additions & 48 deletions src/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -273,18 +273,7 @@ function describe_type($input)
*/
function default_http_handler()
{
$version = guzzle_major_version();
// If Guzzle 6 or 7 installed
if ($version === 6 || $version === 7) {
return new \Aws\Handler\GuzzleV6\GuzzleHandler();
}

// If Guzzle 5 installed
if ($version === 5) {
return new \Aws\Handler\GuzzleV5\GuzzleHandler();
}

throw new \RuntimeException('Unknown Guzzle version: ' . $version);
return new \Aws\Handler\GuzzleV6\GuzzleHandler();
}

/**
Expand All @@ -294,42 +283,7 @@ function default_http_handler()
*/
function default_user_agent()
{
$version = guzzle_major_version();
// If Guzzle 6 or 7 installed
if ($version === 6 || $version === 7) {
return \GuzzleHttp\default_user_agent();
}

throw new \RuntimeException('Unknown Guzzle version: ' . $version);
}

/**
* Get the major version of guzzle that is installed.
*
* @internal This function is internal and should not be used outside aws/aws-sdk-php.
* @return int
* @throws \RuntimeException
*/
function guzzle_major_version()
{
static $cache = null;
if (null !== $cache) {
return $cache;
}

if (defined('\GuzzleHttp\ClientInterface::VERSION')) {
$version = (string) ClientInterface::VERSION;
if ($version[0] === '6') {
return $cache = 6;
}
if ($version[0] === '5') {
return $cache = 5;
}
} elseif (defined('\GuzzleHttp\ClientInterface::MAJOR_VERSION')) {
return $cache = ClientInterface::MAJOR_VERSION;
}

throw new \RuntimeException('Unable to determine what Guzzle version is installed.');
return \GuzzleHttp\default_user_agent();
}

/**
Expand Down
Loading