Skip to content
Merged
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/8.5-support.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[
{
"type": "feature",
"category": "",
"description": "Adds support for PHP 8.5"
}
]
49 changes: 49 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Code Coverage

on:
push:
branches: [master]
schedule:
- cron: '0 0 * * 0'
workflow_dispatch:

permissions:
contents: read

jobs:
coverage:
runs-on: ubuntu-latest
name: Code Coverage
env:
AWS_ACCESS_KEY_ID: foo
AWS_SECRET_ACCESS_KEY: bar
AWS_CSM_ENABLED: false
AWS_SUPPRESS_PHP_DEPRECATION_WARNING: true
steps:
- name: Setup PHP with Xdebug
uses: shivammathur/setup-php@v2
with:
coverage: xdebug
php-version: '8.3'
ini-values: xdebug.overload_var_dump=0, memory_limit=4G, phar.readonly=false

- name: Checkout codebase
uses: actions/checkout@v5
with:
fetch-depth: 0

- name: Validate composer.json and composer.lock
run: composer validate

- name: Install dependencies
run: composer install --no-interaction --prefer-source

- name: Run test suite with coverage
run: vendor/bin/phpunit --testsuite=unit --coverage-clover=clover.xml

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
file: ./clover.xml
fail_ci_if_error: false
token: ${{ secrets.CODECOV_TOKEN }}
8 changes: 4 additions & 4 deletions .github/workflows/docs-build.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build API documentation
name: Build API Documentation
permissions:
contents: read
on:
Expand All @@ -14,12 +14,12 @@ jobs:
php-versions: ['8.1']
name: Build API documentation for PHP ${{ matrix.php-versions }}
steps:
- name: Setup PHP with Xdebug
- name: Setup PHP with JIT
uses: shivammathur/setup-php@v2
with:
coverage: xdebug
coverage: none
php-version: ${{ matrix.php-versions }}
ini-values: xdebug.overload_var_dump=0, memory_limit=4G, phar.readonly=false
ini-values: memory_limit=4G, phar.readonly=false, opcache.enable=1, opcache.enable_cli=1, opcache.jit=tracing, opcache.jit_buffer_size=128M

- name: Checkout CodeBase
uses: actions/checkout@v6
Expand Down
27 changes: 27 additions & 0 deletions .github/workflows/model-changes.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Model Change Scan

on:
pull_request:
branches: [master]

permissions:
contents: read

jobs:
verify-no-models-changes:
runs-on: ubuntu-latest
name: Check for model changes
steps:
- name: Checkout codebase
uses: actions/checkout@v5
with:
fetch-depth: 0
- run: |
BASE_REPO="${{ github.event.pull_request.base.repo.clone_url }}"
git fetch $BASE_REPO master:master -q
CHANGED_FILES=$(git diff --name-only FETCH_HEAD...HEAD -- src/data/)
if [ ! -z "$CHANGED_FILES" ]; then
echo "Changes detected in the following models:"
echo "$CHANGED_FILES"
exit 1
fi
64 changes: 64 additions & 0 deletions .github/workflows/tests-windows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Unit Tests (Windows)

on:
push:
branches: [master]
pull_request:
branches: [master]

permissions:
contents: read

jobs:
run:
runs-on: windows-latest
strategy:
matrix:
include:
- php-versions: '8.1'
composer-options: ''
- php-versions: '8.2'
composer-options: ''
- php-versions: '8.3'
composer-options: ''
- php-versions: '8.4'
composer-options: ''
- php-versions: '8.5'
composer-options: ''
name: PHP ${{ matrix.php-versions }} ${{ matrix.composer-options }}
env:
AWS_ACCESS_KEY_ID: foo
AWS_SECRET_ACCESS_KEY: bar
AWS_CSM_ENABLED: false
AWS_SUPPRESS_PHP_DEPRECATION_WARNING: true
steps:
- name: Setup PHP with JIT
uses: shivammathur/setup-php@v2
with:
coverage: none
php-version: ${{ matrix.php-versions }}
ini-values: memory_limit=4G, phar.readonly=false, opcache.enable=1, opcache.enable_cli=1, opcache.jit=tracing, opcache.jit_buffer_size=128M
extensions: sockets

- name: Checkout codebase
uses: actions/checkout@v6
with:
fetch-depth: 0

- name: Validate composer.json and composer.lock
run: composer validate

- name: Install dependencies
run: |
composer install --no-interaction --prefer-dist --no-progress
if ($LASTEXITCODE -ne 0) {
composer update --no-interaction --prefer-dist --no-progress
}

- name: Run test suite
run: make test

