From d19875a0f127c1cbeb77e160619ec36e096dc8d3 Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Fri, 2 Apr 2021 09:11:10 -0700 Subject: [PATCH] [GH-4503] Rework the API of PostgreSQLSchemaManager::determineExistingSchemaSearchPaths() --- UPGRADE.md | 4 ++++ psalm.xml.dist | 8 -------- src/Schema/PostgreSQLSchemaManager.php | 23 +++++++++++------------ 3 files changed, 15 insertions(+), 20 deletions(-) diff --git a/UPGRADE.md b/UPGRADE.md index 257e413594e..63a44189dfd 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,5 +1,9 @@ # Upgrade to 4.0 +## `PostgreSQLSchemaManager` methods have been made protected. + +`PostgreSQLSchemaManager::getExistingSchemaSearchPaths()` and `::determineExistingSchemaSearchPaths()` have been made protected. + ## Removed schema- and namespace-related methods The following schema- and namespace-related methods have been removed: diff --git a/psalm.xml.dist b/psalm.xml.dist index d0d742e3518..dcd79ac15a8 100644 --- a/psalm.xml.dist +++ b/psalm.xml.dist @@ -116,12 +116,6 @@ - - - - - - @@ -134,8 +128,6 @@ Fixing this issue requires an API change --> - - diff --git a/src/Schema/PostgreSQLSchemaManager.php b/src/Schema/PostgreSQLSchemaManager.php index 9b6fa0032c4..42f324674bf 100644 --- a/src/Schema/PostgreSQLSchemaManager.php +++ b/src/Schema/PostgreSQLSchemaManager.php @@ -4,6 +4,7 @@ namespace Doctrine\DBAL\Schema; +use Doctrine\DBAL\Exception; use Doctrine\DBAL\Platforms\PostgreSQL94Platform; use Doctrine\DBAL\Types\Type; use Doctrine\DBAL\Types\Types; @@ -70,36 +71,34 @@ public function getSchemaSearchPaths(): array } /** - * Gets names of all existing schemas in the current users search path. - * - * This is a PostgreSQL only function. - * - * @internal The method should be only used from within the PostgreSQLSchemaManager class hierarchy. + * Gets names of all existing schemas in the current user's search path. * * @return array + * + * @throws Exception */ - public function getExistingSchemaSearchPaths(): array + protected function getExistingSchemaSearchPaths(): array { if ($this->existingSchemaPaths === null) { - $this->determineExistingSchemaSearchPaths(); + $this->existingSchemaPaths = $this->determineExistingSchemaSearchPaths(); } return $this->existingSchemaPaths; } /** - * Sets or resets the order of the existing schemas in the current search path of the user. + * Determines the names of all existing schemas in the current user's search path. * - * This is a PostgreSQL only function. + * @return array * - * @internal The method should be only used from within the PostgreSQLSchemaManager class hierarchy. + * @throws Exception */ - public function determineExistingSchemaSearchPaths(): void + protected function determineExistingSchemaSearchPaths(): array { $names = $this->listSchemaNames(); $paths = $this->getSchemaSearchPaths(); - $this->existingSchemaPaths = array_filter($paths, static function ($v) use ($names): bool { + return array_filter($paths, static function ($v) use ($names): bool { return in_array($v, $names, true); }); }