Skip to content

Commit 3bcd1fc

Browse files
authored
chore: drop support for PHP 7.4 (#538)
1 parent 309e865 commit 3bcd1fc

11 files changed

Lines changed: 33 additions & 55 deletions

.github/workflows/docs.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ on:
55
- main
66
tags:
77
- "*"
8-
workflow_dispatch:
8+
workflow_dispatch:
99

1010
jobs:
1111
docs:
@@ -18,7 +18,7 @@ jobs:
1818
- name: Setup PHP
1919
uses: shivammathur/setup-php@v2
2020
with:
21-
php-version: 7.4
21+
php-version: 8.1
2222
- name: Install Dependencies
2323
uses: nick-invision/retry@v3
2424
with:

.github/workflows/tests.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@ on:
33
push:
44
branches: [ main ]
55
pull_request:
6-
6+
77
permissions:
88
contents: read
99
jobs:
1010
test:
1111
runs-on: ubuntu-latest
1212
strategy:
1313
matrix:
14-
php: [ "7.4", "8.0", "8.1", "8.2", "8.3" ]
14+
php: [ "8.0", "8.1", "8.2", "8.3" ]
1515
name: PHP ${{matrix.php }} Unit Test
1616
steps:
1717
- uses: actions/checkout@v4
@@ -35,7 +35,7 @@ jobs:
3535
- name: Setup PHP
3636
uses: shivammathur/setup-php@v2
3737
with:
38-
php-version: "7.4"
38+
php-version: "8.0"
3939
- name: Install Dependencies
4040
uses: nick-invision/retry@v3
4141
with:

composer.json

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,22 @@
99
"docs": "https://googleapis.github.io/google-auth-library-php/main/"
1010
},
1111
"require": {
12-
"php": "^7.4||^8.0",
12+
"php": "^8.0",
1313
"firebase/php-jwt": "^6.0",
14-
"guzzlehttp/guzzle": "^6.5.8||^7.4.5",
14+
"guzzlehttp/guzzle": "^7.4.5",
1515
"guzzlehttp/psr7": "^2.4.5",
1616
"psr/http-message": "^1.1||^2.0",
17-
"psr/cache": "^1.0||^2.0||^3.0"
17+
"psr/cache": "^2.0||^3.0"
1818
},
1919
"require-dev": {
2020
"guzzlehttp/promises": "^2.0",
2121
"squizlabs/php_codesniffer": "^3.5",
22-
"phpunit/phpunit": "^9.0.0",
23-
"phpspec/prophecy-phpunit": "^2.0",
22+
"phpunit/phpunit": "^9.6",
23+
"phpspec/prophecy-phpunit": "^2.1",
2424
"sebastian/comparator": ">=1.2.3",
25-
"phpseclib/phpseclib": "^3.0",
26-
"kelvinmo/simplejwt": "0.7.1"
25+
"phpseclib/phpseclib": "^3.0.35",
26+
"kelvinmo/simplejwt": "0.7.1",
27+
"webmozart/assert": "^1.11"
2728
},
2829
"suggest": {
2930
"phpseclib/phpseclib": "May be used in place of OpenSSL for signing strings or for token management. Please require version ^2."

src/Cache/Item.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
*
2929
* This class will be used by MemoryCacheItemPool and SysVCacheItemPool
3030
* on PHP 7.4 and below. It is compatible with psr/cache 1.0 and 2.0 (PSR-6).
31+
* @deprecated
3132
* @see TypedItem for compatiblity with psr/cache 3.0.
3233
*/
3334
final class Item implements CacheItemInterface

src/Cache/MemoryCacheItemPool.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,8 @@ public function getItem($key): CacheItemInterface
5757
public function getItems(array $keys = []): iterable
5858
{
5959
$items = [];
60-
$itemClass = \PHP_VERSION_ID >= 80000 ? TypedItem::class : Item::class;
6160
foreach ($keys as $key) {
62-
$items[$key] = $this->hasItem($key) ? clone $this->items[$key] : new $itemClass($key);
61+
$items[$key] = $this->hasItem($key) ? clone $this->items[$key] : new TypedItem($key);
6362
}
6463

6564
return $items;

src/Cache/SysVCacheItemPool.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,11 +110,10 @@ public function getItems(array $keys = []): iterable
110110
{
111111
$this->loadItems();
112112
$items = [];
113-
$itemClass = \PHP_VERSION_ID >= 80000 ? TypedItem::class : Item::class;
114113
foreach ($keys as $key) {
115114
$items[$key] = $this->hasItem($key) ?
116115
clone $this->items[$key] :
117-
new $itemClass($key);
116+
new TypedItem($key);
118117
}
119118
return $items;
120119
}

tests/BaseTest.php

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,4 @@ public function getValidKeyName($key)
4141
{
4242
return preg_replace('|[^a-zA-Z0-9_\.! ]|', '', $key);
4343
}
44-
45-
protected function getCacheItemClass()
46-
{
47-
if (\PHP_VERSION_ID >= 80000) {
48-
return 'Google\Auth\Cache\TypedItem';
49-
}
50-
51-
return 'Google\Auth\Cache\Item';
52-
}
5344
}

tests/Cache/ItemTest.php

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,31 +17,21 @@
1717

1818
namespace Google\Auth\Tests\Cache;
1919

20-
use Google\Auth\Cache\Item;
2120
use Google\Auth\Cache\TypedItem;
2221
use PHPUnit\Framework\TestCase;
2322

2423
class ItemTest extends TestCase
2524
{
26-
public function getItem($key)
27-
{
28-
if (\PHP_VERSION_ID >= 80000) {
29-
return new TypedItem($key);
30-
}
31-
32-
return new Item($key);
33-
}
34-
3525
public function testGetsKey()
3626
{
37-
$key = 'item';
27+
$item = new TypedItem('item');
3828

39-
$this->assertEquals($key, $this->getItem($key)->getKey());
29+
$this->assertEquals('item', $item->getKey());
4030
}
4131

4232
public function testGetsNull()
4333
{
44-
$item = $this->getItem('item');
34+
$item = new TypedItem('item');
4535

4636
$this->assertNull($item->get());
4737
$this->assertFalse($item->isHit());
@@ -50,7 +40,7 @@ public function testGetsNull()
5040
public function testGetsValue()
5141
{
5242
$value = 'value';
53-
$item = $this->getItem('item');
43+
$item = new TypedItem('item');
5444
$item->set($value);
5545

5646
$this->assertEquals('value', $item->get());
@@ -61,7 +51,7 @@ public function testGetsValue()
6151
*/
6252
public function testSetsValue($value)
6353
{
64-
$item = $this->getItem('item');
54+
$item = new TypedItem('item');
6555
$item->set($value);
6656

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

8373
public function testIsHit()
8474
{
85-
$item = $this->getItem('item');
75+
$item = new TypedItem('item');
8676

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

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

9484
public function testExpiresAt()
9585
{
96-
$item = $this->getItem('item');
86+
$item = new TypedItem('item');
9787
$item->set('value');
9888
$item->expiresAt(new \DateTime('now + 1 hour'));
9989

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

111101
public function testExpiresAfter()
112102
{
113-
$item = $this->getItem('item');
103+
$item = new TypedItem('item');
114104
$item->set('value');
115105
$item->expiresAfter(30);
116106

tests/Cache/MemoryCacheItemPoolTest.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
namespace Google\Auth\Tests\Cache;
1919

2020
use Google\Auth\Cache\MemoryCacheItemPool;
21+
use Google\Auth\Cache\TypedItem;
2122
use Google\Auth\Tests\BaseTest;
2223
use Psr\Cache\InvalidArgumentException;
2324

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

46-
$this->assertInstanceOf($this->getCacheItemClass(), $item);
47+
$this->assertInstanceOf(TypedItem::class, $item);
4748
$this->assertNull($item->get());
4849
$this->assertFalse($item->isHit());
4950
}
@@ -55,7 +56,7 @@ public function testGetsExistingItem()
5556
$this->saveItem($key, $value);
5657
$item = $this->pool->getItem($key);
5758

58-
$this->assertInstanceOf($this->getCacheItemClass(), $item);
59+
$this->assertInstanceOf(TypedItem::class, $item);
5960
$this->assertEquals($value, $item->get());
6061
$this->assertTrue($item->isHit());
6162
}
@@ -66,7 +67,7 @@ public function testGetsMultipleItems()
6667
$items = $this->pool->getItems($keys);
6768

6869
$this->assertEquals($keys, array_keys($items));
69-
$this->assertContainsOnlyInstancesOf($this->getCacheItemClass(), $items);
70+
$this->assertContainsOnlyInstancesOf(TypedItem::class, $items);
7071
}
7172

7273
public function testHasItem()

tests/Cache/SysVCacheItemPoolTest.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
namespace Google\Auth\Tests\Cache;
1919

2020
use Google\Auth\Cache\SysVCacheItemPool;
21+
use Google\Auth\Cache\TypedItem;
2122
use Google\Auth\Tests\BaseTest;
2223

2324
class SysVCacheItemPoolTest extends BaseTest
@@ -48,7 +49,7 @@ public function testGetsFreshItem()
4849
{
4950
$item = $this->pool->getItem('item');
5051

51-
$this->assertInstanceOf($this->getCacheItemClass(), $item);
52+
$this->assertInstanceOf(TypedItem::class, $item);
5253
$this->assertNull($item->get());
5354
$this->assertFalse($item->isHit());
5455
}
@@ -70,7 +71,7 @@ public function testGetsExistingItem()
7071
$this->saveItem($key, $value);
7172
$item = $this->pool->getItem($key);
7273

73-
$this->assertInstanceOf($this->getCacheItemClass(), $item);
74+
$this->assertInstanceOf(TypedItem::class, $item);
7475
$this->assertEquals($value, $item->get());
7576
$this->assertTrue($item->isHit());
7677
}
@@ -81,7 +82,7 @@ public function testGetsMultipleItems()
8182
$items = $this->pool->getItems($keys);
8283

8384
$this->assertEquals($keys, array_keys($items));
84-
$this->assertContainsOnlyInstancesOf($this->getCacheItemClass(), $items);
85+
$this->assertContainsOnlyInstancesOf(TypedItem::class, $items);
8586
}
8687

8788
public function testHasItem()

0 commit comments

Comments
 (0)