Skip to content

Commit

Permalink
chore: drop support for PHP 7.4
Browse files Browse the repository at this point in the history
  • Loading branch information
bshaffer committed Feb 20, 2024
1 parent 155c61a commit 050bcb6
Show file tree
Hide file tree
Showing 11 changed files with 33 additions and 53 deletions.
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.0", "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.0"
- 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.0",
"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';
}
}
25 changes: 8 additions & 17 deletions tests/Cache/ItemTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,25 +23,16 @@

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 +41,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 +52,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 +73,7 @@ public function values()

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

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

Expand All @@ -93,7 +84,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 +101,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 @@ -20,6 +20,7 @@
use Google\Auth\Cache\MemoryCacheItemPool;
use Google\Auth\Tests\BaseTest;
use Psr\Cache\InvalidArgumentException;
use Google\Auth\Cache\TypedItem;

class MemoryCacheItemPoolTest extends BaseTest
{
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 @@ -19,6 +19,7 @@

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

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
6 changes: 1 addition & 5 deletions tests/Cache/sysv_cache_creator.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@
$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);

0 comments on commit 050bcb6

Please sign in to comment.