From fa23ebe52919b408b8cc9cb6e6d0c515ad9a1694 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Thu, 28 Jul 2022 15:48:03 +0200 Subject: [PATCH] Remove calls to setAccessible() --- src/Driver/Mysqli/Exception/ConnectionError.php | 1 - src/Driver/Mysqli/Exception/ConnectionFailed.php | 1 - src/Driver/Mysqli/Exception/InvalidCharset.php | 1 - src/Driver/Mysqli/Exception/StatementError.php | 1 - tests/Functional/Ticket/DBAL461Test.php | 3 +-- tests/Schema/SQLiteSchemaManagerTest.php | 2 -- 6 files changed, 1 insertion(+), 8 deletions(-) diff --git a/src/Driver/Mysqli/Exception/ConnectionError.php b/src/Driver/Mysqli/Exception/ConnectionError.php index ef5b980170e..98c6616f678 100644 --- a/src/Driver/Mysqli/Exception/ConnectionError.php +++ b/src/Driver/Mysqli/Exception/ConnectionError.php @@ -24,7 +24,6 @@ public static function new(mysqli $connection): self public static function upcast(mysqli_sql_exception $exception): self { $p = new ReflectionProperty(mysqli_sql_exception::class, 'sqlstate'); - $p->setAccessible(true); return new self($exception->getMessage(), $p->getValue($exception), (int) $exception->getCode(), $exception); } diff --git a/src/Driver/Mysqli/Exception/ConnectionFailed.php b/src/Driver/Mysqli/Exception/ConnectionFailed.php index 44a8cab9995..e40bf476789 100644 --- a/src/Driver/Mysqli/Exception/ConnectionFailed.php +++ b/src/Driver/Mysqli/Exception/ConnectionFailed.php @@ -29,7 +29,6 @@ public static function new(mysqli $connection): self public static function upcast(mysqli_sql_exception $exception): self { $p = new ReflectionProperty(mysqli_sql_exception::class, 'sqlstate'); - $p->setAccessible(true); return new self($exception->getMessage(), $p->getValue($exception), (int) $exception->getCode(), $exception); } diff --git a/src/Driver/Mysqli/Exception/InvalidCharset.php b/src/Driver/Mysqli/Exception/InvalidCharset.php index 763b4eb777b..98080e83e4a 100644 --- a/src/Driver/Mysqli/Exception/InvalidCharset.php +++ b/src/Driver/Mysqli/Exception/InvalidCharset.php @@ -30,7 +30,6 @@ public static function fromCharset(mysqli $connection, string $charset): self public static function upcast(mysqli_sql_exception $exception, string $charset): self { $p = new ReflectionProperty(mysqli_sql_exception::class, 'sqlstate'); - $p->setAccessible(true); return new self( sprintf('Failed to set charset "%s": %s', $charset, $exception->getMessage()), diff --git a/src/Driver/Mysqli/Exception/StatementError.php b/src/Driver/Mysqli/Exception/StatementError.php index 78dc8556b20..edffd8183f2 100644 --- a/src/Driver/Mysqli/Exception/StatementError.php +++ b/src/Driver/Mysqli/Exception/StatementError.php @@ -24,7 +24,6 @@ public static function new(mysqli_stmt $statement): self public static function upcast(mysqli_sql_exception $exception): self { $p = new ReflectionProperty(mysqli_sql_exception::class, 'sqlstate'); - $p->setAccessible(true); return new self($exception->getMessage(), $p->getValue($exception), (int) $exception->getCode(), $exception); } diff --git a/tests/Functional/Ticket/DBAL461Test.php b/tests/Functional/Ticket/DBAL461Test.php index 4d51adb111f..f8e039743e9 100644 --- a/tests/Functional/Ticket/DBAL461Test.php +++ b/tests/Functional/Ticket/DBAL461Test.php @@ -22,8 +22,7 @@ public function testIssue(): void $schemaManager = new SQLServerSchemaManager($conn, $platform); $reflectionMethod = new ReflectionMethod($schemaManager, '_getPortableTableColumnDefinition'); - $reflectionMethod->setAccessible(true); - $column = $reflectionMethod->invoke($schemaManager, [ + $column = $reflectionMethod->invoke($schemaManager, [ 'type' => 'numeric(18,0)', 'length' => null, 'default' => null, diff --git a/tests/Schema/SQLiteSchemaManagerTest.php b/tests/Schema/SQLiteSchemaManagerTest.php index f3ba6f532f2..d1bd7c47ca7 100644 --- a/tests/Schema/SQLiteSchemaManagerTest.php +++ b/tests/Schema/SQLiteSchemaManagerTest.php @@ -21,7 +21,6 @@ public function testParseColumnCollation(?string $collation, string $column, str $manager = new SQLiteSchemaManager($conn, new SQLitePlatform()); $ref = new ReflectionMethod($manager, 'parseColumnCollationFromSQL'); - $ref->setAccessible(true); self::assertSame($collation, $ref->invoke($manager, $column, $sql)); } @@ -137,7 +136,6 @@ public function testParseColumnCommentFromSQL(string $comment, string $column, s $manager = new SQLiteSchemaManager($conn, new SQLitePlatform()); $ref = new ReflectionMethod($manager, 'parseColumnCommentFromSQL'); - $ref->setAccessible(true); self::assertSame($comment, $ref->invoke($manager, $column, $sql)); }