diff --git a/composer.json b/composer.json index 8a5188b..5af2c24 100644 --- a/composer.json +++ b/composer.json @@ -8,7 +8,7 @@ "symfony/finder": "^2.8", "goaop/parser-reflection": "^1.4", "console-helpers/db-migration": "^0.1.0", - "aura/sql": "^2.5", + "aura/sql": "^2.5 || ^3.0 || ^4.0 || ^5.0", "doctrine/cache": "^1.5", "camspiers/json-pretty": "^1.0" }, diff --git a/composer.lock b/composer.lock index 29dac84..2eb40a6 100644 --- a/composer.lock +++ b/composer.lock @@ -4,34 +4,31 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "15c564eb534ff22554804aa242ba5794", + "content-hash": "76cf6cd7a31554aa05fec7427bd42e1e", "packages": [ { "name": "aura/sql", - "version": "2.6.0", + "version": "3.1.0", "source": { "type": "git", "url": "https://github.com/auraphp/Aura.Sql.git", - "reference": "16206efbe5ba63603fe3b18ba54a4c5296cd5f3e" + "reference": "88d8b8ed1bcfd588a649fdc7e7ac89ec047abbca" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/auraphp/Aura.Sql/zipball/16206efbe5ba63603fe3b18ba54a4c5296cd5f3e", - "reference": "16206efbe5ba63603fe3b18ba54a4c5296cd5f3e", + "url": "https://api.github.com/repos/auraphp/Aura.Sql/zipball/88d8b8ed1bcfd588a649fdc7e7ac89ec047abbca", + "reference": "88d8b8ed1bcfd588a649fdc7e7ac89ec047abbca", "shasum": "" }, "require": { - "php": ">=5.3.0" + "php": ">=5.6.0", + "psr/log": "^1.0 || ^2.0" }, "require-dev": { - "phpunit/phpunit": "~5.7 || ~4.8" + "pds/skeleton": "~1.0", + "yoast/phpunit-polyfills": "~1.0" }, "type": "library", - "extra": { - "aura": { - "type": "library" - } - }, "autoload": { "psr-4": { "Aura\\Sql\\": "src/" @@ -39,7 +36,7 @@ }, "notification-url": "https://packagist.org/downloads/", "license": [ - "BSD-2-Clause" + "MIT" ], "authors": [ { @@ -47,7 +44,7 @@ "homepage": "https://github.com/auraphp/Aura.Sql/contributors" } ], - "description": "A PDO extension that provides lazy connections, array quoting, identifier quoting, query profiling, value binding, and convenience methods for common fetch styles. Because it extends PDO, existing code that uses PDO can use this without any changes to the existing code.", + "description": "A PDO extension that provides lazy connections, array quoting, query profiling, value binding, and convenience methods for common fetch styles. Because it extends PDO, existing code that uses PDO can use this without any changes to the existing code.", "homepage": "https://github.com/auraphp/Aura.Sql", "keywords": [ "mysql", @@ -62,9 +59,9 @@ ], "support": { "issues": "https://github.com/auraphp/Aura.Sql/issues", - "source": "https://github.com/auraphp/Aura.Sql/tree/2.x" + "source": "https://github.com/auraphp/Aura.Sql/tree/3.1.0" }, - "time": "2018-08-15T13:33:56+00:00" + "time": "2022-04-28T05:11:23+00:00" }, { "name": "camspiers/json-pretty", diff --git a/src/CodeInsight/BackwardsCompatibility/Checker/AbstractChecker.php b/src/CodeInsight/BackwardsCompatibility/Checker/AbstractChecker.php index fcab38a..cf96d2b 100644 --- a/src/CodeInsight/BackwardsCompatibility/Checker/AbstractChecker.php +++ b/src/CodeInsight/BackwardsCompatibility/Checker/AbstractChecker.php @@ -260,7 +260,17 @@ protected function addIncident($type, $element, $old_value = null, $new_value = */ protected function getCacheKey(ExtendedPdoInterface $db, $cache_key) { - return sha1($db->getDsn()) . ':' . $cache_key; + if ( method_exists($db, 'getDsn') ) { + // Aura.Sql 2.5. + $dsn = $db->getDsn(); + } + else { + // Aura.Sql 3.0+. + $debug_info = $db->__debugInfo(); + $dsn = $debug_info['args']['0']; + } + + return sha1($dsn) . ':' . $cache_key; } } diff --git a/tests/CodeInsight/KnowledgeBase/DatabaseManagerTest.php b/tests/CodeInsight/KnowledgeBase/DatabaseManagerTest.php index 3d3fba8..4604792 100644 --- a/tests/CodeInsight/KnowledgeBase/DatabaseManagerTest.php +++ b/tests/CodeInsight/KnowledgeBase/DatabaseManagerTest.php @@ -11,6 +11,7 @@ namespace Tests\ConsoleHelpers\CodeInsight\KnowledgeBase; +use Aura\Sql\ExtendedPdo; use ConsoleHelpers\CodeInsight\KnowledgeBase\DatabaseManager; use Prophecy\Prophecy\ObjectProphecy; use Tests\ConsoleHelpers\ConsoleKit\WorkingDirectoryAwareTestCase; @@ -69,7 +70,7 @@ public function testCreatingDatabase() $this->assertFileNotExists($this->workingDirectory . '/databases/absolute/path/code_insight.sqlite'); $this->assertEquals( 'sqlite:' . $this->workingDirectory . '/databases/absolute/path/code_insight.sqlite', - $database->getDsn() + $this->getDSN($database) ); } @@ -82,7 +83,7 @@ public function testCreatingForkedDatabaseFromNothing() $this->assertFileNotExists($this->workingDirectory . '/databases/absolute/path/code_insight-fork.sqlite'); $this->assertEquals( 'sqlite:' . $this->workingDirectory . '/databases/absolute/path/code_insight-fork.sqlite', - $database->getDsn() + $this->getDSN($database) ); } @@ -105,10 +106,30 @@ public function testCreatingForkedDatabaseFromOriginal() $this->assertFileExists($this->workingDirectory . '/databases/absolute/path/code_insight-fork.sqlite'); $this->assertEquals( 'sqlite:' . $this->workingDirectory . '/databases/absolute/path/code_insight-fork.sqlite', - $database->getDsn() + $this->getDSN($database) ); } + /** + * Returns database DSN. + * + * @param ExtendedPdo $database Datbase. + * + * @return string + */ + protected function getDSN(ExtendedPdo $database) + { + // Aura.Sql 2.5. + if ( method_exists($database, 'getDsn') ) { + return $database->getDsn(); + } + + // Aura.Sql 3.0+. + $debug_info = $database->__debugInfo(); + + return $debug_info['args']['0']; + } + public function testRunMigrations() { $context = $this->prophesize(MigrationContext::class)->reveal();