Skip to content

Commit 984ca84

Browse files
Merge pull request #18766 from MauricioFauth/db-designer-export-errors
Fix some type errors when exporting from db designer
2 parents d43dbfc + 25beca2 commit 984ca84

8 files changed

Lines changed: 56 additions & 118 deletions

File tree

phpstan-baseline.neon

Lines changed: 5 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -15500,31 +15500,6 @@ parameters:
1550015500
count: 1
1550115501
path: src/Plugins/Schema/Eps/TableStatsEps.php
1550215502

15503-
-
15504-
message: "#^Parameter \\#1 \\$xFrom of method PhpMyAdmin\\\\Plugins\\\\Schema\\\\Eps\\\\Eps\\:\\:rect\\(\\) expects int, float\\|int given\\.$#"
15505-
count: 2
15506-
path: src/Plugins/Schema/Eps/TableStatsEps.php
15507-
15508-
-
15509-
message: "#^Parameter \\#2 \\$x of method PhpMyAdmin\\\\Plugins\\\\Schema\\\\Eps\\\\Eps\\:\\:showXY\\(\\) expects int, float\\|int given\\.$#"
15510-
count: 2
15511-
path: src/Plugins/Schema/Eps/TableStatsEps.php
15512-
15513-
-
15514-
message: "#^Parameter \\#2 \\$yFrom of method PhpMyAdmin\\\\Plugins\\\\Schema\\\\Eps\\\\Eps\\:\\:rect\\(\\) expects int, float\\|int given\\.$#"
15515-
count: 2
15516-
path: src/Plugins/Schema/Eps/TableStatsEps.php
15517-
15518-
-
15519-
message: "#^Parameter \\#3 \\$xTo of method PhpMyAdmin\\\\Plugins\\\\Schema\\\\Eps\\\\Eps\\:\\:rect\\(\\) expects int, float\\|int given\\.$#"
15520-
count: 2
15521-
path: src/Plugins/Schema/Eps/TableStatsEps.php
15522-
15523-
-
15524-
message: "#^Parameter \\#3 \\$y of method PhpMyAdmin\\\\Plugins\\\\Schema\\\\Eps\\\\Eps\\:\\:showXY\\(\\) expects int, float\\|int given\\.$#"
15525-
count: 2
15526-
path: src/Plugins/Schema/Eps/TableStatsEps.php
15527-
1552815503
-
1552915504
message: "#^Argument of an invalid type mixed supplied for foreach, only iterables are supported\\.$#"
1553015505
count: 1
@@ -15781,18 +15756,18 @@ parameters:
1578115756
path: src/Plugins/Schema/Pdf/TableStatsPdf.php
1578215757

1578315758
-
15784-
message: "#^Parameter \\#1 \\$link of method TCPDF\\:\\:setLink\\(\\) expects int, mixed given\\.$#"
15759+
message: "#^Cannot cast mixed to string\\.$#"
1578515760
count: 2
1578615761
path: src/Plugins/Schema/Pdf/TableStatsPdf.php
1578715762

1578815763
-
15789-
message: "#^Parameter \\#1 \\$s of method TCPDF\\:\\:GetStringWidth\\(\\) expects string, mixed given\\.$#"
15790-
count: 1
15764+
message: "#^Parameter \\#1 \\$link of method TCPDF\\:\\:setLink\\(\\) expects int, mixed given\\.$#"
15765+
count: 2
1579115766
path: src/Plugins/Schema/Pdf/TableStatsPdf.php
1579215767

1579315768
-
15794-
message: "#^Parameter \\#8 \\$link of method PhpMyAdmin\\\\Plugins\\\\Schema\\\\Pdf\\\\Pdf\\:\\:cellScale\\(\\) expects string, mixed given\\.$#"
15795-
count: 2
15769+
message: "#^Parameter \\#1 \\$s of method TCPDF\\:\\:GetStringWidth\\(\\) expects string, mixed given\\.$#"
15770+
count: 1
1579615771
path: src/Plugins/Schema/Pdf/TableStatsPdf.php
1579715772

1579815773
-
@@ -15880,16 +15855,6 @@ parameters:
1588015855
count: 1
1588115856
path: src/Plugins/Schema/Svg/TableStatsSvg.php
1588215857

