Skip to content

Commit

Permalink
feature #180 Support Doctrine ORM 3.0 (wmouwen)
Browse files Browse the repository at this point in the history
This PR was squashed before being merged into the 0.4-dev branch.

Discussion
----------

Support Doctrine ORM 3.0

Doctrine ORM v3.0.0 has been released.
https://github.com/doctrine/orm/releases/tag/3.0.0

Upgrade the minimal version of the ORM to v2.14, allow v3.0 as well. This matches the version requirement as used by [doctrine/doctrine-fixtures-bundle](https://github.com/doctrine/DoctrineFixturesBundle/blob/6c3253bfd071b57fac9a5b02cd7b1e5b9803148e/composer.json#L26).

Update the GitHub workflows to test against v2.14, v2.18 and v3.0.

Commits
-------

0cd73a8 Support Doctrine ORM 3.0
  • Loading branch information
chalasr committed Mar 10, 2024
2 parents e4d5221 + 0cd73a8 commit a094e60
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 81 deletions.
11 changes: 10 additions & 1 deletion .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,24 @@ jobs:
static-analysis:
name: "static analysis"
runs-on: "ubuntu-latest"
strategy:
fail-fast: false
matrix:
doctrine-orm: ['2.14.*', '2.18.*', '3.0.*']
composer-flags: ['--prefer-stable']

steps:
- name: "checkout"
uses: "actions/checkout@v4"

- name: "build the environment"
run: "dev/bin/docker-compose build"

- name: "require specific Doctrine ORM version"
run: "dev/bin/php composer require --ansi ${{ matrix.composer-flags }} doctrine/orm:${{ matrix.doctrine-orm }}"

- name: "install dependencies"
run: "dev/bin/php composer update --prefer-stable"
run: "dev/bin/php composer update --ansi ${{ matrix.composer-flags }}"

- name: "run static analysis"
run: "dev/bin/php psalm --shepherd --stats"
Expand Down
10 changes: 9 additions & 1 deletion .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,18 @@ jobs:
matrix:
php: ['8.1', '8.2', '8.3']
symfony: ['5.4.*', '6.4.*', '7.0.*']
doctrine-orm: ['2.14.*', '2.18.*', '3.0.*']
composer-flags: ['--prefer-stable']
can-fail: [false]
exclude:
- php: "8.1"
symfony: "7.0.*"
- doctrine-orm: "2.14.*"
symfony: "6.4.*"
- doctrine-orm: "2.14.*"
symfony: "7.0.*"

name: "PHP ${{ matrix.php }} - Symfony ${{ matrix.symfony }}${{ matrix.composer-flags != '' && format(' - Composer {0}', matrix.composer-flags) || '' }}"
name: "PHP ${{ matrix.php }} - Doctrine ${{ matrix.doctrine-orm }} - Symfony ${{ matrix.symfony }}${{ matrix.composer-flags != '' && format(' - Composer {0}', matrix.composer-flags) || '' }}"

env:
SYMFONY_REQUIRE: ${{ matrix.symfony }}
Expand All @@ -34,6 +39,9 @@ jobs:
- name: "build the PHP environment"
run: "dev/bin/docker-compose build --build-arg PHP_VERSION=${{ matrix.php }} --build-arg XDEBUG_VERSION='3.3.1' php"

- name: "require specific Doctrine ORM version"
run: "dev/bin/php composer require --ansi ${{ matrix.composer-flags }} doctrine/orm:${{ matrix.doctrine-orm }}"

- name: "install dependencies"
run: "dev/bin/php composer update --ansi ${{ matrix.composer-flags }}"

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"require": {
"php": "^8.1",
"doctrine/doctrine-bundle": "^2.0.8",
"doctrine/orm": "^2.7.1",
"doctrine/orm": "^2.14|^3.0",
"league/oauth2-server": "^8.3",
"nyholm/psr7": "^1.4",
"psr/http-factory": "^1.0",
Expand Down
48 changes: 12 additions & 36 deletions src/Model/AbstractClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,45 +15,21 @@
*/
abstract class AbstractClient implements ClientInterface
{
/**
* @var string
*/
private $name;
private string $name;
protected string $identifier;
private ?string $secret;

/**
* @var string
*/
protected $identifier;
/** @var list<RedirectUri> */
private array $redirectUris = [];

/**
* @var string|null
*/
private $secret;
/** @var list<Grant> */
private array $grants = [];

/**
* @var list<RedirectUri>
*/
private $redirectUris = [];
/** @var list<Scope> */
private array $scopes = [];

/**
* @var list<Grant>
*/
private $grants = [];

/**
* @var list<Scope>
*/
private $scopes = [];

/**
* @var bool
*/
private $active = true;

/**
* @var bool
*/
private $allowPlainTextPkce = false;
private bool $active = true;
private bool $allowPlainTextPkce = false;

/**
* @psalm-mutation-free
Expand Down Expand Up @@ -165,7 +141,7 @@ public function setActive(bool $active): ClientInterface
*/
public function isConfidential(): bool
{
return !empty($this->secret);
return null !== $this->secret && '' !== $this->secret;
}

/**
Expand Down
23 changes: 4 additions & 19 deletions src/Model/RefreshToken.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,10 @@

class RefreshToken implements RefreshTokenInterface
{
/**
* @var string
*/
private $identifier;

/**
* @var \DateTimeInterface
*/
private $expiry;

/**
* @var AccessTokenInterface|null
*/
private $accessToken;

/**
* @var bool
*/
private $revoked = false;
private string $identifier;
private \DateTimeInterface $expiry;
private ?AccessTokenInterface $accessToken;
private bool $revoked = false;

/**
* @psalm-mutation-free
Expand Down
23 changes: 4 additions & 19 deletions src/Security/Authenticator/OAuth2Authenticator.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,25 +36,10 @@ final class OAuth2Authenticator implements AuthenticatorInterface, Authenticatio
*/
use ForwardCompatAuthenticatorTrait;

/**
* @var HttpMessageFactoryInterface
*/
private $httpMessageFactory;

/**
* @var ResourceServer
*/
private $resourceServer;

/**
* @var UserProviderInterface
*/
private $userProvider;

/**
* @var string
*/
private $rolePrefix;
private HttpMessageFactoryInterface $httpMessageFactory;
private ResourceServer $resourceServer;
private UserProviderInterface $userProvider;
private string $rolePrefix;

public function __construct(
HttpMessageFactoryInterface $httpMessageFactory,
Expand Down
5 changes: 1 addition & 4 deletions src/Security/Exception/OAuth2AuthenticationException.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@
*/
class OAuth2AuthenticationException extends AuthenticationException implements HttpExceptionInterface
{
/**
* @var int
*/
private $statusCode;
private int $statusCode;

public function __construct(string $message, int $statusCode, ?\Throwable $previous = null)
{
Expand Down

0 comments on commit a094e60

Please sign in to comment.