Skip to content

Commit

Permalink
Merge pull request #42 from weierophinney/feature/php-8.2-support
Browse files Browse the repository at this point in the history
Drop PHP 7, add PHP 8.2 support
  • Loading branch information
weierophinney authored Jul 11, 2023
2 parents 8a759df + 6c04cda commit 1936977
Show file tree
Hide file tree
Showing 16 changed files with 803 additions and 764 deletions.
16 changes: 9 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,21 @@
"sort-packages": true,
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true
},
"platform": {
"php": "8.0.99"
}
},
"require": {
"php": "^7.4 || ~8.0.0 || ~8.1.0",
"bshaffer/oauth2-server-php": "^1.12.1",
"laminas-api-tools/api-tools-api-problem": "^1.4",
"laminas-api-tools/api-tools-content-negotiation": "^1.7.0",
"php": "~8.0.0 || ~8.1.0 || ~8.2.0",
"bshaffer/oauth2-server-php": "^1.14.1",
"laminas-api-tools/api-tools-api-problem": "^1.5",
"laminas-api-tools/api-tools-content-negotiation": "^1.8.0",
"laminas/laminas-crypt": "^3.4",
"laminas/laminas-http": "^2.13",
"laminas/laminas-mvc": "^2.7.15 || ^3.0.2",
"laminas/laminas-mvc-i18n": "^1.2",
"laminas/laminas-servicemanager": "^3.1",
"laminas/laminas-zendframework-bridge": "^1.1",
"laminas/laminas-servicemanager": "^3.11",
"webmozart/assert": "^1.10"
},
"require-dev": {
Expand All @@ -48,7 +50,7 @@
"laminas/laminas-test": "^4.0.0",
"mockery/mockery": "^1.3.2",
"phpspec/prophecy-phpunit": "^2.0",
"phpunit/phpunit": "^9.3",
"phpunit/phpunit": "^9.5.10",
"psalm/plugin-phpunit": "^0.16",
"vimeo/psalm": "^4.23"
},
Expand Down
1,488 changes: 757 additions & 731 deletions composer.lock

Large diffs are not rendered by default.

34 changes: 20 additions & 14 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd" bootstrap="vendor/autoload.php" colors="true">
<coverage processUncoveredFiles="true">
<include>
<directory suffix=".php">./src</directory>
</include>
</coverage>
<testsuites>
<testsuite name="adapter-pdo">
<directory>./test/Adapter/Pdo</directory>
</testsuite>
<testsuite name="Laminas\ApiTools\OAuth2 Tests">
<directory>./test</directory>
</testsuite>
</testsuites>
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd"
bootstrap="vendor/autoload.php"
colors="true">
<coverage processUncoveredFiles="true">
<include>
<directory suffix=".php">./src</directory>
</include>
</coverage>

<testsuites>
<testsuite name="adapter-pdo">
<directory>./test/Adapter/Pdo</directory>
</testsuite>

<testsuite name="Laminas\ApiTools\OAuth2 Tests">
<directory>./test</directory>
</testsuite>
</testsuites>
</phpunit>
5 changes: 2 additions & 3 deletions src/Controller/AuthController.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
use RuntimeException;
use Webmozart\Assert\Assert;

