Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: drop support for PHP 8.0 #532

Merged
merged 4 commits into from
Oct 3, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
- main
tags:
- "*"
workflow_dispatch:
workflow_dispatch:

jobs:
docs:
Expand All @@ -18,7 +18,7 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 7.4
php-version: 8.1
- name: Install Dependencies
uses: nick-invision/retry@v3
with:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ on:
push:
branches: [ main ]
pull_request:

permissions:
contents: read
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
php: [ "7.4", "8.0", "8.1", "8.2", "8.3" ]
php: [ "8.1", "8.2", "8.3" ]
name: PHP ${{matrix.php }} Unit Test
steps:
- uses: actions/checkout@v4
Expand All @@ -35,7 +35,7 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: "7.4"
php-version: "8.1"
- name: Install Dependencies
uses: nick-invision/retry@v3
with:
Expand Down
15 changes: 8 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,22 @@
"docs": "https://googleapis.github.io/google-auth-library-php/main/"
},
"require": {
"php": "^7.4||^8.0",
"php": "^8.1",
"firebase/php-jwt": "^6.0",
"guzzlehttp/guzzle": "^6.5.8||^7.4.5",
"guzzlehttp/guzzle": "^7.4.5",
"guzzlehttp/psr7": "^2.4.5",
"psr/http-message": "^1.1||^2.0",
"psr/cache": "^1.0||^2.0||^3.0"
"psr/cache": "^2.0||^3.0"
},
"require-dev": {
"guzzlehttp/promises": "^2.0",
"squizlabs/php_codesniffer": "^3.5",
"phpunit/phpunit": "^9.0.0",
"phpspec/prophecy-phpunit": "^2.0",
"phpunit/phpunit": "^9.6",
"phpspec/prophecy-phpunit": "^2.1",
"sebastian/comparator": ">=1.2.3",
"phpseclib/phpseclib": "^3.0",
"kelvinmo/simplejwt": "0.7.1"
"phpseclib/phpseclib": "^3.0.35",
"kelvinmo/simplejwt": "0.7.1",
"webmozart/assert": "^1.11"
},
"suggest": {
"phpseclib/phpseclib": "May be used in place of OpenSSL for signing strings or for token management. Please require version ^2."
Expand Down
1 change: 1 addition & 0 deletions src/Cache/Item.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
*
* This class will be used by MemoryCacheItemPool and SysVCacheItemPool
* on PHP 7.4 and below. It is compatible with psr/cache 1.0 and 2.0 (PSR-6).
* @deprecated
* @see TypedItem for compatiblity with psr/cache 3.0.
*/
final class Item implements CacheItemInterface
Expand Down
3 changes: 1 addition & 2 deletions src/Cache/MemoryCacheItemPool.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,8 @@ public function getItem($key): CacheItemInterface
public function getItems(array $keys = []): iterable
{
$items = [];
$itemClass = \PHP_VERSION_ID >= 80000 ? TypedItem::class : Item::class;
foreach ($keys as $key) {
$items[$key] = $this->hasItem($key) ? clone $this->items[$key] : new $itemClass($key);
$items[$key] = $this->hasItem($key) ? clone $this->items[$key] : new TypedItem($key);
}

return $items;
Expand Down
3 changes: 1 addition & 2 deletions src/Cache/SysVCacheItemPool.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,10 @@ public function getItems(array $keys = []): iterable
{
$this->loadItems();
$items = [];
$itemClass = \PHP_VERSION_ID >= 80000 ? TypedItem::class : Item::class;
foreach ($keys as $key) {
$items[$key] = $this->hasItem($key) ?
clone $this->items[$key] :
new $itemClass($key);
new TypedItem($key);
}
return $items;
}
Expand Down
9 changes: 0 additions & 9 deletions tests/BaseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,4 @@ public function getValidKeyName($key)
{
return preg_replace('|[^a-zA-Z0-9_\.! ]|', '', $key);
}

protected function getCacheItemClass()
{
if (\PHP_VERSION_ID >= 80000) {
return 'Google\Auth\Cache\TypedItem';
}

return 'Google\Auth\Cache\Item';
}
}
26 changes: 8 additions & 18 deletions tests/Cache/ItemTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,31 +17,21 @@

namespace Google\Auth\Tests\Cache;

use Google\Auth\Cache\Item;
use Google\Auth\Cache\TypedItem;
use PHPUnit\Framework\TestCase;

class ItemTest extends TestCase
{
public function getItem($key)
{
if (\PHP_VERSION_ID >= 80000) {
return new TypedItem($key);
}

return new Item($key);
}

public function testGetsKey()
{
$key = 'item';
$item = new TypedItem('item');

$this->assertEquals($key, $this->getItem($key)->getKey());
$this->assertEquals('item', $item->getKey());
}

public function testGetsNull()
{
$item = $this->getItem('item');
$item = new TypedItem('item');

$this->assertNull($item->get());
$this->assertFalse($item->isHit());
Expand All @@ -50,7 +40,7 @@ public function testGetsNull()
public function testGetsValue()
{
$value = 'value';
$item = $this->getItem('item');
$item = new TypedItem('item');
$item->set($value);

$this->assertEquals('value', $item->get());
Expand All @@ -61,7 +51,7 @@ public function testGetsValue()
*/
public function testSetsValue($value)
{
$item = $this->getItem('item');
$item = new TypedItem('item');
$item->set($value);

$this->assertEquals($value, $item->get());
Expand All @@ -82,7 +72,7 @@ public function values()

public function testIsHit()
{
$item = $this->getItem('item');
$item = new TypedItem('item');

$this->assertFalse($item->isHit());

Expand All @@ -93,7 +83,7 @@ public function testIsHit()

public function testExpiresAt()
{
$item = $this->getItem('item');
$item = new TypedItem('item');
$item->set('value');
$item->expiresAt(new \DateTime('now + 1 hour'));

Expand All @@ -110,7 +100,7 @@ public function testExpiresAt()

public function testExpiresAfter()
{
$item = $this->getItem('item');
$item = new TypedItem('item');
$item->set('value');
$item->expiresAfter(30);

Expand Down
7 changes: 4 additions & 3 deletions tests/Cache/MemoryCacheItemPoolTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
namespace Google\Auth\Tests\Cache;

use Google\Auth\Cache\MemoryCacheItemPool;
use Google\Auth\Cache\TypedItem;
use Google\Auth\Tests\BaseTest;
use Psr\Cache\InvalidArgumentException;

Expand All @@ -43,7 +44,7 @@ public function testGetsFreshItem()
{
$item = $this->pool->getItem('item');

$this->assertInstanceOf($this->getCacheItemClass(), $item);
$this->assertInstanceOf(TypedItem::class, $item);
$this->assertNull($item->get());
$this->assertFalse($item->isHit());
}
Expand All @@ -55,7 +56,7 @@ public function testGetsExistingItem()
$this->saveItem($key, $value);
$item = $this->pool->getItem($key);

$this->assertInstanceOf($this->getCacheItemClass(), $item);
$this->assertInstanceOf(TypedItem::class, $item);
$this->assertEquals($value, $item->get());
$this->assertTrue($item->isHit());
}
Expand All @@ -66,7 +67,7 @@ public function testGetsMultipleItems()
$items = $this->pool->getItems($keys);

$this->assertEquals($keys, array_keys($items));
$this->assertContainsOnlyInstancesOf($this->getCacheItemClass(), $items);
$this->assertContainsOnlyInstancesOf(TypedItem::class, $items);
}

public function testHasItem()
Expand Down
7 changes: 4 additions & 3 deletions tests/Cache/SysVCacheItemPoolTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
namespace Google\Auth\Tests\Cache;

use Google\Auth\Cache\SysVCacheItemPool;
use Google\Auth\Cache\TypedItem;
use Google\Auth\Tests\BaseTest;

class SysVCacheItemPoolTest extends BaseTest
Expand Down Expand Up @@ -48,7 +49,7 @@ public function testGetsFreshItem()
{
$item = $this->pool->getItem('item');

$this->assertInstanceOf($this->getCacheItemClass(), $item);
$this->assertInstanceOf(TypedItem::class, $item);
$this->assertNull($item->get());
$this->assertFalse($item->isHit());
}
Expand All @@ -70,7 +71,7 @@ public function testGetsExistingItem()
$this->saveItem($key, $value);
$item = $this->pool->getItem($key);

$this->assertInstanceOf($this->getCacheItemClass(), $item);
$this->assertInstanceOf(TypedItem::class, $item);
$this->assertEquals($value, $item->get());
$this->assertTrue($item->isHit());
}
Expand All @@ -81,7 +82,7 @@ public function testGetsMultipleItems()
$items = $this->pool->getItems($keys);

$this->assertEquals($keys, array_keys($items));
$this->assertContainsOnlyInstancesOf($this->getCacheItemClass(), $items);
$this->assertContainsOnlyInstancesOf(TypedItem::class, $items);
}

public function testHasItem()
Expand Down
7 changes: 1 addition & 6 deletions tests/Cache/sysv_cache_creator.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,12 @@

require_once __DIR__ . '/../../vendor/autoload.php';

use Google\Auth\Cache\Item;
use Google\Auth\Cache\SysVCacheItemPool;
use Google\Auth\Cache\TypedItem;

$value = $argv[1];
// Use the same variableKey in the test.
$pool = new SysVCacheItemPool(['variableKey' => 99]);
if (\PHP_VERSION_ID >= 80000) {
$item = new TypedItem('separate-process-item');
} else {
$item = new Item('separate-process-item');
}
$item = new TypedItem('separate-process-item');
$item->set($value);
$pool->save($item);