Skip to content

refactor: remove unneeded code in SQLite3\Table and fix PHPDoc types in Database #8703

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 0 additions & 30 deletions phpstan-baseline.php
Original file line number Diff line number Diff line change
Expand Up @@ -2851,16 +2851,6 @@
'count' => 1,
'path' => __DIR__ . '/system/Database/BaseConnection.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\Database\\\\BaseConnection\\:\\:_foreignKeyData\\(\\) return type has no value type specified in iterable type array\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/Database/BaseConnection.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\Database\\\\BaseConnection\\:\\:_indexData\\(\\) return type has no value type specified in iterable type array\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/Database/BaseConnection.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\Database\\\\BaseConnection\\:\\:callFunction\\(\\) has parameter \\$params with no value type specified in iterable type array\\.$#',
'count' => 1,
Expand Down Expand Up @@ -2896,11 +2886,6 @@
'count' => 1,
'path' => __DIR__ . '/system/Database/BaseConnection.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\Database\\\\BaseConnection\\:\\:foreignKeyDataToObjects\\(\\) return type has no value type specified in iterable type array\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/Database/BaseConnection.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\Database\\\\BaseConnection\\:\\:getFieldNames\\(\\) return type has no value type specified in iterable type array\\.$#',
'count' => 1,
Expand All @@ -2911,11 +2896,6 @@
'count' => 1,
'path' => __DIR__ . '/system/Database/BaseConnection.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\Database\\\\BaseConnection\\:\\:getIndexData\\(\\) return type has no value type specified in iterable type array\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/Database/BaseConnection.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\Database\\\\BaseConnection\\:\\:listTables\\(\\) return type has no value type specified in iterable type array\\.$#',
'count' => 1,
Expand Down Expand Up @@ -9391,16 +9371,6 @@
'count' => 1,
'path' => __DIR__ . '/system/Test/Mock/MockConnection.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\Test\\\\Mock\\\\MockConnection\\:\\:_foreignKeyData\\(\\) return type has no value type specified in iterable type array\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/Test/Mock/MockConnection.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\Test\\\\Mock\\\\MockConnection\\:\\:_indexData\\(\\) return type has no value type specified in iterable type array\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/Test/Mock/MockConnection.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\Test\\\\Mock\\\\MockConnection\\:\\:shouldReturn\\(\\) has no return type specified\\.$#',
'count' => 1,
Expand Down
10 changes: 8 additions & 2 deletions system/Database/BaseConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -1527,7 +1527,7 @@ public function getFieldData(string $table)
/**
* Returns an object with key data
*
* @return array
* @return array<string, stdClass>
*/
public function getIndexData(string $table)
{
Expand All @@ -1547,7 +1547,9 @@ public function getForeignKeyData(string $table)
/**
* Converts array of arrays generated by _foreignKeyData() to array of objects
*
* @return array[
* @return array<string, stdClass>
*
* array[
* {constraint_name} =>
* stdClass[
* 'constraint_name' => string,
Expand Down Expand Up @@ -1704,13 +1706,17 @@ abstract protected function _fieldData(string $table): array;
* Platform-specific index data.
*
* @see getIndexData()
*
* @return array<string, stdClass>
*/
abstract protected function _indexData(string $table): array;

/**
* Platform-specific foreign keys data.
*
* @see getForeignKeyData()
*
* @return array<string, stdClass>
*/
abstract protected function _foreignKeyData(string $table): array;

Expand Down
4 changes: 2 additions & 2 deletions system/Database/MySQLi/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ protected function _fieldData(string $table): array
/**
* Returns an array of objects with index data
*
* @return list<stdClass>
* @return array<string, stdClass>
*
* @throws DatabaseException
* @throws LogicException
Expand Down Expand Up @@ -489,7 +489,7 @@ protected function _indexData(string $table): array
/**
* Returns an array of objects with Foreign key data
*
* @return list<stdClass>
* @return array<string, stdClass>
*
* @throws DatabaseException
*/
Expand Down
4 changes: 2 additions & 2 deletions system/Database/OCI8/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ protected function _fieldData(string $table): array
/**
* Returns an array of objects with index data
*
* @return list<stdClass>
* @return array<string, stdClass>
*
* @throws DatabaseException
*/
Expand Down Expand Up @@ -374,7 +374,7 @@ protected function _indexData(string $table): array
/**
* Returns an array of objects with Foreign key data
*
* @return list<stdClass>
* @return array<string, stdClass>
*
* @throws DatabaseException
*/
Expand Down
4 changes: 2 additions & 2 deletions system/Database/Postgre/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ protected function _fieldData(string $table): array
/**
* Returns an array of objects with index data
*
* @return list<stdClass>
* @return array<string, stdClass>
*
* @throws DatabaseException
*/
Expand Down Expand Up @@ -371,7 +371,7 @@ protected function _indexData(string $table): array
/**
* Returns an array of objects with Foreign key data
*
* @return list<stdClass>
* @return array<string, stdClass>
*
* @throws DatabaseException
*/
Expand Down
4 changes: 2 additions & 2 deletions system/Database/SQLSRV/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ protected function _listColumns(string $table = ''): string
/**
* Returns an array of objects with index data
*
* @return list<stdClass>
* @return array<string, stdClass>
*
* @throws DatabaseException
*/
Expand Down Expand Up @@ -269,7 +269,7 @@ protected function _indexData(string $table): array
* Returns an array of objects with Foreign key data
* referenced_object_id parent_object_id
*
* @return list<stdClass>
* @return array<string, stdClass>
*
* @throws DatabaseException
*/
Expand Down
4 changes: 2 additions & 2 deletions system/Database/SQLite3/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ protected function _fieldData(string $table): array
/**
* Returns an array of objects with index data
*
* @return list<stdClass>
* @return array<string, stdClass>
*
* @throws DatabaseException
*/
Expand Down Expand Up @@ -343,7 +343,7 @@ protected function _indexData(string $table): array
/**
* Returns an array of objects with Foreign key data
*
* @return list<stdClass>
* @return array<string, stdClass>
*/
protected function _foreignKeyData(string $table): array
{
Expand Down
10 changes: 3 additions & 7 deletions system/Database/SQLite3/Table.php
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ public function addForeignKey(array $foreignKeys)
/**
* Creates the new table based on our current fields.
*
* @return mixed
* @return bool
*/
protected function createTable()
{
Expand Down Expand Up @@ -449,16 +449,12 @@ private function isNumericType(string $type): bool
* Converts keys retrieved from the database to
* the format needed to create later.
*
* @param mixed $keys
* @param array<string, stdClass> $keys
*
* @return mixed
* @return array<string, array{fields: string, type: string}>
*/
protected function formatKeys($keys)
{
if (! is_array($keys)) {
return $keys;
}

$return = [];

foreach ($keys as $name => $key) {
Expand Down