Skip to content

Commit 7351c05

Browse files
committed
Fixing PHPStan
1 parent f578b41 commit 7351c05

File tree

3 files changed

+19
-35
lines changed

3 files changed

+19
-35
lines changed

src/Utils/BeanDescriptor.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,6 @@ private function getPivotTableDescriptors(): array
388388
// There are exactly 2 FKs since this is a pivot table.
389389
$fks = array_values($table->getForeignKeys());
390390

391-
//todo auto pivot case?
392391
if ($fks[0]->getForeignTableName() === $this->table->getName()) {
393392
list($localFk, $remoteFk) = $fks;
394393
$descs[] = new PivotTableMethodsDescriptor($table, $localFk, $remoteFk, $this->namingStrategy, $this->beanNamespace, $this->annotationParser);
@@ -397,8 +396,6 @@ private function getPivotTableDescriptors(): array
397396
list($remoteFk, $localFk) = $fks;
398397
$descs[] = new PivotTableMethodsDescriptor($table, $localFk, $remoteFk, $this->namingStrategy, $this->beanNamespace, $this->annotationParser);
399398
}
400-
401-
402399
}
403400

404401
return $descs;
@@ -642,7 +639,7 @@ public function generatePhpCode(): ?FileGenerator
642639
if ($onDeleteCode) {
643640
$class->addMethodFromGenerator($onDeleteCode);
644641
}
645-
$cloneCode = $this->generateCloneCode();
642+
$cloneCode = $this->generateCloneCode($pivotTableMethodsDescriptors);
646643
$cloneCode = $this->codeGeneratorListener->onBaseBeanCloneGenerated($cloneCode, $this, $this->configuration, $class);
647644
if ($cloneCode) {
648645
$class->addMethodFromGenerator($cloneCode);
@@ -1426,7 +1423,11 @@ private function generateGetManyToManyRelationshipDescriptorKeysCode(array $pivo
14261423
return $method;
14271424
}
14281425

1429-
private function generateCloneCode(): MethodGenerator
1426+
/**
1427+
* @param PivotTableMethodsDescriptor[] $pivotTableMethodsDescriptors
1428+
* @return MethodGenerator
1429+
*/
1430+
private function generateCloneCode(array $pivotTableMethodsDescriptors): MethodGenerator
14301431
{
14311432
$precode = '';
14321433
$postcode = '';
@@ -1436,7 +1437,7 @@ private function generateCloneCode(): MethodGenerator
14361437
}
14371438

14381439
//cloning many to many relationships
1439-
foreach ($this->getPivotTableDescriptors() as $beanMethodDescriptor) {
1440+
foreach ($pivotTableMethodsDescriptors as $beanMethodDescriptor) {
14401441
$precode .= $beanMethodDescriptor->getCloneRule()."\n";
14411442
}
14421443

src/Utils/ManyToManyRelationshipPathDescriptor.php

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,14 @@ class ManyToManyRelationshipPathDescriptor
3030
*/
3131
private $whereKeys;
3232

33+
/**
34+
* ManyToManyRelationshipPathDescriptor constructor.
35+
* @param string $targetTable
36+
* @param string $pivotTable
37+
* @param string[] $joinForeignKeys
38+
* @param string[] $joinLocalKeys
39+
* @param string[] $whereKeys
40+
*/
3341
public function __construct(string $targetTable, string $pivotTable, array $joinForeignKeys, array $joinLocalKeys, array $whereKeys)
3442
{
3543
$this->targetTable = $targetTable;
@@ -39,35 +47,11 @@ public function __construct(string $targetTable, string $pivotTable, array $join
3947
$this->whereKeys = $whereKeys;
4048
}
4149

42-
/**
43-
* @return mixed[]
44-
*/
45-
public static function generateModelArray(ForeignKeyConstraint $remoteFk, ForeignKeyConstraint $localFk): array
46-
{
47-
return [$remoteFk->getForeignTableName(), $remoteFk->getLocalTableName(), $remoteFk->getUnquotedForeignColumns(), $remoteFk->getUnquotedLocalColumns(), $localFk->getUnquotedLocalColumns()];
48-
}
49-
5050
public static function generateModelKey(ForeignKeyConstraint $remoteFk, ForeignKeyConstraint $localFk): string
5151
{
5252
return $remoteFk->getLocalTableName().".".implode("__", $localFk->getUnquotedLocalColumns());
5353
}
5454

55-
/**
56-
* @param mixed[] $modelArray
57-
*/
58-
public static function createFromModelArray(array $modelArray): self
59-
{
60-
$obj = new self();
61-
$obj->targetTable = $modelArray[0];
62-
$obj->pivotTable = $modelArray[1];
63-
64-
$obj->joinForeignKeys = $modelArray[2];
65-
$obj->joinLocalKeys= $modelArray[3];
66-
$obj->whereKeys = $modelArray[4];
67-
68-
return $obj;
69-
}
70-
7155
public function getPivotName(): string
7256
{
7357
return $this->pivotTable;
@@ -102,6 +86,10 @@ public function getPivotWhere(): string
10286

10387
}
10488

89+
/**
90+
* @param string[] $primaryKeys
91+
* @return string[]
92+
*/
10593
public function getPivotParams(array $primaryKeys): array
10694
{
10795
$params = [];

src/Utils/PivotTableMethodsDescriptor.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,6 @@ class PivotTableMethodsDescriptor implements MethodDescriptorInterface
5959
* @var string
6060
*/
6161
private $pathKey;
62-
/**
63-
* @var array
64-
*/
65-
private $pathModel;
6662

6763
/**
6864
* @param Table $pivotTable The pivot table
@@ -80,7 +76,6 @@ public function __construct(Table $pivotTable, ForeignKeyConstraint $localFk, Fo
8076
$this->annotationParser = $annotationParser;
8177

8278
$this->pathKey = ManyToManyRelationshipPathDescriptor::generateModelKey($this->remoteFk, $this->localFk);
83-
$this->pathModel = ManyToManyRelationshipPathDescriptor::generateModelArray($this->remoteFk, $this->localFk);
8479
}
8580

8681
/**

0 commit comments

Comments
 (0)