Skip to content

Commit

Permalink
Add PHP 8.1 and 8.2 test in GitHub action
Browse files Browse the repository at this point in the history
  • Loading branch information
peter279k committed Sep 5, 2023
1 parent 7fd4bd0 commit 5e4c266
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 27 deletions.
9 changes: 2 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
strategy:
matrix:
operating-system: [ ubuntu-latest ]
php-versions: [ '7.2', '7.3', '7.4', '8.0' ]
php-versions: [ '7.2', '7.3', '7.4', '8.0', '8.1', '8.2' ]
name: PHP ${{ matrix.php-versions }} Test on ${{ matrix.operating-system }}

steps:
Expand All @@ -34,14 +34,9 @@ jobs:
- name: Validate composer.json and composer.lock
run: composer validate

- name: Install dependencies for PHP 7
if: matrix.php-versions < '8.0'
- name: Install dependencies for PHP
run: composer update --prefer-dist --no-progress

- name: Install dependencies for PHP 8
if: matrix.php-versions >= '8.0'
run: composer update --prefer-dist --no-progress --ignore-platform-req=php

- name: Run test suite
run: composer check
env:
Expand Down
25 changes: 12 additions & 13 deletions src/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Selective\Config;

use Cake\Chronos\Chronos;
use InvalidArgumentException;

/**
* Configuration.
Expand Down Expand Up @@ -31,7 +30,7 @@ public function __construct(array $data = [])
* @param string $key The key
* @param int|null $default The default value
*
* @throws InvalidArgumentException
* @throws \InvalidArgumentException
*
* @return int The value
*/
Expand All @@ -40,7 +39,7 @@ public function getInt(string $key, int $default = null): int
$value = $this->find($key, $default);

if ($this->isNullOrBlank($value)) {
throw new InvalidArgumentException(sprintf('No value found for key "%s"', $key));
throw new \InvalidArgumentException(sprintf('No value found for key "%s"', $key));
}

return (int)$value;
Expand Down Expand Up @@ -71,7 +70,7 @@ public function findInt(string $key, int $default = null)
* @param string $key The key
* @param string|null $default The default value
*
* @throws InvalidArgumentException
* @throws \InvalidArgumentException
*
* @return string The value
*/
Expand All @@ -80,7 +79,7 @@ public function getString(string $key, string $default = null): string
$value = $this->find($key, $default);

if ($value === null) {
throw new InvalidArgumentException(sprintf('No value found for key "%s"', $key));
throw new \InvalidArgumentException(sprintf('No value found for key "%s"', $key));
}

return (string)$value;
Expand Down Expand Up @@ -111,7 +110,7 @@ public function findString(string $key, string $default = null)
* @param string $key The key
* @param array<mixed>|null $default The default value
*
* @throws InvalidArgumentException
* @throws \InvalidArgumentException
*
* @return array<mixed> The value
*/
Expand All @@ -120,7 +119,7 @@ public function getArray(string $key, array $default = null): array
$value = $this->find($key, $default);

if ($this->isNullOrBlank($value)) {
throw new InvalidArgumentException(sprintf('No value found for key "%s"', $key));
throw new \InvalidArgumentException(sprintf('No value found for key "%s"', $key));
}

return (array)$value;
Expand Down Expand Up @@ -151,7 +150,7 @@ public function findArray(string $key, array $default = null)
* @param string $key The key
* @param float|null $default The default value
*
* @throws InvalidArgumentException
* @throws \InvalidArgumentException
*
* @return float The value
*/
Expand All @@ -160,7 +159,7 @@ public function getFloat(string $key, float $default = null): float
$value = $this->find($key, $default);

if ($this->isNullOrBlank($value)) {
throw new InvalidArgumentException(sprintf('No value found for key "%s"', $key));
throw new \InvalidArgumentException(sprintf('No value found for key "%s"', $key));
}

return (float)$value;
Expand Down Expand Up @@ -191,7 +190,7 @@ public function findFloat(string $key, float $default = null)
* @param string $key The key
* @param bool|null $default The default value
*
* @throws InvalidArgumentException
* @throws \InvalidArgumentException
*
* @return bool The value
*/
Expand All @@ -200,7 +199,7 @@ public function getBool(string $key, bool $default = null): bool
$value = $this->find($key, $default);

if ($this->isNullOrBlank($value)) {
throw new InvalidArgumentException(sprintf('No value found for key "%s"', $key));
throw new \InvalidArgumentException(sprintf('No value found for key "%s"', $key));
}

return (bool)$value;
Expand Down Expand Up @@ -231,7 +230,7 @@ public function findBool(string $key, bool $default = null)
* @param string $key The key
* @param Chronos|null $default The default value
*
* @throws InvalidArgumentException
* @throws \InvalidArgumentException
*
* @return Chronos The value
*/
Expand All @@ -240,7 +239,7 @@ public function getChronos(string $key, Chronos $default = null): Chronos
$value = $this->find($key, $default);

if ($this->isNullOrBlank($value)) {
throw new InvalidArgumentException(sprintf('No value found for key "%s"', $key));
throw new \InvalidArgumentException(sprintf('No value found for key "%s"', $key));
}

if ($value instanceof Chronos) {
Expand Down
13 changes: 6 additions & 7 deletions tests/ConfigurationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Selective\Config\Test;

use Cake\Chronos\Chronos;
use InvalidArgumentException;
use PHPUnit\Framework\TestCase;
use Selective\Config\Configuration;

Expand Down Expand Up @@ -59,7 +58,7 @@ public function providerGetString(): array
*/
public function testGetStringError($data, string $key): void
{
$this->expectException(InvalidArgumentException::class);
$this->expectException(\InvalidArgumentException::class);

$reader = new Configuration($data);
$reader->getString($key);
Expand Down Expand Up @@ -164,7 +163,7 @@ public function providerGetInt(): array
*/
public function testGetIntError($data, string $key): void
{
$this->expectException(InvalidArgumentException::class);
$this->expectException(\InvalidArgumentException::class);

$reader = new Configuration($data);
$reader->getInt($key);
Expand Down Expand Up @@ -269,7 +268,7 @@ public function providerGetBool(): array
*/
public function testGetBoolError($data, string $key): void
{
$this->expectException(InvalidArgumentException::class);
$this->expectException(\InvalidArgumentException::class);

$reader = new Configuration($data);
$reader->getBool($key);
Expand Down Expand Up @@ -374,7 +373,7 @@ public function providerGetFloat(): array
*/
public function testGetFloatError($data, string $key): void
{
$this->expectException(InvalidArgumentException::class);
$this->expectException(\InvalidArgumentException::class);

$reader = new Configuration($data);
$reader->getFloat($key);
Expand Down Expand Up @@ -479,7 +478,7 @@ public function providerGetArray(): array
*/
public function testGetArrayError($data, string $key): void
{
$this->expectException(InvalidArgumentException::class);
$this->expectException(\InvalidArgumentException::class);

$reader = new Configuration($data);
$reader->getArray($key);
Expand Down Expand Up @@ -585,7 +584,7 @@ public function providerGetChronos(): array
*/
public function testGetChronosError($data, string $key): void
{
$this->expectException(InvalidArgumentException::class);
$this->expectException(\InvalidArgumentException::class);

$reader = new Configuration($data);
$reader->getChronos($key);
Expand Down

0 comments on commit 5e4c266

Please sign in to comment.