Skip to content

Commit 8eb1cef

Browse files
committed
Use generic template for ExportRelationSchema::$diagram
Signed-off-by: Maurício Meneghini Fauth <[email protected]>
1 parent 772648a commit 8eb1cef

File tree

9 files changed

+10
-113
lines changed

9 files changed

+10
-113
lines changed

libraries/classes/Plugins/Schema/Dia/DiaRelationSchema.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
* inherits ExportRelationSchema class has common functionality added
2525
* to this class
2626
*
27-
* @property Dia $diagram
27+
* @extends ExportRelationSchema<Dia>
2828
*/
2929
class DiaRelationSchema extends ExportRelationSchema
3030
{

libraries/classes/Plugins/Schema/Eps/EpsRelationSchema.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
* This class inherits ExportRelationSchema class has common functionality added
2828
* to this class
2929
*
30-
* @property Eps $diagram
30+
* @extends ExportRelationSchema<Eps>
3131
*/
3232
class EpsRelationSchema extends ExportRelationSchema
3333
{

libraries/classes/Plugins/Schema/ExportRelationSchema.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,11 @@
2121
* This class is inherited by all schema classes
2222
* It contains those methods which are common in them
2323
* it works like factory pattern
24+
*
25+
* @template T
2426
*/
2527
class ExportRelationSchema
2628
{
27-
/** @var Dia\Dia|Eps\Eps|Pdf\Pdf|Svg\Svg|null */
28-
protected $diagram;
29-
3029
/** @var bool */
3130
protected $showColor = false;
3231

@@ -54,11 +53,10 @@ class ExportRelationSchema
5453
protected Relation $relation;
5554

5655
/**
57-
* @param Pdf\Pdf|Svg\Svg|Eps\Eps|Dia\Dia|null $diagram schema diagram
56+
* @param T $diagram
5857
*/
59-
public function __construct(protected DatabaseName $db, $diagram)
58+
public function __construct(protected DatabaseName $db, protected $diagram)
6059
{
61-
$this->diagram = $diagram;
6260
$this->setPageNumber((int) $_REQUEST['page_number']);
6361
$this->setOffline(isset($_REQUEST['offline_export']));
6462
$this->relation = new Relation($GLOBALS['dbi']);

libraries/classes/Plugins/Schema/Pdf/PdfRelationSchema.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
* This class inherits ExportRelationSchema class has common functionality added
4646
* to this class
4747
*
48-
* @property Pdf $diagram
48+
* @extends ExportRelationSchema<Pdf>
4949
*/
5050
class PdfRelationSchema extends ExportRelationSchema
5151
{

libraries/classes/Plugins/Schema/Svg/SvgRelationSchema.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
* inherits ExportRelationSchema class has common functionality added
3333
* to this class
3434
*
35-
* @property Svg $diagram
35+
* @extends ExportRelationSchema<Svg>
3636
*/
3737
class SvgRelationSchema extends ExportRelationSchema
3838
{

phpcs.xml.dist

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,6 @@
3636
<rule ref="SlevomatCodingStandard.Classes.ParentCallSpacing.IncorrectLinesCountBeforeControlStructure">
3737
<severity>4</severity>
3838
</rule>
39-
<rule ref="SlevomatCodingStandard.Classes.RequireConstructorPropertyPromotion.RequiredConstructorPropertyPromotion">
40-
<severity>4</severity>
41-
</rule>
4239
<rule ref="SlevomatCodingStandard.Commenting.RequireOneLineDocComment.MultiLineDocComment">
4340
<severity>4</severity>
4441
</rule>

phpstan-baseline.neon

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7006,7 +7006,7 @@ parameters:
70067006
path: libraries/classes/Plugins/Schema/Pdf/PdfRelationSchema.php
70077007

70087008
-
7009-
message: "#^Property PhpMyAdmin\\\\Plugins\\\\Schema\\\\ExportRelationSchema\\:\\:\\$orientation \\(string\\) in isset\\(\\) is not nullable\\.$#"
7009+
message: "#^Property PhpMyAdmin\\\\Plugins\\\\Schema\\\\ExportRelationSchema\\<PhpMyAdmin\\\\Plugins\\\\Schema\\\\Pdf\\\\Pdf\\>\\:\\:\\$orientation \\(string\\) in isset\\(\\) is not nullable\\.$#"
70107010
count: 1
70117011
path: libraries/classes/Plugins/Schema/Pdf/PdfRelationSchema.php
70127012

psalm-baseline.xml

Lines changed: 0 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -12548,17 +12548,10 @@
1254812548
<code>$one_key</code>
1254912549
<code>$rel</code>
1255012550
</MixedAssignment>
12551-
<PossiblyInvalidArgument>
12552-
<code><![CDATA[$this->diagram]]></code>
12553-
</PossiblyInvalidArgument>
1255412551
<PossiblyInvalidCast>
1255512552
<code><![CDATA[$_REQUEST['dia_orientation']]]></code>
1255612553
<code><![CDATA[$_REQUEST['dia_paper']]]></code>
1255712554
</PossiblyInvalidCast>
12558-
<PossiblyNullReference>
12559-
<code>endDiaDoc</code>
12560-
<code>startDiaDoc</code>
12561-
</PossiblyNullReference>
1256212555
<UnusedProperty>
1256312556
<code>$bottomMargin</code>
1256412557
<code>$leftMargin</code>
@@ -12605,7 +12598,6 @@
1260512598
<InvalidArgument>
1260612599
<code><![CDATA[$this->tables[$foreignTable]]]></code>
1260712600
<code><![CDATA[$this->tables[$masterTable]]]></code>
12608-
<code>10</code>
1260912601
</InvalidArgument>
1261012602
<InvalidCast>
1261112603
<code><![CDATA[$this->tables[$foreignTable]]]></code>
@@ -12617,12 +12609,6 @@
1261712609
<code><![CDATA[$one_key['ref_table_name']]]></code>
1261812610
<code><![CDATA[$rel['foreign_field']]]></code>
1261912611
<code><![CDATA[$rel['foreign_table']]]></code>
12620-
<code><![CDATA[$this->diagram->getFont()]]></code>
12621-
<code><![CDATA[$this->diagram->getFont()]]></code>
12622-
<code><![CDATA[$this->diagram->getFont()]]></code>
12623-
<code><![CDATA[$this->diagram->getFontSize()]]></code>
12624-
<code><![CDATA[$this->diagram->getFontSize()]]></code>
12625-
<code><![CDATA[$this->diagram->getFontSize()]]></code>
1262612612
</MixedArgument>
1262712613
<MixedArgumentTypeCoercion>
1262812614
<code>$master_field</code>
@@ -12646,26 +12632,9 @@
1264612632
<code>$one_key</code>
1264712633
<code>$rel</code>
1264812634
</MixedAssignment>
12649-
<PossiblyInvalidArgument>
12650-
<code><![CDATA[$this->diagram]]></code>
12651-
</PossiblyInvalidArgument>
1265212635
<PossiblyInvalidCast>
1265312636
<code><![CDATA[$_REQUEST['eps_orientation']]]></code>
1265412637
</PossiblyInvalidCast>
12655-
<PossiblyNullReference>
12656-
<code>endEpsDoc</code>
12657-
<code>getFont</code>
12658-
<code>getFont</code>
12659-
<code>getFont</code>
12660-
<code>getFontSize</code>
12661-
<code>getFontSize</code>
12662-
<code>getFontSize</code>
12663-
<code>setAuthor</code>
12664-
<code>setDate</code>
12665-
<code>setFont</code>
12666-
<code>setOrientation</code>
12667-
<code>setTitle</code>
12668-
</PossiblyNullReference>
1266912638
</file>
1267012639
<file src="libraries/classes/Plugins/Schema/Eps/RelationStatsEps.php">
1267112640
<MixedMethodCall>
@@ -12828,15 +12797,9 @@
1282812797
<code>$table</code>
1282912798
<code>$table</code>
1283012799
<code>$table</code>
12831-
<code><![CDATA[$this->diagram->PageNo()]]></code>
12832-
<code><![CDATA[$this->diagram->customLinks['RT']['-']]]></code>
1283312800
<code><![CDATA[$this->diagram->customLinks['RT']['-']]]></code>
1283412801
<code><![CDATA[$this->diagram->customLinks['doc'][$table][$field_name]]]></code>
1283512802
<code><![CDATA[$this->diagram->customLinks['doc'][$table]['-']]]></code>
12836-
<code><![CDATA[max(
12837-
($this->xMax - $this->xMin) / $innerWidth,
12838-
($this->yMax - $this->yMin) / $innerHeight
12839-
) * 100]]></code>
1284012803
</MixedArgument>
1284112804
<MixedArgumentTypeCoercion>
1284212805
<code>$master_field</code>
@@ -12896,8 +12859,6 @@
1289612859
<code>$field_name</code>
1289712860
<code>$foreignTable</code>
1289812861
<code>$index</code>
12899-
<code>$innerHeight</code>
12900-
<code>$innerWidth</code>
1290112862
<code>$links[0]</code>
1290212863
<code>$links[6]</code>
1290312864
<code>$one_field</code>
@@ -12915,15 +12876,9 @@
1291512876
<code><![CDATA[$foreigner['foreign_table']]]></code>
1291612877
<code><![CDATA[$foreigner['on_delete']]]></code>
1291712878
<code><![CDATA[$foreigner['on_update']]]></code>
12918-
<code>$innerHeight</code>
12919-
<code>$innerWidth</code>
1292012879
<code>$show_comment</code>
1292112880
<code>$table</code>
1292212881
<code>$table</code>
12923-
<code><![CDATA[max(
12924-
($this->xMax - $this->xMin) / $innerWidth,
12925-
($this->yMax - $this->yMin) / $innerHeight
12926-
)]]></code>
1292712882
</MixedOperand>
1292812883
<NullArgument>
1292912884
<code>null</code>
@@ -12932,46 +12887,15 @@
1293212887
</NullArgument>
1293312888
<PossiblyInvalidArgument>
1293412889
<code><![CDATA[$_REQUEST['pdf_table_order']]]></code>
12935-
<code><![CDATA[$this->diagram]]></code>
1293612890
</PossiblyInvalidArgument>
1293712891
<PossiblyInvalidCast>
1293812892
<code><![CDATA[$_REQUEST['pdf_orientation']]]></code>
1293912893
<code><![CDATA[$_REQUEST['pdf_paper']]]></code>
1294012894
<code><![CDATA[$_REQUEST['pdf_table_order']]]></code>
1294112895
</PossiblyInvalidCast>
1294212896
<PossiblyNullArgument>
12943-
<code><![CDATA[$this->diagram->customLinks['RT']['-']]]></code>
1294412897
<code><![CDATA[$this->orientation]]></code>
1294512898
</PossiblyNullArgument>
12946-
<PossiblyNullArrayAccess>
12947-
<code><![CDATA[$this->diagram->customLinks['RT']]]></code>
12948-
<code><![CDATA[$this->diagram->customLinks['RT']['-']]]></code>
12949-
</PossiblyNullArrayAccess>
12950-
<PossiblyNullPropertyFetch>
12951-
<code><![CDATA[$this->diagram->customLinks]]></code>
12952-
</PossiblyNullPropertyFetch>
12953-
<PossiblyNullReference>
12954-
<code>AddPage</code>
12955-
<code>Bookmark</code>
12956-
<code>Open</code>
12957-
<code>PageNo</code>
12958-
<code>getPageHeight</code>
12959-
<code>getPageWidth</code>
12960-
<code>setAlias</code>
12961-
<code>setAutoPageBreak</code>
12962-
<code>setAutoPageBreak</code>
12963-
<code>setAutoPageBreak</code>
12964-
<code>setCMargin</code>
12965-
<code>setCMargin</code>
12966-
<code>setCMargin</code>
12967-
<code>setFontSize</code>
12968-
<code>setFontSizeScale</code>
12969-
<code>setLineWidthScale</code>
12970-
<code>setLink</code>
12971-
<code>setOffline</code>
12972-
<code>setScale</code>
12973-
<code>setTitle</code>
12974-
</PossiblyNullReference>
1297512899
<PossiblyUndefinedArrayOffset>
1297612900
<code><![CDATA[$row['Null']]]></code>
1297712901
</PossiblyUndefinedArrayOffset>
@@ -13197,12 +13121,6 @@
1319713121
<code><![CDATA[$one_key['ref_table_name']]]></code>
1319813122
<code><![CDATA[$rel['foreign_field']]]></code>
1319913123
<code><![CDATA[$rel['foreign_table']]]></code>
13200-
<code><![CDATA[$this->diagram->getFont()]]></code>
13201-
<code><![CDATA[$this->diagram->getFont()]]></code>
13202-
<code><![CDATA[$this->diagram->getFont()]]></code>
13203-
<code><![CDATA[$this->diagram->getFontSize()]]></code>
13204-
<code><![CDATA[$this->diagram->getFontSize()]]></code>
13205-
<code><![CDATA[$this->diagram->getFontSize()]]></code>
1320613124
</MixedArgument>
1320713125
<MixedArgumentTypeCoercion>
1320813126
<code>$master_field</code>
@@ -13227,29 +13145,13 @@
1322713145
<code>$rel</code>
1322813146
</MixedAssignment>
1322913147
<PossiblyInvalidArgument>
13230-
<code><![CDATA[$this->diagram]]></code>
1323113148
<code><![CDATA[$this->tables[$table]]]></code>
1323213149
<code><![CDATA[$this->xMax + $border]]></code>
1323313150
<code><![CDATA[$this->xMin - $border]]></code>
1323413151
<code><![CDATA[$this->yMax + $border]]></code>
1323513152
<code><![CDATA[$this->yMin - $border]]></code>
1323613153
</PossiblyInvalidArgument>
13237-
<PossiblyNullReference>
13238-
<code>endSvgDoc</code>
13239-
<code>getFont</code>
13240-
<code>getFont</code>
13241-
<code>getFont</code>
13242-
<code>getFontSize</code>
13243-
<code>getFontSize</code>
13244-
<code>getFontSize</code>
13245-
<code>setAuthor</code>
13246-
<code>setFont</code>
13247-
<code>setFontSize</code>
13248-
<code>setTitle</code>
13249-
<code>startSvgDoc</code>
13250-
</PossiblyNullReference>
1325113154
<TooFewArguments>
13252-
<code>setFont</code>
1325313155
<code>tableDraw</code>
1325413156
<code>tableDraw</code>
1325513157
</TooFewArguments>

test/classes/Plugins/Schema/ExportRelationSchemaTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
*/
1414
class ExportRelationSchemaTest extends AbstractTestCase
1515
{
16-
/** @var ExportRelationSchema */
16+
/** @var ExportRelationSchema<null> */
1717
protected $object;
1818

1919
/**

0 commit comments

Comments
 (0)