15883-
-
15884-
message: "#^Parameter \\#2 \\$x of method PhpMyAdmin\\\\Plugins\\\\Schema\\\\Svg\\\\Svg\\:\\:printElement\\(\\) expects int, float\\|int given\\.$#"
15885-
count: 4
15886-
path: src/Plugins/Schema/Svg/TableStatsSvg.php
15887-
15888-
-
15889-
message: "#^Parameter \\#3 \\$y of method PhpMyAdmin\\\\Plugins\\\\Schema\\\\Svg\\\\Svg\\:\\:printElement\\(\\) expects int, float\\|int given\\.$#"
15890-
count: 4
15891-
path: src/Plugins/Schema/Svg/TableStatsSvg.php
15892-
1589315858
-
1589415859
message: "#^Parameter \\#6 \\$text of method PhpMyAdmin\\\\Plugins\\\\Schema\\\\Svg\\\\Svg\\:\\:printElement\\(\\) expects string\\|null, mixed given\\.$#"
1589515860
count: 1

psalm-baseline.xml

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -10014,18 +10014,6 @@
1001410014
<code>$field</code>
1001510015
<code>$field</code>
1001610016
</MixedAssignment>
10017-
<PossiblyInvalidArgument>
10018-
<code><![CDATA[$this->width]]></code>
10019-
<code><![CDATA[$this->width]]></code>
10020-
<code><![CDATA[$this->x]]></code>
10021-
<code><![CDATA[$this->x]]></code>
10022-
<code><![CDATA[$this->x + 5]]></code>
10023-
<code><![CDATA[$this->x + 5]]></code>
10024-
<code><![CDATA[$this->y + 12]]></code>
10025-
<code><![CDATA[$this->y + 12 + $this->currentCell]]></code>
10026-
<code><![CDATA[$this->y + 14]]></code>
10027-
<code><![CDATA[$this->y + 14 + $this->currentCell]]></code>
10028-
</PossiblyInvalidArgument>
1002910017
<PossiblyUnusedProperty>
1003010018
<code>$height</code>
1003110019
</PossiblyUnusedProperty>
@@ -10274,8 +10262,6 @@
1027410262
<code>$field</code>
1027510263
<code><![CDATA[$this->diagram->customLinks['RT'][$this->tableName][$field]]]></code>
1027610264
<code><![CDATA[$this->diagram->customLinks['RT'][$this->tableName]['-']]]></code>
10277-
<code><![CDATA[$this->diagram->customLinks['doc'][$this->tableName][$field]]]></code>
10278-
<code><![CDATA[$this->diagram->customLinks['doc'][$this->tableName]['-']]]></code>
1027910265
</MixedArgument>
1028010266
<MixedArrayAccess>
1028110267
<code><![CDATA[$this->diagram->customLinks['RT'][$this->tableName]]]></code>
@@ -10449,16 +10435,6 @@
1044910435
<code>$field</code>
1045010436
<code>$field</code>
1045110437
</MixedAssignment>
10452-
<PossiblyInvalidArgument>
10453-
<code><![CDATA[$this->x]]></code>
10454-
<code><![CDATA[$this->x]]></code>
10455-
<code><![CDATA[$this->x + 5]]></code>
10456-
<code><![CDATA[$this->x + 5]]></code>
10457-
<code><![CDATA[$this->y]]></code>
10458-
<code><![CDATA[$this->y + $this->currentCell]]></code>
10459-
<code><![CDATA[$this->y + 14]]></code>
10460-
<code><![CDATA[$this->y + 14 + $this->currentCell]]></code>
10461-
</PossiblyInvalidArgument>
1046210438
</file>
1046310439
<file src="src/Plugins/Schema/TableStats.php">
1046410440
<DeprecatedMethod>

src/Plugins/Schema/Eps/Eps.php

