Skip to content

Commit

Permalink
#1324 - Update implemetation of methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeckerson committed Oct 12, 2019
1 parent 9d7cd1f commit 482e3af
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 9 deletions.
4 changes: 2 additions & 2 deletions scripts/Phalcon/Db/Adapter/Pdo/PdoMysql.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ class PdoMysql extends Mysql
*
* @throws \Phalcon\Db\Exception
*/
public function addForeignKey($tableName, $schemaName, ReferenceInterface $reference)
public function addForeignKey(string $tableName, string $schemaName, ReferenceInterface $reference): bool
{
$foreignKeyCheck = $this->{"prepare"}($this->_dialect->getForeignKeyChecks());
$foreignKeyCheck = $this->{"prepare"}($this->getDialect()->getForeignKeyChecks());
if (!$foreignKeyCheck->execute()) {
throw new Exception("DATABASE PARAMETER 'FOREIGN_KEY_CHECKS' HAS TO BE 1");
}
Expand Down
7 changes: 3 additions & 4 deletions scripts/Phalcon/Db/Adapter/Pdo/PdoPostgresql.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@

namespace Phalcon\Db\Adapter\Pdo;

use Phalcon\Db;
use Phalcon\Db\Enum;
use Phalcon\Db\Reference;
use Phalcon\Db\Exception;
use Phalcon\Db\ReferenceInterface;

/**
Expand All @@ -39,11 +38,11 @@ class PdoPostgresql extends Postgresql
* @return ReferenceInterface[]
*
*/
public function describeReferences($table, $schema = null)
public function describeReferences(string $table, string $schema = null): array
{
$references = [];

foreach ($this->fetchAll($this->_dialect->describeReferences($table, $schema), Db::FETCH_NUM) as $reference) {
foreach ($this->fetchAll(parent::describeReferences($table, $schema), Enum::FETCH_NUM) as $reference) {
$constraintName = $reference[2];
if (!isset($references[$constraintName])) {
$referencedSchema = $reference[3];
Expand Down
4 changes: 2 additions & 2 deletions scripts/Phalcon/Db/Dialect/DialectMysql.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class DialectMysql extends Mysql
* @param ReferenceInterface $reference
* @return string
*/
public function addForeignKey($tableName, $schemaName, ReferenceInterface $reference)
public function addForeignKey(string $tableName, string $schemaName, ReferenceInterface $reference): string
{
$sql = 'ALTER TABLE ' . $this->prepareTable($tableName, $schemaName) . ' ADD';
if ($reference->getName()) {
Expand Down Expand Up @@ -64,7 +64,7 @@ public function addForeignKey($tableName, $schemaName, ReferenceInterface $refer
*
* @return string
*/
public function getForeignKeyChecks()
public function getForeignKeyChecks(): string
{
$sql = 'SELECT @@foreign_key_checks';

Expand Down
2 changes: 1 addition & 1 deletion scripts/Phalcon/Db/Dialect/DialectPostgresql.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class DialectPostgresql extends Postgresql
* @param string $schema
* @return string
*/
public function describeReferences($table, $schema = null)
public function describeReferences(string $table, string $schema = null)
{
$sql = "
SELECT DISTINCT
Expand Down

0 comments on commit 482e3af

Please sign in to comment.