Skip to content

Commit a975456

Browse files
committed
Remove unnecessary array count in ImportShp::doImport()
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
1 parent ec0c6d8 commit a975456

3 files changed

Lines changed: 17 additions & 44 deletions

File tree

phpstan-baseline.neon

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -15195,21 +15195,6 @@ parameters:
1519515195
count: 4
1519615196
path: src/Plugins/Import/ImportShp.php
1519715197

15198-
-
15199-
message: "#^Cannot access offset mixed on mixed\\.$#"
15200-
count: 1
15201-
path: src/Plugins/Import/ImportShp.php
15202-
15203-
-
15204-
message: "#^Cannot access property \\$dbfData on mixed\\.$#"
15205-
count: 1
15206-
path: src/Plugins/Import/ImportShp.php
15207-
15208-
-
15209-
message: "#^Cannot access property \\$shpData on mixed\\.$#"
15210-
count: 1
15211-
path: src/Plugins/Import/ImportShp.php
15212-
1521315198
-
1521415199
message: "#^Cannot cast mixed to string\\.$#"
1521515200
count: 3
@@ -15255,11 +15240,6 @@ parameters:
1525515240
count: 1
1525615241
path: src/Plugins/Import/ImportShp.php
1525715242

15258-
-
15259-
message: "#^Parameter \\#1 \\$rowData of method PhpMyAdmin\\\\Gis\\\\GisMultiLineString\\:\\:getShape\\(\\) expects array, mixed given\\.$#"
15260-
count: 1
15261-
path: src/Plugins/Import/ImportShp.php
15262-
1526315243
-
1526415244
message: "#^Parameter \\#1 \\$string of function mb_substr expects string, mixed given\\.$#"
1526515245
count: 1

psalm-baseline.xml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9658,7 +9658,6 @@
96589658
<code>$c[0]</code>
96599659
<code>$dbfHeader[$n]</code>
96609660
<code>$dbfHeader[$n][0]</code>
9661-
<code><![CDATA[$record->dbfData[$c[0]]]]></code>
96629661
</MixedArrayAccess>
96639662
<MixedArrayAssignment>
96649663
<code>$analyses[$tableNo][Import::FORMATTEDSQL]</code>
@@ -9685,7 +9684,6 @@
96859684
<code>$dbfFileName</code>
96869685
<code>$dbfHeader</code>
96879686
<code>$extracted</code>
9688-
<code>$record</code>
96899687
<code>$result</code>
96909688
<code>$temp</code>
96919689
</MixedAssignment>
@@ -9696,8 +9694,6 @@
96969694
</MixedOperand>
96979695
<MixedPropertyFetch>
96989696
<code><![CDATA[$config->settings]]></code>
9699-
<code><![CDATA[$record->dbfData]]></code>
9700-
<code><![CDATA[$record->shpData]]></code>
97019697
</MixedPropertyFetch>
97029698
<MixedReturnTypeCoercion>
97039699
<code>$sqlStatements</code>

src/Plugins/Import/ImportShp.php

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -209,36 +209,33 @@ public function doImport(File|null $importHandle = null): array
209209
$gisObj = null;
210210
}
211211

212-
$numRows = count($shp->records);
213212
// If .dbf file is loaded, the number of extra data columns
214213
$numDataCols = $shp->getDBFHeader() !== null ? count($shp->getDBFHeader()) : 0;
215214

216215
$rows = [];
217216
$colNames = [];
218-
if ($numRows != 0) {
219-
foreach ($shp->records as $record) {
220-
$tempRow = [];
221-
if ($gisObj == null || ! method_exists($gisObj, 'getShape')) {
222-
$tempRow[] = null;
223-
} else {
224-
$tempRow[] = "GeomFromText('"
225-
. $gisObj->getShape($record->shpData) . "')";
226-
}
227-
228-
if ($shp->getDBFHeader() !== null) {
229-
foreach ($shp->getDBFHeader() as $c) {
230-
$cell = trim((string) $record->dbfData[$c[0]]);
217+
foreach ($shp->records as $record) {
218+
$tempRow = [];
219+
if ($gisObj == null || ! method_exists($gisObj, 'getShape')) {
220+
$tempRow[] = null;
221+
} else {
222+
$tempRow[] = "GeomFromText('"
223+
. $gisObj->getShape($record->shpData) . "')";
224+
}
231225

232-
if ($cell === '') {
233-
$cell = 'NULL';
234-
}
226+
if ($shp->getDBFHeader() !== null) {
227+
foreach ($shp->getDBFHeader() as $c) {
228+
$cell = trim((string) $record->dbfData[$c[0]]);
235229

236-
$tempRow[] = $cell;
230+
if ($cell === '') {
231+
$cell = 'NULL';
237232
}
238-
}
239233

240-
$rows[] = $tempRow;
234+
$tempRow[] = $cell;
235+
}
241236
}
237+
238+
$rows[] = $tempRow;
242239
}
243240

244241
if ($rows === []) {

0 commit comments

Comments
 (0)