Skip to content

Commit

Permalink
Rename to ForeignKey
Browse files Browse the repository at this point in the history
Signed-off-by: Kamil Tekiela <[email protected]>
  • Loading branch information
kamil-tekiela committed Sep 24, 2024
1 parent c3fa38e commit 741fce0
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1037,7 +1037,7 @@
<code><![CDATA[$obj instanceof Parser]]></code>
</RedundantConditionGivenDocblockType>
</file>
<file src="src/Utils/ForeignKeyData.php">
<file src="src/Utils/ForeignKey.php">
<PossiblyUnusedProperty>
<code><![CDATA[$constraint]]></code>
<code><![CDATA[$indexList]]></code>
Expand Down
6 changes: 3 additions & 3 deletions src/Statements/CreateStatement.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
use PhpMyAdmin\SqlParser\Token;
use PhpMyAdmin\SqlParser\TokensList;
use PhpMyAdmin\SqlParser\TokenType;
use PhpMyAdmin\SqlParser\Utils\ForeignKeyData;
use PhpMyAdmin\SqlParser\Utils\ForeignKey;

use function is_array;
use function str_replace;
Expand Down Expand Up @@ -778,7 +778,7 @@ public function parse(Parser $parser, TokensList $list): void
}
}

/** @return list<ForeignKeyData> */
/** @return list<ForeignKey> */
public function getForeignKeys(): array
{
if (empty($this->fields) || (! is_array($this->fields)) || (! $this->options->has('TABLE'))) {
Expand All @@ -801,7 +801,7 @@ public function getForeignKeys(): array
$columns[] = $column['name'];
}

$foreignKey = new ForeignKeyData();
$foreignKey = new ForeignKey();
$foreignKey->constraint = $field->name;
$foreignKey->indexList = $columns;

Expand Down
2 changes: 1 addition & 1 deletion src/Utils/ForeignKeyData.php → src/Utils/ForeignKey.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace PhpMyAdmin\SqlParser\Utils;

final class ForeignKeyData
final class ForeignKey
{
/**
* @param (int|string)[] $indexList
Expand Down
14 changes: 7 additions & 7 deletions tests/Utils/TableTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
use PhpMyAdmin\SqlParser\Parser;
use PhpMyAdmin\SqlParser\Statements\CreateStatement;
use PhpMyAdmin\SqlParser\Tests\TestCase;
use PhpMyAdmin\SqlParser\Utils\ForeignKeyData;
use PhpMyAdmin\SqlParser\Utils\ForeignKey;
use PhpMyAdmin\SqlParser\Utils\Table;
use PHPUnit\Framework\Attributes\DataProvider;

class TableTest extends TestCase
{
/** @param list<ForeignKeyData> $expected */
/** @param list<ForeignKey> $expected */
#[DataProvider('getForeignKeysProvider')]
public function testGetForeignKeys(string $query, array $expected): void
{
Expand All @@ -24,7 +24,7 @@ public function testGetForeignKeys(string $query, array $expected): void
$this->assertEquals($expected, $result);
}

/** @return list<array{string, list<ForeignKeyData>}> */
/** @return list<array{string, list<ForeignKey>}> */
public static function getForeignKeysProvider(): array
{
return [
Expand Down Expand Up @@ -53,22 +53,22 @@ public static function getForeignKeysProvider(): array
REFERENCES `staff` (`staff_id`) ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=16050 DEFAULT CHARSET=utf8',
[
new ForeignKeyData(
new ForeignKey(
constraint: 'fk_payment_customer',
indexList: ['customer_id'],
refTableName: 'customer',
refIndexList: ['customer_id'],
onUpdate: 'CASCADE',
),
new ForeignKeyData(
new ForeignKey(
constraint: 'fk_payment_rental',
indexList: ['rental_id'],
refTableName: 'rental',
refIndexList: ['rental_id'],
onDelete: 'SET_NULL',
onUpdate: 'CASCADE',
),
new ForeignKeyData(
new ForeignKey(
constraint: 'fk_payment_staff',
indexList: ['staff_id'],
refTableName: 'staff',
Expand Down Expand Up @@ -103,7 +103,7 @@ public static function getForeignKeysProvider(): array
CONSTRAINT `fk_address_city` FOREIGN KEY (`city_id`) REFERENCES `city` (`city_id`) ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=606 DEFAULT CHARSET=utf8',
[
new ForeignKeyData(
new ForeignKey(
constraint: 'fk_address_city',
indexList: ['city_id'],
refTableName: 'city',
Expand Down

0 comments on commit 741fce0

Please sign in to comment.