Lines changed: 22 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -122,21 +122,17 @@ public function getFontSize(): int
122122
* drawing the lines from x,y source to x,y destination and set the
123123
* width of the line. lines helps in showing relationships of tables
124124
*
125-
* @param int $xFrom The x_from attribute defines the start
126-
* left position of the element
127-
* @param int $yFrom The y_from attribute defines the start
128-
* right position of the element
129-
* @param int $xTo The x_to attribute defines the end
130-
* left position of the element
131-
* @param int $yTo The y_to attribute defines the end
132-
* right position of the element
133-
* @param int $lineWidth Sets the width of the line e.g 2
125+
* @param int|float $xFrom The x_from attribute defines the start left position of the element
126+
* @param int|float $yFrom The y_from attribute defines the start right position of the element
127+
* @param int|float $xTo The x_to attribute defines the end left position of the element
128+
* @param int|float $yTo The y_to attribute defines the end right position of the element
129+
* @param int $lineWidth Sets the width of the line e.g 2
134130
*/
135131
public function line(
136-
int $xFrom = 0,
137-
int $yFrom = 0,
138-
int $xTo = 0,
139-
int $yTo = 0,
132+
int|float $xFrom = 0,
133+
int|float $yFrom = 0,
134+
int|float $xTo = 0,
135+
int|float $yTo = 0,
140136
int $lineWidth = 0,
141137
): void {
142138
$this->stringCommands .= $lineWidth . " setlinewidth \n";
@@ -151,17 +147,13 @@ public function line(
151147
* drawing the rectangle from x,y source to x,y destination and set the
152148
* width of the line. rectangles drawn around the text shown of fields
153149
*
154-
* @param int $xFrom The x_from attribute defines the start
155-
* left position of the element
156-
* @param int $yFrom The y_from attribute defines the start
157-
* right position of the element
158-
* @param int $xTo The x_to attribute defines the end
159-
* left position of the element
160-
* @param int $yTo The y_to attribute defines the end
161-
* right position of the element
162-
* @param int $lineWidth Sets the width of the line e.g 2
150+
* @param int|float $xFrom The x_from attribute defines the start left position of the element
151+
* @param int|float $yFrom The y_from attribute defines the start right position of the element
152+
* @param int|float $xTo The x_to attribute defines the end left position of the element
153+
* @param int|float $yTo The y_to attribute defines the end right position of the element
154+
* @param int $lineWidth Sets the width of the line e.g 2
163155
*/
164-
public function rect(int $xFrom, int $yFrom, int $xTo, int $yTo, int $lineWidth): void
156+
public function rect(int|float $xFrom, int|float $yFrom, int|float $xTo, int|float $yTo, int $lineWidth): void
165157
{
166158
$this->stringCommands .= $lineWidth . " setlinewidth \n";
167159
$this->stringCommands .= "newpath \n";
@@ -180,10 +172,10 @@ public function rect(int $xFrom, int $yFrom, int $xTo, int $yTo, int $lineWidth)
180172
* them as x and y coordinates to which to move. The coordinates
181173
* specified become the current point.
182174
*
183-
* @param int $x The x attribute defines the left position of the element
184-
* @param int $y The y attribute defines the right position of the element
175+
* @param int|float $x The x attribute defines the left position of the element
176+
* @param int|float $y The y attribute defines the right position of the element
185177
*/
186-
public function moveTo(int $x, int $y): void
178+
public function moveTo(int|float $x, int|float $y): void
187179
{
188180
$this->stringCommands .= $x . ' ' . $y . " moveto \n";
189181
}
@@ -201,11 +193,11 @@ public function show(string $text): void
201193
/**
202194
* Output the text at specified co-ordinates
203195
*
204-
* @param string $text String to be displayed
205-
* @param int $x X attribute defines the left position of the element
206-
* @param int $y Y attribute defines the right position of the element
196+
* @param string $text String to be displayed
197+
* @param int|float $x X attribute defines the left position of the element
198+
* @param int|float $y Y attribute defines the right position of the element
207199
*/
208-
public function showXY(string $text, int $x, int $y): void
200+
public function showXY(string $text, int|float $x, int|float $y): void
209201
{
210202
$this->moveTo($x, $y);
211203
$this->show($text);

src/Plugins/Schema/Eps/EpsRelationSchema.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ public function getExportInfo(): array
165165
*
166166
* @see _setMinMax
167167
* @see TableStatsEps::__construct()
168-
* @see PhpMyAdmin\Plugins\Schema\Eps\RelationStatsEps::__construct()
168+
* @see RelationStatsEps::__construct
169169
*
170170
* @param string $masterTable The master table name
171171
* @param string $font The font

src/Plugins/Schema/Pdf/PdfRelationSchema.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ private function addRelation(
373373
/**
374374
* Draws the grid
375375
*
376-
* @see PMA_Schema_PDF
376+
* @see Pdf
377377
*/
378378
private function strokeGrid(): void
379379
{

src/Plugins/Schema/Pdf/RelationStatsPdf.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
* master table's master field to foreign table's foreign key
2121
* in PDF document.
2222
*
23-
* @see Schema\Pdf::setDrawColor
24-
* @see Schema\Pdf::setLineWidthScale
23+
* @see Pdf::setDrawColor
24+
* @see Pdf::setLineWidthScale
2525
* @see Pdf::lineScale
2626
*/
2727
class RelationStatsPdf extends RelationStats

src/Plugins/Schema/Pdf/TableStatsPdf.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
* This class preserves the table co-ordinates,fields
2424
* and helps in drawing/generating the Tables in PDF document.
2525
*
26-
* @see Schema\Pdf
26+
* @see Pdf
2727
*
2828
* @property Pdf $diagram
2929
*/
@@ -34,9 +34,9 @@ class TableStatsPdf extends TableStats
3434
private string $ff = PdfLib::PMA_PDF_FONT;
3535

3636
/**
37-
* @see PMA_Schema_PDF
37+
* @see Pdf
3838
* @see TableStatsPdf::setWidthTable
39-
* @see PhpMyAdmin\Plugins\Schema\Pdf\TableStatsPdf::setHeightTable
39+
* @see TableStatsPdf::setHeightTable
4040
*
4141
* @param Pdf $diagram The PDF diagram
4242
* @param string $db The database name
@@ -96,7 +96,7 @@ protected function getTitle(): string
9696
/**
9797
* Sets the width of the table
9898
*
99-
* @see PMA_Schema_PDF
99+
* @see Pdf
100100
*
101101
* @param int|null $fontSize The font size
102102
*/
@@ -127,7 +127,7 @@ private function setHeight(): void
127127
/**
128128
* Do draw the table
129129
*
130-
* @see Schema\Pdf
130+
* @see Pdf
131131
*
132132
* @param int|null $fontSize The font size or null to use the default value
133133
* @param bool $withDoc Whether to include links to documentation
@@ -156,7 +156,7 @@ public function tableDraw(int|null $fontSize, bool $withDoc, bool $setColor = fa
156156
1,
157157
'C',
158158
$setColor,
159-
$this->diagram->customLinks['doc'][$this->tableName]['-'],
159+
(string) $this->diagram->customLinks['doc'][$this->tableName]['-'],
160160
);
161161
$this->diagram->setXScale($this->x);
162162
$this->diagram->setFont($this->ff, '', $fontSize);
@@ -188,7 +188,7 @@ public function tableDraw(int|null $fontSize, bool $withDoc, bool $setColor = fa
188188
1,
189189
'L',
190190
$setColor,
191-
$this->diagram->customLinks['doc'][$this->tableName][$field],
191+
(string) $this->diagram->customLinks['doc'][$this->tableName][$field],
192192
);
193193
$this->diagram->setXScale($this->x);
194194
$this->diagram->setFillColor(255);

src/Plugins/Schema/Svg/Svg.php

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -171,10 +171,10 @@ public function getOutputData(): string
171171
* @see XMLWriter::endElement()
172172
*
173173
* @param string $name RelationStatsSvg element name
174-
* @param int $x The x attr defines the left position of the element
174+
* @param int|float $x The x attr defines the left position of the element
175175
* (e.g. x="0" places the element 0 pixels from the
176176
* left of the browser window)
177-
* @param int $y The y attribute defines the top position of the
177+
* @param int|float $y The y attribute defines the top position of the
178178
* element (e.g. y="0" places the element 0 pixels
179179
* from the top of the browser window)
180180
* @param int|float $width The width attribute defines the width the element
@@ -185,8 +185,8 @@ public function getOutputData(): string
185185
*/
186186
public function printElement(
187187
string $name,
188-
int $x,
189-
int $y,
188+
int|float $x,
189+
int|float $y,
190190
int|float $width,
191191
int $height,
192192
string|null $text = '',
@@ -218,16 +218,21 @@ public function printElement(
218218
* @see XMLWriter::writeAttribute()
219219
* @see XMLWriter::endElement()
220220
*
221-
* @param string $name RelationStatsSvg element name i.e line
222-
* @param int $x1 Defines the start of the line on the x-axis
223-
* @param int $y1 Defines the start of the line on the y-axis
224-
* @param int $x2 Defines the end of the line on the x-axis
225-
* @param int $y2 Defines the end of the line on the y-axis
226-
* @param string $styles The style attribute defines the style the element
227-
* styles can be defined like CSS styles
221+
* @param string $name RelationStatsSvg element name i.e line
222+
* @param int|float $x1 Defines the start of the line on the x-axis
223+
* @param int|float $y1 Defines the start of the line on the y-axis
224+
* @param int|float $x2 Defines the end of the line on the x-axis
225+
* @param int|float $y2 Defines the end of the line on the y-axis
226+
* @param string $styles The style attribute defines the style the element styles can be defined like CSS styles
228227
*/
229-
public function printElementLine(string $name, int $x1, int $y1, int $x2, int $y2, string $styles): void
230-
{
228+
public function printElementLine(
229+
string $name,
230+
int|float $x1,
231+
int|float $y1,
232+
int|float $x2,
233+
int|float $y2,
234+
string $styles,
235+
): void {
231236
$this->startElement($name);
232237
$this->writeAttribute('x1', (string) $x1);
233238
$this->writeAttribute('y1', (string) $y1);

0 commit comments

Comments
 (0)