use function get_class;
use function gettype;
use function is_callable;
use function is_object;
Expand Down Expand Up @@ -52,7 +51,7 @@ public function __construct($serverFactory, UserIdProviderInterface $userIdProvi
if (! is_callable($serverFactory)) {
throw new InvalidArgumentException(sprintf(
'OAuth2 Server factory must be a PHP callable; received %s',
is_object($serverFactory) ? get_class($serverFactory) : gettype($serverFactory)
is_object($serverFactory) ? $serverFactory::class : gettype($serverFactory)
));
}
$this->serverFactory = $serverFactory;
Expand Down Expand Up @@ -367,7 +366,7 @@ private function getOAuth2Server($type)
if (! $server instanceof OAuth2Server) {
throw new RuntimeException(sprintf(
'OAuth2\Server factory did not return a valid instance; received %s',
is_object($server) ? get_class($server) : gettype($server)
is_object($server) ? $server::class : gettype($server)
));
}
$this->server = $server;
Expand Down
2 changes: 1 addition & 1 deletion src/Factory/AuthControllerFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@

namespace Laminas\ApiTools\OAuth2\Factory;

use Interop\Container\ContainerInterface; // phpcs:ignore WebimpressCodingStandard.PHP.CorrectClassNameCase.Invalid
use Laminas\ApiTools\OAuth2\Controller\AuthController;
use Laminas\ApiTools\OAuth2\Provider\UserId;
use Laminas\ServiceManager\FactoryInterface;
use Laminas\ServiceManager\ServiceLocatorInterface;
use OAuth2\Server as OAuth2Server;
use Psr\Container\ContainerInterface;

class AuthControllerFactory implements FactoryInterface
{
Expand Down
2 changes: 1 addition & 1 deletion src/Factory/MongoAdapterFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
namespace Laminas\ApiTools\OAuth2\Factory;

use ArrayAccess;
use Interop\Container\ContainerInterface; // phpcs:ignore WebimpressCodingStandard.PHP.CorrectClassNameCase.Invalid
use Laminas\ApiTools\OAuth2\Adapter\MongoAdapter;
use Laminas\ApiTools\OAuth2\Controller\Exception;
use Laminas\ServiceManager\ServiceLocatorInterface;
use MongoClient;
use MongoDB;
use Psr\Container\ContainerInterface;

use function is_array;

Expand Down
2 changes: 1 addition & 1 deletion src/Factory/OAuth2ServerFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

namespace Laminas\ApiTools\OAuth2\Factory;

use Interop\Container\ContainerInterface; // phpcs:ignore WebimpressCodingStandard.PHP.CorrectClassNameCase.Invalid
use Laminas\ServiceManager\ServiceLocatorInterface;
use Psr\Container\ContainerInterface;

class OAuth2ServerFactory
{
Expand Down
2 changes: 1 addition & 1 deletion src/Factory/OAuth2ServerInstanceFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@

namespace Laminas\ApiTools\OAuth2\Factory;

use Interop\Container\ContainerInterface; // phpcs:ignore WebimpressCodingStandard.PHP.CorrectClassNameCase.Invalid
use Laminas\ApiTools\OAuth2\Controller\Exception;
use OAuth2\GrantType\AuthorizationCode;
use OAuth2\GrantType\ClientCredentials;
use OAuth2\GrantType\JwtBearer;
use OAuth2\GrantType\RefreshToken;
use OAuth2\GrantType\UserCredentials;
use OAuth2\Server as OAuth2Server;
use Psr\Container\ContainerInterface;

use function array_merge;
use function is_array;
Expand Down
2 changes: 1 addition & 1 deletion src/Factory/PdoAdapterFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

namespace Laminas\ApiTools\OAuth2\Factory;

use Interop\Container\ContainerInterface; // phpcs:ignore WebimpressCodingStandard.PHP.CorrectClassNameCase.Invalid
use Laminas\ApiTools\OAuth2\Adapter\PdoAdapter;
use Laminas\ApiTools\OAuth2\Controller\Exception;
use Laminas\ServiceManager\ServiceLocatorInterface;
use Psr\Container\ContainerInterface;

use function is_array;

Expand Down
2 changes: 1 addition & 1 deletion src/Provider/UserId/AuthenticationServiceFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

namespace Laminas\ApiTools\OAuth2\Provider\UserId;

use Interop\Container\ContainerInterface; // phpcs:ignore WebimpressCodingStandard.PHP.CorrectClassNameCase.Invalid
use Laminas\ServiceManager\ServiceLocatorInterface;
use Psr\Container\ContainerInterface;

class AuthenticationServiceFactory
{
Expand Down
5 changes: 2 additions & 3 deletions test/Adapter/Pdo/ScopeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
use OAuth2\Storage\ScopeInterface;

use function explode;
use function get_class;
use function sort;
use function sprintf;

Expand All @@ -28,7 +27,7 @@ public function testScopeExists(object $storage): void
// incompatible storage
$this->markTestSkipped(sprintf(
'Skipped Storage of type %s; does not implement %s ',
get_class($storage),
$storage::class,
ScopeInterface::class
));
return;
Expand All @@ -55,7 +54,7 @@ public function testGetDefaultScope(object $storage): void
// incompatible storage
$this->markTestSkipped(sprintf(
'Skipped Storage of type %s; does not implement %s ',
get_class($storage),
$storage::class,
ScopeInterface::class
));
return;
Expand Down
1 change: 1 addition & 0 deletions test/TestAsset/custom.application.config.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
$modules = [
'Laminas\ApiTools\ContentNegotiation',
'Laminas\ApiTools\OAuth2',
'Laminas\Mvc\I18n',
];

if (class_exists(Module::class)) {
Expand Down
2 changes: 2 additions & 0 deletions test/TestAsset/database/db_oauth2.sql
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ CREATE TABLE oauth_authorization_codes (
authorization_code VARCHAR(40) NOT NULL,
client_id VARCHAR(80) NOT NULL,
user_id VARCHAR(255),
code_challenge VARCHAR(255),
code_challenge_method VARCHAR(64),
redirect_uri VARCHAR(2000),
expires TIMESTAMP NOT NULL,
scope VARCHAR(2000), id_token VARCHAR(2000),
Expand Down
Binary file modified test/TestAsset/database/pdo.db
Binary file not shown.
2 changes: 2 additions & 0 deletions test/TestAsset/database/pdo.sql
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ CREATE TABLE oauth_authorization_codes (
authorization_code VARCHAR(40) NOT NULL,
client_id VARCHAR(80) NOT NULL,
user_id VARCHAR(255),
code_challenge VARCHAR(255),
code_challenge_method VARCHAR(64),
redirect_uri VARCHAR(2000),
expires TIMESTAMP NOT NULL,
scope VARCHAR(2000), id_token VARCHAR(2000),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
$modules = [
'Laminas\ApiTools\ContentNegotiation',
'Laminas\ApiTools\OAuth2',
'Laminas\Mvc\I18n',
'Laminas\I18n',
];

if (class_exists(Module::class)) {
Expand Down

0 comments on commit 1936977

Please sign in to comment.