- name: Static analysis
run: |
composer require --dev nette/neon "^3.4.4" phpstan/phpstan "2.1.1" --ignore-platform-req=php --update-with-all-dependencies
vendor\bin\phpstan analyse src
61 changes: 25 additions & 36 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: PHP Composer
name: Unit Tests (Linux)

# whenever master has a PR or is pushed to
on:
Expand All @@ -11,25 +11,6 @@ permissions:
contents: read

jobs:
verify-no-models-changes:
runs-on: ubuntu-latest
name: Check for model changes
if: github.event_name == 'pull_request'
steps:
- name: Checkout codebase
uses: actions/checkout@v6
with:
fetch-depth: 0
- run: |
BASE_REPO="${{ github.event.pull_request.base.repo.clone_url }}"
git fetch $BASE_REPO master:master -q
CHANGED_FILES=$(git diff --name-only FETCH_HEAD...HEAD -- src/data/)
if [ ! -z "$CHANGED_FILES" ]; then
echo "Changes detected in the following models:"
echo "$CHANGED_FILES"
exit 1
fi

run:
runs-on: ubuntu-latest
strategy:
Expand All @@ -50,6 +31,10 @@ jobs:
composer-options: '--prefer-lowest'
- php-versions: '8.4'
composer-options: ''
- php-versions: '8.4'
composer-options: '--prefer-lowest'
- php-versions: '8.5'
composer-options: ''
# set the name for each job
name: PHP ${{ matrix.php-versions }} ${{ matrix.composer-options }}
# set up environment variables used by unit tests
Expand All @@ -60,30 +45,40 @@ jobs:
AWS_SUPPRESS_PHP_DEPRECATION_WARNING: true
steps:
# sets up the correct version of PHP with necessary config options
- name: Setup PHP with Xdebug
- name: Setup PHP with JIT
uses: shivammathur/setup-php@v2
with:
coverage: xdebug
coverage: none
php-version: ${{ matrix.php-versions }}
ini-values: xdebug.overload_var_dump=0, memory_limit=4G, phar.readonly=false
ini-values: memory_limit=4G, phar.readonly=false, opcache.enable=1, opcache.enable_cli=1, opcache.jit=tracing, opcache.jit_buffer_size=128M

# checkout the codebase from github
- name: Checkout codebase
uses: actions/checkout@v6
with:
fetch-depth: 0 # Added for code coverage
fetch-depth: 0

# validate composer files
- name: Validate composer.json and composer.lock
run: composer validate

# get dependencies
- name: Install dependencies
run: composer update ${{ matrix.composer-options }} --no-interaction --prefer-source

# php 8.1+ requirements
- name: PHP 8.1+ requirements
run: composer require --dev phpunit/phpunit "^9.5" guzzlehttp/guzzle "^7.4.5" --no-interaction --prefer-source --with-all-dependencies
run: |
if [[ "${{ matrix.composer-options }}" == "--prefer-lowest" ]]; then
# PHP 8.3+ needs PSR HTTP Message 2.0+ and compatible Guzzle packages
if [[ "${{ matrix.php-versions }}" == "8.3" ]] || [[ "${{ matrix.php-versions }}" == "8.4" ]]; then
composer update ${{ matrix.composer-options }} --no-interaction --prefer-dist --with-all-dependencies
composer update psr/http-message guzzlehttp/psr7 guzzlehttp/guzzle --with-all-dependencies --no-interaction
if [[ "${{ matrix.php-versions }}" == "8.4" ]]; then
composer update phpunit/phpunit:^9.6.18 --with-all-dependencies --no-interaction
fi
else
composer update ${{ matrix.composer-options }} --no-interaction --prefer-dist --with-all-dependencies
fi
else
composer update ${{ matrix.composer-options }} --no-interaction --prefer-dist
fi

# run tests
- name: Run test suite
Expand All @@ -92,8 +87,7 @@ jobs:
# static analysis
- name: Static analysis
run: |
composer require --dev nette/neon "^3.4.4"
composer require --dev phpstan/phpstan "2.1.1"
composer require --dev nette/neon "^3.4.4" phpstan/phpstan "2.1.1" --ignore-platform-req=php --update-with-all-dependencies
vendor/bin/phpstan analyse src

# generate package
Expand All @@ -103,8 +97,3 @@ jobs:
composer config platform.php 8.1
composer update
make package

