Skip to content

Commit

Permalink
Fix BC-break for combination of PHP 7.4 and lcobucci/jwt 3.4
Browse files Browse the repository at this point in the history
Fixes #24
  • Loading branch information
tjveldhuizen committed Feb 17, 2021
1 parent 95cc38c commit eb4d697
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 4 deletions.
11 changes: 11 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,23 @@ language: php
matrix:
include:
- php: 5.6
env: LCOBUCCI_JWT_VERSION=^3.4
- php: 7.0
env: LCOBUCCI_JWT_VERSION=^3.4
- php: 7.1
env: LCOBUCCI_JWT_VERSION=^3.4
- php: 7.2
env: LCOBUCCI_JWT_VERSION=^3.4
- php: 7.3
env: LCOBUCCI_JWT_VERSION=^3.4
- php: 7.4
env: LCOBUCCI_JWT_VERSION=^3.4
- php: 7.4
env: LCOBUCCI_JWT_VERSION=^4.0
- php: 8.0
env: LCOBUCCI_JWT_VERSION=^4.0
- php: nightly
env: LCOBUCCI_JWT_VERSION=^4.0
- php: hhvm-3.6
sudo: required
dist: trusty
Expand Down Expand Up @@ -41,6 +51,7 @@ matrix:

before_script:
- travis_retry composer self-update
- travis_retry composer require lcobucci/jwt $LCOBUCCI_JWT_VERSION
- travis_retry composer install --no-interaction --prefer-source --dev
- travis_retry phpenv rehash

Expand Down
15 changes: 11 additions & 4 deletions src/Provider/Apple.php
Original file line number Diff line number Diff line change
Expand Up @@ -237,10 +237,17 @@ public function getAccessToken($grant, array $options = [])
*/
public function getConfiguration()
{
return Configuration::forSymmetricSigner(
Signer\Ecdsa\Sha256::create(),
$this->getLocalKey()
);
if (method_exists(Signer\Ecdsa\Sha256::class, 'create')) {
return Configuration::forSymmetricSigner(
Signer\Ecdsa\Sha256::create(),
$this->getLocalKey()
);
} else {
return Configuration::forSymmetricSigner(
new Signer\Ecdsa\Sha256(),
$this->getLocalKey()
);
}
}

/**
Expand Down
9 changes: 9 additions & 0 deletions test/src/Provider/AppleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use GuzzleHttp\ClientInterface;
use GuzzleHttp\Psr7\Response;
use Lcobucci\JWT\Configuration;
use Lcobucci\JWT\Signer\Key;
use League\OAuth2\Client\Provider\Apple;
use League\OAuth2\Client\Provider\AppleResourceOwner;
use League\OAuth2\Client\Token\AccessToken;
Expand Down Expand Up @@ -245,4 +246,12 @@ public function testCreationOfResourceOwner()
$this->assertFalse($data->isPrivateEmail());
$this->assertArrayHasKey('name', $data->toArray());
}

public function testGetConfiguration()
{
$provider = m::mock(Apple::class)->makePartial();
$provider->shouldReceive('getLocalKey')->andReturn(m::mock(Key::class));

$this->assertInstanceOf(Configuration::class, $provider->getConfiguration());
}
}

0 comments on commit eb4d697

Please sign in to comment.