Skip to content

Commit

Permalink
Upgrade to PHP 8.1
Browse files Browse the repository at this point in the history
  • Loading branch information
MilesChou committed May 12, 2023
1 parent 44c3380 commit 381aeec
Show file tree
Hide file tree
Showing 24 changed files with 192 additions and 153 deletions.
2 changes: 1 addition & 1 deletion .codacy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
engines:
phpcs:
enabled: true
php_version: 7.1
php_version: 8.1
exclude_paths:
- 'tests/**'
46 changes: 46 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: tests

on:
pull_request:
push:
branches:
- master

jobs:
linux_tests:
runs-on: ubuntu-latest

strategy:
fail-fast: true
matrix:
php: [ 8.2, 8.1 ]
stability: [ prefer-lowest, prefer-stable ]

name: PHP ${{ matrix.php }} - ${{ matrix.stability }}

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
tools: composer:v2
coverage: xdebug

- name: Install dependencies
uses: nick-invision/retry@v2
with:
timeout_minutes: 5
max_attempts: 5
command: composer update --${{ matrix.stability }} --prefer-dist --no-interaction --no-progress

- name: Execute phpcs
run: php vendor/bin/phpcs

- name: Execute tests
run: php -d xdebug.mode=coverage vendor/bin/phpunit

- name: Code coverage
uses: codecov/codecov-action@v3
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,4 @@ Desktop.ini
# Artifacts files
/build
/.phpunit.result.cache
/.phpunit.cache
30 changes: 0 additions & 30 deletions .travis.yml

This file was deleted.

28 changes: 14 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
#!/usr/bin/make -f

PHP_MAJOR_VERSION := $(shell php -r "echo PHP_MAJOR_VERSION;")
PROCESSORS_NUM := $(shell getconf _NPROCESSORS_ONLN)
GLOBAL_CONFIG := -d memory_limit=-1

.PHONY: all clean clean-all check test analyse coverage
# -----------------------------------------------------------------------------

# ---------------------------------------------------------------------

all: test analyse
.PHONY: all
all: check test

.PHONY: clean
clean:
rm -rf ./build

.PHONY: clean-all
clean-all: clean
rm -rf ./vendor
rm -rf ./composer.lock

.PHONY: check
check:
php vendor/bin/phpcs
mkdir -p build
php ${GLOBAL_CONFIG} vendor/bin/phpcs --parallel=${PROCESSORS_NUM} --report-junit=build/phpcs.xml

test: clean check
ifeq ($(PHP_MAJOR_VERSION), 7)
phpdbg -qrr vendor/bin/phpunit
else
php vendor/bin/phpunit
endif

analyse:
php vendor/bin/phpstan analyse src --level=max
.PHONY: test
test: clean
php -d xdebug.mode=coverage vendor/bin/phpunit

