Skip to content

Commit 05b8e7d

Browse files
committed
Upgrade phpmyadmin/coding-standard to 3.0.0
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
1 parent 2087c28 commit 05b8e7d

6 files changed

Lines changed: 28 additions & 26 deletions

File tree

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
},
3535
"require-dev": {
3636
"phpstan/phpstan": "^0.12.37",
37-
"phpmyadmin/coding-standard": "^2.1.1",
37+
"phpmyadmin/coding-standard": "^3.0.0",
3838
"phpstan/phpstan-phpunit": "^0.12.6",
3939
"phpunit/phpunit": "^7.4 || ^8 || ^9"
4040
},

examples/read.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
*
3131
* @param string $filename File to open
3232
*/
33+
// phpcs:ignore Squiz.Functions.GlobalFunction.Found
3334
function display_file(string $filename): void
3435
{
3536
$shp = new ShapeFile(1);

phpcs.xml.dist

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,16 @@
1414
<exclude-pattern>*/examples/index.php</exclude-pattern>
1515

1616
<rule ref="PhpMyAdmin">
17-
<exclude name="SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingTraversableParameterTypeHintSpecification"/>
18-
<exclude name="SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingTraversablePropertyTypeHintSpecification"/>
19-
<exclude name="SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingTraversableReturnTypeHintSpecification"/>
20-
<exclude name="SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingPropertyTypeHint"/>
17+
<exclude name="SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingTraversableTypeHintSpecification"/>
18+
<exclude name="SlevomatCodingStandard.TypeHints.PropertyTypeHint.MissingTraversableTypeHintSpecification"/>
19+
<exclude name="SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification"/>
2120
</rule>
2221

23-
<rule ref="Squiz.Functions.GlobalFunction.Found">
24-
<exclude-pattern>*/examples/read.php</exclude-pattern>
25-
</rule>
26-
<!-- Fixing this issue has some side effects -->
27-
<rule ref="SlevomatCodingStandard.Operators.DisallowEqualOperators.DisallowedEqualOperator">
28-
<exclude-pattern>*/src/ShapeFile.php</exclude-pattern>
29-
</rule>
30-
<!-- Fixing this issue has some side effects -->
31-
<rule ref="SlevomatCodingStandard.Operators.DisallowEqualOperators.DisallowedNotEqualOperator">
32-
<exclude-pattern>*/src/ShapeFile.php</exclude-pattern>
22+
<rule ref="SlevomatCodingStandard.ControlStructures.RequireSingleLineCondition"/>
23+
<rule ref="SlevomatCodingStandard.Functions.RequireSingleLineCall"/>
24+
<rule ref="SlevomatCodingStandard.Whitespaces.DuplicateSpaces">
25+
<properties>
26+
<property name="ignoreSpacesInComment" value="true"/>
27+
</properties>
3328
</rule>
3429
</ruleset>

src/ShapeFile.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -205,15 +205,17 @@ private function updateBBox(string $type, array $data): void
205205
$min = $type . 'min';
206206
$max = $type . 'max';
207207

208-
if (! isset($this->boundingBox[$min])
209-
|| $this->boundingBox[$min] == 0.0
208+
if (
209+
! isset($this->boundingBox[$min])
210+
|| $this->boundingBox[$min] == 0.0 // phpcs:ignore SlevomatCodingStandard.Operators.DisallowEqualOperators
210211
|| ($this->boundingBox[$min] > $data[$min])
211212
) {
212213
$this->boundingBox[$min] = $data[$min];
213214
}
214215

215-
if (isset($this->boundingBox[$max])
216-
&& $this->boundingBox[$max] != 0.0
216+
if (
217+
isset($this->boundingBox[$max])
218+
&& $this->boundingBox[$max] != 0.0 // phpcs:ignore SlevomatCodingStandard.Operators.DisallowEqualOperators
217219
&& ($this->boundingBox[$max] >= $data[$max])
218220
) {
219221
return;
@@ -308,7 +310,8 @@ public function setDBFHeader(array $header): void
308310
public function getIndexFromDBFData(string $field, $value): int
309311
{
310312
foreach ($this->records as $index => $record) {
311-
if (isset($record->dbfData[$field]) &&
313+
if (
314+
isset($record->dbfData[$field]) &&
312315
(trim(strtoupper($record->dbfData[$field])) === strtoupper($value))
313316
) {
314317
return $index;
@@ -691,6 +694,7 @@ public function getShapeName(): string
691694
*/
692695
public function hasMeasure(): bool
693696
{
697+
// phpcs:ignore SlevomatCodingStandard.Operators.DisallowEqualOperators.DisallowedNotEqualOperator
694698
return $this->boundingBox['mmin'] != 0 || $this->boundingBox['mmax'] != 0;
695699
}
696700
}

src/ShapeRecord.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,8 @@ private function loadPolyLineRecord(): void
480480
++$part;
481481
}
482482

483-
if (! isset($this->shpData['parts'][$part]['points'])
483+
if (
484+
! isset($this->shpData['parts'][$part]['points'])
484485
|| ! is_array($this->shpData['parts'][$part]['points'])
485486
) {
486487
$this->shpData['parts'][$part] = ['points' => []];
@@ -687,6 +688,7 @@ public function addPoint(array $point, int $partIndex = 0): void
687688
case 0:
688689
//Don't add anything
689690
return;
691+
690692
case 1:
691693
case 11:
692694
case 21:
@@ -754,7 +756,8 @@ public function deletePoint(int $pointIndex = 0, int $partIndex = 0): void
754756
case 23:
755757
case 25:
756758
//Deletes the point from the selected part, if exists
757-
if (isset($this->shpData['parts'][$partIndex])
759+
if (
760+
isset($this->shpData['parts'][$partIndex])
758761
&& isset($this->shpData['parts'][$partIndex]['points'][$pointIndex])
759762
) {
760763
$count = count($this->shpData['parts'][$partIndex]['points']) - 1;

tests/ShapeFileTest.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
use PhpMyAdmin\ShapeFile\ShapeFile;
2929
use PhpMyAdmin\ShapeFile\ShapeRecord;
3030
use PHPUnit\Framework\TestCase;
31+
3132
use function count;
3233

3334
class ShapeFileTest extends TestCase
@@ -121,6 +122,7 @@ public function testLoadEmptyFilename(): void
121122

122123
return;
123124
}
125+
124126
$this->assertEquals('Not a SHP file (file code mismatch)', $shp->lastError);
125127
}
126128

@@ -360,10 +362,7 @@ public function testShapeSaveLoad(int $type, array $points): void
360362
continue;
361363
}
362364

363-
$this->assertEquals(
364-
$record->shpData[$item],
365-
$record2->shpData[$item]
366-
);
365+
$this->assertEquals($record->shpData[$item], $record2->shpData[$item]);
367366
}
368367

369368
/* Test deletion works */

0 commit comments

Comments
 (0)