Skip to content

Commit

Permalink
#151 - Remove redundant comments and code
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeckerson committed Apr 14, 2024
1 parent c37c5ed commit 7c1b2db
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 59 deletions.
18 changes: 2 additions & 16 deletions src/Db/Adapter/Pdo/PdoPostgresql.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@
use Phalcon\Db\Adapter\Pdo\Postgresql;
use Phalcon\Db\Enum;
use Phalcon\Db\Index;
use Phalcon\Db\IndexInterface;
use Phalcon\Db\Reference;
use Phalcon\Db\ReferenceInterface;

class PdoPostgresql extends Postgresql
{
Expand All @@ -27,18 +25,12 @@ class PdoPostgresql extends Postgresql

/**
* Lists table references
*
* @param string $table
* @param string|null $schema
*
* @return ReferenceInterface[]
*/
public function describeReferences(string $table, string $schema = null): array
{
$references = [];

$rows = $this->fetchAll($this->getDialect()
->describeReferences($table, $schema), Enum::FETCH_NUM);
$rows = $this->fetchAll($this->getDialect()->describeReferences($table, $schema), Enum::FETCH_NUM);
foreach ($rows as $reference) {
$constraintName = $reference[2];
if (!isset($references[$constraintName])) {
Expand Down Expand Up @@ -85,12 +77,6 @@ public function describeReferences(string $table, string $schema = null): array
return $referenceObjects;
}

/**
* @param string $table
* @param string|null $schema
*
* @return IndexInterface[]
*/
public function describeIndexes(string $table, string $schema = null): array
{
$indexes = [];
Expand Down Expand Up @@ -121,7 +107,7 @@ public function describeIndexes(string $table, string $schema = null): array
$indexObjects[$name] = new Index(
$name,
$index['columns'],
$index['type']
$index['type'],
);
}

Expand Down
1 change: 0 additions & 1 deletion src/Migration/Action/Generate.php
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,6 @@ public function createDumpFiles(
/**
* Prepare table columns
*
* @return Generator
* @throws UnknownColumnTypeException
*/
public function getColumns(): Generator
Expand Down
30 changes: 2 additions & 28 deletions src/Mvc/Model/Migration.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class Migration
*
* @var AbstractAdapter
*/
protected static $connection;
protected static AbstractAdapter $connection;

/**
* Database configuration
Expand Down Expand Up @@ -343,10 +343,6 @@ public static function migrate(
/**
* Create migration object for specified version
*
* @param ItemInterface $version
* @param string $tableName
*
* @return null|Migration
* @throws Exception
*/
private static function createClass(ItemInterface $version, string $tableName): ?Migration
Expand Down Expand Up @@ -374,12 +370,7 @@ private static function createClass(ItemInterface $version, string $tableName):
/**
* Find the last morph function in the previous migration files
*
* @param ItemInterface $toVersion
* @param string $tableName
*
* @return null|Migration
* @throws Exception
* @internal param ItemInterface $version
*/
private static function createPrevClassWithMorphMethod(ItemInterface $toVersion, string $tableName): ?Migration
{
Expand All @@ -404,10 +395,6 @@ private static function createPrevClassWithMorphMethod(ItemInterface $toVersion,

/**
* Scan for all versions
*
* @param string $dir Directory to scan
*
* @return ItemInterface[]
*/
public static function scanForVersions(string $dir): array
{
Expand All @@ -427,11 +414,6 @@ public static function scanForVersions(string $dir): array

/**
* Look for table definition modifications and apply to real table
*
* @param string $tableName
* @param array $definition
*
* @throws DbException
*/
public function morphTable(string $tableName, array $definition): void
{
Expand Down Expand Up @@ -774,12 +756,8 @@ public function morphTable(string $tableName, array $definition): void

/**
* Inserts data from a data migration file in a table
*
* @param string $tableName
* @param mixed $fields
* @param int $size Insert batch size
*/
public function batchInsert(string $tableName, $fields, int $size = 1024): void
public function batchInsert(string $tableName, array $fields, int $size = 1024): void
{
$migrationData = self::$migrationPath . $this->version . '/' . $tableName . '.dat';
if (!file_exists($migrationData)) {
Expand Down Expand Up @@ -882,10 +860,6 @@ protected function executeMultiInsert(string $table, array $columns, string $val

/**
* Resolves the DB Schema
*
* @param Config $config
*
* @return null|string
*/
public static function resolveDbSchema(Config $config): ?string
{
Expand Down
4 changes: 0 additions & 4 deletions src/Mvc/Model/Migration/TableAware/ListTablesDb.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@ class ListTablesDb implements ListTablesInterface
/**
* Get table names with prefix for running migration
*
* @param string $tablePrefix
* @param DirectoryIterator|null $iterator
*
* @return string
* @throws DbException
*/
public function listTablesForPrefix(string $tablePrefix, DirectoryIterator $iterator = null): string
Expand Down
6 changes: 1 addition & 5 deletions src/Version/IncrementalItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,11 +173,7 @@ public function addMinor(int $number): IncrementalItem
}

$parts = array_reverse($parts);

$this->setParts($parts)
->regenerateVersionStamp()
;

$this->setParts($parts)->regenerateVersionStamp();

Check warning on line 176 in src/Version/IncrementalItem.php

View check run for this annotation

Codecov / codecov/patch

src/Version/IncrementalItem.php#L176

Added line #L176 was not covered by tests
$this->version = join('.', $parts);

return $this;
Expand Down
6 changes: 1 addition & 5 deletions src/Version/ItemCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,8 @@ public static function setType(int $type): void

/**
* Create new version item
*
* @param null|string $version
*
* @return IncrementalItem|TimestampedItem
*/
public static function createItem(string $version = null)
public static function createItem(string $version = null): TimestampedItem|IncrementalItem
{
if (self::TYPE_INCREMENTAL === self::$type) {
$version = $version ?: '0.0.0';
Expand Down

0 comments on commit 7c1b2db

Please sign in to comment.