.PHONY: coverage
coverage: test
@if [ "`uname`" = "Darwin" ]; then open build/coverage/index.html; fi
19 changes: 8 additions & 11 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,21 @@
"issues": "https://github.com/oidcphp/oauth2/issues"
},
"require": {
"php": ">=7.1",
"php": "^8.1",
"ext-json": "*",
"psr/http-client": "^1.0",
"psr/http-factory": "^1.0",
"psr/http-message": "^1.0"
},
"require-dev": {
"codacy/coverage": "^1.4",
"guzzlehttp/guzzle": "^6.4",
"http-interop/http-factory-guzzle": "^1.0",
"illuminate/container": "^5.6 | ^6 | ^7",
"illuminate/support": "^5.6 | ^6 | ^7",
"guzzlehttp/guzzle": "^7.5",
"guzzlehttp/psr7": "^2.5",
"illuminate/container": "^9 | ^10",
"illuminate/support": "^9 | ^10",
"laminas/laminas-diactoros": "^2.2",
"mileschou/mocker": "^0.1.0",
"php-http/guzzle6-adapter": "^2.0",
"phpstan/phpstan": "^0.12",
"phpunit/phpunit": "^7 | ^8",
"squizlabs/php_codesniffer": "^3.5"
"mileschou/mocker": "^1.1",
"phpunit/phpunit": "^10",
"squizlabs/php_codesniffer": "^3.7"
},
"autoload": {
"psr-4": {
Expand Down
49 changes: 27 additions & 22 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,27 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.1/phpunit.xsd"
backupGlobals="false"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false">
<testsuites>
<testsuite name="Unit">
<directory suffix="Test.php">./tests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./src</directory>
</whitelist>
</filter>
<logging>
<log type="testdox-text" target="build/testdox/executed.txt" />
<log type="coverage-clover" target="build/logs/clover.xml" />
<log type="coverage-html" target="build/coverage" />
<log type="junit" target="build/phpunit/phpunit.xml" />
</logging>
stopOnFailure="false"
cacheDirectory=".phpunit.cache"
backupStaticProperties="false"
>
<coverage>
<report>
<clover outputFile="build/logs/clover.xml"/>
<html outputDirectory="build/coverage"/>
</report>
</coverage>
<testsuites>
<testsuite name="Unit">
<directory suffix="Test.php">./tests</directory>
</testsuite>
</testsuites>
<logging>
<testdoxText outputFile="build/testdox/executed.txt"/>
<junit outputFile="build/phpunit/junit.xml"/>
</logging>
<source>
<include>
<directory suffix=".php">./src</directory>
</include>
</source>
</phpunit>
10 changes: 7 additions & 3 deletions src/OAuth2/Builder/AuthorizationFormResponseBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

use DomainException;
use OpenIDConnect\OAuth2\Exceptions\OAuth2ServerException;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
use Psr\Http\Message\ResponseFactoryInterface;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\StreamFactoryInterface;
Expand All @@ -15,8 +17,10 @@ class AuthorizationFormResponseBuilder
use BuilderTrait;

/**
* @param array<mixed> $parameters
* @param array $parameters
* @return ResponseInterface
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
public function build(array $parameters): ResponseInterface
{
Expand All @@ -31,7 +35,7 @@ public function build(array $parameters): ResponseInterface
}

/**
* @param array<mixed> $parameters
* @param array $parameters
* @return string
*/
private function generateForm(array $parameters): string
Expand All @@ -45,7 +49,7 @@ private function generateForm(array $parameters): string

/**
* @param string $url
* @param array<mixed> $parameters
* @param array $parameters
* @return string
*/
private function generateHtml(string $url, array $parameters): string
Expand Down
6 changes: 5 additions & 1 deletion src/OAuth2/Builder/AuthorizationRedirectResponseBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
namespace OpenIDConnect\OAuth2\Builder;

use OpenIDConnect\OAuth2\Utils\Query;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
use Psr\Http\Message\ResponseFactoryInterface;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\UriFactoryInterface;
Expand Down Expand Up @@ -32,8 +34,10 @@ public function build(array $parameters): ResponseInterface
}

/**
* @param array<mixed> $parameters
* @param array $parameters
* @return UriInterface
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
private function createAuthorizeUri(array $parameters): UriInterface
{
Expand Down
2 changes: 1 addition & 1 deletion src/OAuth2/Builder/BuilderTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ trait BuilderTrait
/**
* @var ContainerInterface
*/
protected $container;
protected ContainerInterface $container;

/**
* @param ContainerInterface $container
Expand Down
6 changes: 5 additions & 1 deletion src/OAuth2/Builder/TokenRequestBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
use OpenIDConnect\OAuth2\ClientAuthentication\ClientAuthenticationAwareTrait;
use OpenIDConnect\OAuth2\Grant\GrantType;
use OpenIDConnect\OAuth2\Utils\Query;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
use Psr\Http\Message\RequestFactoryInterface;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\StreamFactoryInterface;
Expand All @@ -23,8 +25,10 @@ class TokenRequestBuilder

/**
* @param GrantType $grantType
* @param array<mixed> $parameters
* @param array $parameters
* @return RequestInterface
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
public function build(GrantType $grantType, array $parameters): RequestInterface
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ trait ClientAuthenticationAwareTrait
/**
* @var ClientAuthentication|null
*/
protected $clientAuthentication;
protected ?ClientAuthentication $clientAuthentication = null;

/**
* Default method for client authentication is ClientSecretBasic
Expand All @@ -31,7 +31,7 @@ public function resolveClientAuthenticationByDefault(string $clientId, string $c
* @param ClientAuthentication|null $clientAuthentication
* @return static
*/
public function setClientAuthentication(?ClientAuthentication $clientAuthentication)
public function setClientAuthentication(?ClientAuthentication $clientAuthentication): static
{
$this->clientAuthentication = $clientAuthentication;

Expand Down
4 changes: 2 additions & 2 deletions src/OAuth2/ClientAuthentication/ClientSecretBasic.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ class ClientSecretBasic implements ClientAuthentication
/**
* @var string
*/
private $client;
private string $client;

/**
* @var string
*/
private $secret;
private string $secret;

/**
* @param string $client
Expand Down
4 changes: 2 additions & 2 deletions src/OAuth2/ClientAuthentication/ClientSecretPost.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ class ClientSecretPost implements ClientAuthentication
/**
* @var string
*/
private $client;
private string $client;

/**
* @var string
*/
private $secret;
private string $secret;

/**
* @param string $client
Expand Down
4 changes: 2 additions & 2 deletions src/OAuth2/Metadata/ClientInformationAwaitTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ trait ClientInformationAwaitTrait
/**
* @var ClientInformation
*/
protected $clientInformation;
protected ClientInformation $clientInformation;

/**
* @param ClientInformation $clientInformation
* @return static
*/
public function setClientInformation(ClientInformation $clientInformation)
public function setClientInformation(ClientInformation $clientInformation): static
{
$this->clientInformation = $clientInformation;

Expand Down
2 changes: 1 addition & 1 deletion src/OAuth2/Metadata/ClientMetadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class ClientMetadata implements JsonSerializable
use ParameterTrait;

/**
* @param array<mixed> $metadata
* @param array $metadata
*/
public function __construct(array $metadata = [])
{
Expand Down

0 comments on commit 381aeec

Please sign in to comment.