Skip to content

Commit

Permalink
[doctrineGH-4503] Rework the API of PostgreSQLSchemaManager::determin…
Browse files Browse the repository at this point in the history
…eExistingSchemaSearchPaths()
  • Loading branch information
morozov committed Apr 2, 2021
1 parent 872167f commit d19875a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 20 deletions.
4 changes: 4 additions & 0 deletions 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:
Expand Down
8 changes: 0 additions & 8 deletions psalm.xml.dist
Expand Up @@ -116,12 +116,6 @@
<file name="src/Driver/OCI8/Connection.php"/>
</errorLevel>
</ImplementedReturnTypeMismatch>
<InvalidNullableReturnType>
<errorLevel type="suppress">
<!-- See https://github.com/doctrine/dbal/issues/4503 -->
<file name="src/Schema/PostgreSQLSchemaManager.php"/>
</errorLevel>
</InvalidNullableReturnType>
<InvalidPropertyAssignmentValue>
<errorLevel type="suppress">
<!-- Fixing this issue requires an API change -->
Expand All @@ -134,8 +128,6 @@
Fixing this issue requires an API change
-->
<file name="src/Driver/AbstractSQLiteDriver.php"/>
<!-- See https://github.com/doctrine/dbal/issues/4503 -->
<file name="src/Schema/PostgreSQLSchemaManager.php"/>
</errorLevel>
</NullableReturnStatement>
<PossiblyNullArgument>
Expand Down
23 changes: 11 additions & 12 deletions src/Schema/PostgreSQLSchemaManager.php
Expand Up @@ -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;
Expand Down Expand Up @@ -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<int, string>
*
* @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<int,string>
*
* @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);
});
}
Expand Down

0 comments on commit d19875a

Please sign in to comment.