Skip to content

Commit

Permalink
Merge pull request #21 from Art4/update-compat
Browse files Browse the repository at this point in the history
Update dependencies
  • Loading branch information
Art4 authored Oct 11, 2024
2 parents ef847a4 + d9bfada commit 2c2f991
Show file tree
Hide file tree
Showing 7 changed files with 126 additions and 25 deletions.
122 changes: 109 additions & 13 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,30 @@
name: PHPUnit
name: Check

on:
push:
pull_request:
# Allow manually triggering the workflow.
workflow_dispatch:

jobs:

tests:
name: Tests (PHP ${{ matrix.php }} with ${{ matrix.prefer-versions }} lib versions)
unit-tests:
name: PHPUnit (PHP ${{ matrix.php }} with ${{ matrix.prefer-versions }} lib versions)
runs-on: ubuntu-latest
continue-on-error: ${{ matrix.php == '8.4' }}

strategy:
fail-fast: false
matrix:
operating-system: ['ubuntu-latest']
php: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4']
php:
- '8.4'
- '8.3'
- '8.2'
- '8.1'
- '8.0'
- '7.4'
- '7.3'
- '7.2'
prefer-versions: ['latest']
include:
- php: '7.2'
Expand All @@ -26,7 +33,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 2

Expand All @@ -35,8 +42,7 @@ jobs:
with:
php-version: ${{ matrix.php }}
ini-values: error_reporting=-1, display_errors=On, log_errors_max_len=0
coverage: xdebug
tools: none
tools: phpunit

# Install dependencies and handle caching in one go.
# @link https://github.com/marketplace/actions/install-composer-dependencies
Expand All @@ -57,17 +63,107 @@ jobs:
composer-options: --ignore-platform-reqs

- name: Run phpunit tests
run: composer run phpunit -- --coverage-clover ./.code-coverage/clover.xml
run: composer run phpunit

static-code-analysis:
name: PHPStan (PHP ${{ matrix.php }})
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
operating-system: ["ubuntu-latest"]
php: ["8.3"]

steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 2

- name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php
with:
php-version: ${{ matrix.php }}
tools: phpunit
extensions: mbstring, xml, ctype, iconv, intl, pdo_sqlite

# Install composer dependencies and handle caching in one go.
# @link https://github.com/marketplace/actions/install-composer-dependencies
- name: "Install Composer dependencies"
uses: "ramsey/composer-install@v2"

- name: Run static code analysis
# Do not run phpstan on lowest php version
if: ${{ matrix.prefer-versions == 'latest' }}
run: composer run phpstan -- --error-format=github

code-coverage:
name: Code Coverage (PHP ${{ matrix.php }})
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
operating-system: ["ubuntu-latest"]
php: ["8.3"]

steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 2

- name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php
with:
php-version: ${{ matrix.php }}
tools: phpunit
extensions: mbstring, xml, ctype, iconv, intl, pdo_sqlite
coverage: xdebug

# Install composer dependencies and handle caching in one go.
# @link https://github.com/marketplace/actions/install-composer-dependencies
- name: "Install Composer dependencies"
uses: "ramsey/composer-install@v2"

- name: Run phpunit tests
run: composer run phpunit -- --coverage-clover ./.code-coverage/clover.xml

- name: Send coverage report to Codecov
if: ${{ success() && matrix.php == '8.3' }}
uses: codecov/codecov-action@v3
if: ${{ success() }}
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./.code-coverage/clover.xml
fail_ci_if_error: true
verbose: true

code-style:
name: Code Style (PHP ${{ matrix.php }})
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
operating-system: ["ubuntu-latest"]
php: ["8.3"]

steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 2

- name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php
with:
php-version: ${{ matrix.php }}
tools: none
extensions: mbstring, xml, ctype, iconv, intl, pdo_sqlite

# Install composer dependencies and handle caching in one go.
# @link https://github.com/marketplace/actions/install-composer-dependencies
- name: "Install Composer dependencies"
uses: "ramsey/composer-install@v2"

- name: Check code-style
run: composer run codestyle -- --dry-run --diff
1 change: 1 addition & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@
'@PHPUnit84Migration:risky' => true,
])
->setFinder($finder)
->setRiskyAllowed(true)
;
10 changes: 8 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"rmccue/requests": "^1.8 || ^2.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.0",
"friendsofphp/php-cs-fixer": "^3.4",
"phpstan/phpstan": "^1.10",
"phpunit/phpunit": "^8 || ^9 || ^10",
"yoast/phpunit-polyfills": "^2"
Expand All @@ -37,9 +37,15 @@
}
},
"scripts": {
"codestyle": "php-cs-fixer fix",
"coverage": "phpunit --coverage-html=.code-coverage",
"phpstan": "phpstan analyze --memory-limit 512M --configuration .phpstan.neon",
"phpunit": "phpunit"
"phpunit": "phpunit",
"test": [
"@phpstan",
"@phpunit",
"@codestyle --dry-run --diff"
]
},
"provide": {
"psr/http-client-implementation": "^1.0"
Expand Down
2 changes: 1 addition & 1 deletion src/Psr/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ public function getStatusCode(): int
* @return static
* @throws \InvalidArgumentException For invalid status code arguments.
*/
public function withStatus(int $code, string $reasonPhrase = ''): ResponseInterface
public function withStatus(int $code, string $reasonPhrase = ''): ResponseInterface
{
$response = clone($this);
$response->status_code = $code;
Expand Down
10 changes: 5 additions & 5 deletions src/Psr/Uri.php
Original file line number Diff line number Diff line change
Expand Up @@ -514,16 +514,16 @@ public function __toString(): string

$path = $this->getPath();

// If the path is rootless and an authority is present, the path MUST
// be prefixed by "/".
if (strncmp($path, '/', 1) !== 0 && $authority !== '') {
// If the path is rootless and an authority is present, the path MUST
// be prefixed by "/".
$string .= '/' . $path;
// If the path is starting with more than one "/" and no authority is
// present, the starting slashes MUST be reduced to one.
} elseif (strncmp($path, '//', 2) === 0 && $authority === '') {
// If the path is starting with more than one "/" and no authority is
// present, the starting slashes MUST be reduced to one.
$string .= '/' . ltrim($path, '/');
// The path can be concatenated without delimiters
} else {
// The path can be concatenated without delimiters
$string .= $path;
}

Expand Down
4 changes: 1 addition & 3 deletions v1-compat/InvalidArgument.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
<?php
/**
* @source https://github.com/WordPress/Requests/blob/v2.0.0/src/Exception/InvalidArgument.php
*/

namespace WpOrg\Requests\Exception;

Expand All @@ -12,6 +9,7 @@
*
* @package Requests\Exceptions
* @since 2.0.0
* @source https://github.com/WordPress/Requests/blob/v2.0.12/src/Exception/InvalidArgument.php
*/
final class InvalidArgument extends InvalidArgumentException {

Expand Down
2 changes: 1 addition & 1 deletion v1-compat/Port.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*
* @package Requests\Utilities
* @since 2.0.0
* @source https://github.com/WordPress/Requests/blob/v2.0.0/src/Port.php
* @source https://github.com/WordPress/Requests/blob/v2.0.12/src/Port.php
*/

namespace WpOrg\Requests;
Expand Down

0 comments on commit 2c2f991

Please sign in to comment.