# generate code coverage
- if: ${{ matrix.composer-options == '' }}
name: Code Coverage
run: bash <(curl -s https://codecov.io/bash)
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,30 +25,30 @@
"ext-json": "*",
"ext-simplexml": "*",
"aws/aws-crt-php": "^1.2.3",
"psr/http-message": "^1.0 || ^2.0"
"psr/http-message": "^1.0 || ^2.0",
"symfony/filesystem": "^v6.4.3 || ^v7.1.0"
},
"require-dev": {
"composer/composer" : "^2.7.8",
"ext-openssl": "*",
"ext-dom": "*",
"ext-pcntl": "*",
"ext-sockets": "*",
"phpunit/phpunit": "^5.6.3 || ^8.5 || ^9.5",
"phpunit/phpunit": "^9.6",
"behat/behat": "~3.0",
"doctrine/cache": "~1.4",
"aws/aws-php-sns-message-validator": "~1.0",
"andrewsville/php-token-reflection": "^1.4",
"psr/cache": "^2.0 || ^3.0",
"psr/simple-cache": "^2.0 || ^3.0",
"sebastian/comparator": "^1.2.3 || ^4.0 || ^5.0",
"symfony/filesystem": "^v6.4.0 || ^v7.1.0",
"yoast/phpunit-polyfills": "^2.0",
"dms/phpunit-arraysubset-asserts": "^0.4.0"
},
"suggest": {
"ext-openssl": "Allows working with CloudFront private distributions and verifying received SNS messages",
"ext-curl": "To send requests using cURL",
"ext-sockets": "To use client-side monitoring",
"ext-pcntl": "To use client-side monitoring",
"doctrine/cache": "To use the DoctrineCacheAdapter",
"aws/aws-php-sns-message-validator": "To validate incoming SNS notifications"
},
Expand Down
2 changes: 1 addition & 1 deletion src/Api/Serializer/RestSerializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ private function applyPayload(StructureShape $input, $name, array $args, array &
// This path skips setting the content-type header usually done in
// RestJsonSerializer and RestXmlSerializer.certain S3 and glacier
// operations determine content type in Middleware::ContentType()
if (!isset(self::$excludeContentType[$this->api->getServiceName()])) {
if (!isset(self::$excludeContentType[$this->api->getServiceName() ?? ''])) {
switch ($type) {
case 'string':
$opts['headers']['Content-Type'] = 'text/plain';
Expand Down
10 changes: 8 additions & 2 deletions src/AwsClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -568,8 +568,14 @@ private function loadAliases($file = null)
$aliases = \Aws\load_compiled_json($file);
$serviceId = $this->api->getServiceId();
$version = $this->getApi()->getApiVersion();
if (!empty($aliases['operations'][$serviceId][$version])) {
$this->aliases = array_flip($aliases['operations'][$serviceId][$version]);
$serviceAliases = null;

if (!is_null($serviceId) && isset($aliases['operations'][$serviceId])) {
$serviceAliases = $aliases['operations'][$serviceId];
}

if ($serviceAliases && isset($serviceAliases[$version])) {
$this->aliases = array_flip($serviceAliases[$version]);
}
}
}
Expand Down
7 changes: 5 additions & 2 deletions src/Configuration/ConfigurationResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,11 @@ private static function retrieveValueFromIniSubsection(
"services {$data[$profile]['services']}"
);

if (!isset($services_section[$options['subsection']][$options['key']])
) {
if (empty($options['subsection']) || empty($options['key'])) {
return null;
}

if (!isset($services_section[$options['subsection']][$options['key']])) {
return null;
}

Expand Down
4 changes: 2 additions & 2 deletions src/EndpointDiscovery/EndpointDiscoveryMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -322,8 +322,8 @@ private function handleInvalidEndpoint(

// If no more cached endpoints, make discovery call
// if none made within cooldown for given key
if (time() - $this->discoveryTimes[$cacheKey]
< self::$discoveryCooldown
if (isset($this->discoveryTimes[$cacheKey])
&& time() - $this->discoveryTimes[$cacheKey] < self::$discoveryCooldown
) {

// If no more cached endpoints and it's required,
Expand Down
3 changes: 3 additions & 0 deletions src/LruArrayCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public function __construct($maxItems = 1000)

public function get($key)
{
$key = $key ?? '';
if (!isset($this->items[$key])) {
Comment thread
yenfryherrerafeliz marked this conversation as resolved.
return null;
}
Expand All @@ -49,6 +50,7 @@ public function get($key)

public function set($key, $value, $ttl = 0)
{
$key = $key ?? '';
Comment thread
stobrien89 marked this conversation as resolved.
// Only call time() if the TTL is not 0/false/null
$ttl = $ttl ? time() + $ttl : 0;
$this->items[$key] = [$value, $ttl];
Expand All @@ -69,6 +71,7 @@ public function set($key, $value, $ttl = 0)

public function remove($key)
{
$key = $key ?? '';
unset($this->items[$key]);
}

Expand Down
Loading