Skip to content

Commit

Permalink
Merge pull request #26 from ray-di/php8.1-support
Browse files Browse the repository at this point in the history
PHP 8.1 support
  • Loading branch information
koriym authored Nov 14, 2021
2 parents c5fbc8f + dbf1f3d commit 26acc60
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 1 deletion.
1 change: 1 addition & 0 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ jobs:
- '7.3'
- '7.4'
- '8.0'
- '8.1'
dependencies:
- lowest
- highest
Expand Down
2 changes: 1 addition & 1 deletion src/PhpQueryModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function __construct(iterable $configs, ?AbstractModule $module = null)

protected function configure(): void
{
/** @var string $binding */
/** @var class-string $binding */
foreach ($this->configs as $name => $binding) {
$this->bindQuery($name, $binding);
$this->bind()->annotatedWith($name)->to($binding);
Expand Down
2 changes: 2 additions & 0 deletions tests/Iso8601FormatModuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use Aura\Sql\ExtendedPdo;
use Aura\Sql\ExtendedPdoInterface;
use PDO;
use PHPUnit\Framework\TestCase;
use Ray\Di\AbstractModule;
use Ray\Di\Injector;
Expand All @@ -21,6 +22,7 @@ class Iso8601FormatModuleTest extends TestCase
protected function setUp(): void
{
$pdo = new ExtendedPdo('sqlite::memory:');
$pdo->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true);
$pdo->query('CREATE TABLE IF NOT EXISTS todo (
id INTEGER,
title TEXT,
Expand Down
4 changes: 4 additions & 0 deletions tests/SqlQueryModuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Aura\Sql\ExtendedPdoInterface;
use Aura\Sql\PdoInterface;
use InvalidArgumentException;
use PDO;
use PHPUnit\Framework\TestCase;
use Ray\Di\AbstractModule;
use Ray\Di\Injector;
Expand All @@ -26,6 +27,8 @@ class SqlQueryModuleTest extends TestCase
protected function setUp(): void
{
$pdo = new ExtendedPdo('sqlite::memory:');
$pdo->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true);
$pdo->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true);
$pdo->query('CREATE TABLE IF NOT EXISTS todo (
id INTEGER,
title TEXT
Expand Down Expand Up @@ -168,6 +171,7 @@ public function testResourceObject404(): void
public function testDevSqlModule(): void
{
$pdo = new ExtendedPdo('sqlite::memory:');
$pdo->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true);
$pdo->query('CREATE TABLE IF NOT EXISTS todo (
id INTEGER,
title TEXT
Expand Down
2 changes: 2 additions & 0 deletions tests/SqlQueryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Ray\Query;

use Aura\Sql\ExtendedPdo;
use PDO;
use PHPUnit\Framework\TestCase;

use function file_get_contents;
Expand All @@ -17,6 +18,7 @@ class SqlQueryTest extends TestCase
protected function setUp(): void
{
$pdo = new ExtendedPdo('sqlite::memory:');
$pdo->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true);
$pdo->query('CREATE TABLE IF NOT EXISTS todo (
id INTEGER,
title TEXT
Expand Down
10 changes: 10 additions & 0 deletions tests/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,25 @@
use Koriym\Attributes\AttributeReader;
use Ray\ServiceLocator\ServiceLocator;

require dirname(__DIR__) . '/vendor/autoload.php';

$rm = static function ($dir) use (&$rm) {
foreach ((array) glob($dir . '/*') as $file) {
$f = (string) $file;
is_dir($f) ? $rm($f) : @unlink($f);
@rmdir($f);
}
};

$rm(__DIR__ . '/tmp');

// Suppress E_DEPRECATED in vendor files
if (PHP_VERSION_ID >= 80100) {
set_error_handler(static function (int $errno, string $errstr, string $errfile) {
return $errno === E_DEPRECATED && str_contains($errfile, dirname(__DIR__) . '/vendor');
});
}

// no annotation in PHP 8
if (PHP_MAJOR_VERSION >= 8) {
ServiceLocator::setReader(new AttributeReader());
Expand Down

0 comments on commit 26acc60

Please sign in to comment.