Passed
Pull Request — master (#34)
by
unknown
09:58
created
src/ShapeRecord.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
     /** @var resource */
42 42
     private $shpFile;
43 43
 
44
-    private ShapeFile|null $shapeFile = null;
44
+    private ShapeFile | null $shapeFile = null;
45 45
 
46 46
     private int $size = 0;
47 47
 
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
             $this->reportInvalidShapeTypeError();
105 105
         }
106 106
 
107
-        if (! ShapeFile::supportsDbase() || $dbfFile === false) {
107
+        if (!ShapeFile::supportsDbase() || $dbfFile === false) {
108 108
             return;
109 109
         }
110 110
 
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
             default => $this->reportInvalidShapeTypeError(),
142 142
         };
143 143
 
144
-        if (! ShapeFile::supportsDbase() || $dbfFile === false) {
144
+        if (!ShapeFile::supportsDbase() || $dbfFile === false) {
145 145
             return;
146 146
         }
147 147
 
@@ -331,7 +331,7 @@  discard block
 block discarded – undo
331 331
     private function loadMultiPointMZRecord(string $type): void
332 332
     {
333 333
         /* The m dimension is optional, depends on bounding box data */
334
-        if ($type === 'm' && ! $this->shapeFile->hasMeasure()) {
334
+        if ($type === 'm' && !$this->shapeFile->hasMeasure()) {
335 335
             return;
336 336
         }
337 337
 
@@ -421,8 +421,8 @@  discard block
 block discarded – undo
421 421
             }
422 422
 
423 423
             if (
424
-                ! isset($this->shpData['parts'][$part]['points'])
425
-                || ! is_array($this->shpData['parts'][$part]['points'])
424
+                !isset($this->shpData['parts'][$part]['points'])
425
+                || !is_array($this->shpData['parts'][$part]['points'])
426 426
             ) {
427 427
                 $this->shpData['parts'][$part] = ['points' => []];
428 428
             }
@@ -434,7 +434,7 @@  discard block
 block discarded – undo
434 434
     private function loadPolyLineMZRecord(string $type): void
435 435
     {
436 436
         /* The m dimension is optional, depends on bounding box data */
437
-        if ($type === 'm' && ! $this->shapeFile->hasMeasure()) {
437
+        if ($type === 'm' && !$this->shapeFile->hasMeasure()) {
438 438
             return;
439 439
         }
440 440
 
@@ -555,13 +555,13 @@  discard block
 block discarded – undo
555 555
     {
556 556
         // Adjusts bounding box based on point
557 557
         foreach (['x', 'y', 'z', 'm'] as $direction) {
558
-            if (! isset($point[$direction])) {
558
+            if (!isset($point[$direction])) {
559 559
                 continue;
560 560
             }
561 561
 
562 562
             $min = $direction . 'min';
563 563
             $max = $direction . 'max';
564
-            if (! isset($this->shpData[$min]) || ($this->shpData[$min] > $point[$direction])) {
564
+            if (!isset($this->shpData[$min]) || ($this->shpData[$min] > $point[$direction])) {
565 565
                 $this->shpData[$min] = $point[$direction];
566 566
             }
567 567
 
@@ -718,7 +718,7 @@  discard block
 block discarded – undo
718 718
     /**
719 719
      * Returns length of content.
720 720
      */
721
-    public function getContentLength(): int|null
721
+    public function getContentLength(): int | null
722 722
     {
723 723
         // The content length for a record is the length of the record contents section measured in 16-bit words.
724 724
         // one coordinate makes 4 16-bit words (64 bit double)
@@ -796,10 +796,10 @@  discard block
 block discarded – undo
796 796
 
797 797
         unset($this->dbfData['deleted']);
798 798
         if ($this->recordNumber <= dbase_numrecords($dbfFile)) {
799
-            if (! dbase_replace_record($dbfFile, array_values($this->dbfData), $this->recordNumber)) {
799
+            if (!dbase_replace_record($dbfFile, array_values($this->dbfData), $this->recordNumber)) {
800 800
                 $this->setError("I wasn't possible to update the information in the DBF file.");
801 801
             }
802
-        } elseif (! dbase_add_record($dbfFile, array_values($this->dbfData))) {
802
+        } elseif (!dbase_add_record($dbfFile, array_values($this->dbfData))) {
803 803
             $this->setError("I wasn't possible to add the information to the DBF file.");
804 804
         }
805 805
     }
Please login to merge, or discard this patch.
src/ShapeFile.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
     private $dbfFile = false;
64 64
 
65 65
     /** @var mixed[]|null */
66
-    private array|null $dbfHeader = null;
66
+    private array | null $dbfHeader = null;
67 67
 
68 68
     public string $lastError = '';
69 69
 
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
             'xmax' => 0.0,
98 98
             'ymax' => 0.0,
99 99
         ],
100
-        public string|null $fileName = null,
100
+        public string | null $fileName = null,
101 101
     ) {
102 102
     }
103 103
 
@@ -117,14 +117,14 @@  discard block
 block discarded – undo
117 117
         }
118 118
 
119 119
         if ($result && ($this->openDBFFile())) {
120
-            if (! $this->loadHeaders()) {
120
+            if (!$this->loadHeaders()) {
121 121
                 $this->closeSHPFile();
122 122
                 $this->closeDBFFile();
123 123
 
124 124
                 return false;
125 125
             }
126 126
 
127
-            if (! $this->loadRecords()) {
127
+            if (!$this->loadRecords()) {
128 128
                 $this->closeSHPFile();
129 129
                 $this->closeDBFFile();
130 130
 
@@ -145,13 +145,13 @@  discard block
 block discarded – undo
145 145
      *
146 146
      * @param string|null $fileName Name of file, otherwise existing is used
147 147
      */
148
-    public function saveToFile(string|null $fileName = null): bool
148
+    public function saveToFile(string | null $fileName = null): bool
149 149
     {
150 150
         if ($fileName !== null) {
151 151
             $this->fileName = $fileName;
152 152
         }
153 153
 
154
-        if (! $this->openSHPFile(true) || (! $this->openSHXFile(true)) || (! $this->createDBFFile())) {
154
+        if (!$this->openSHPFile(true) || (!$this->openSHXFile(true)) || (!$this->createDBFFile())) {
155 155
             return false;
156 156
         }
157 157
 
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
         $max = $type . 'max';
187 187
 
188 188
         if (
189
-            ! isset($this->boundingBox[$min])
189
+            !isset($this->boundingBox[$min])
190 190
             || $this->boundingBox[$min] == 0.0 // phpcs:ignore SlevomatCodingStandard.Operators.DisallowEqualOperators
191 191
             || ($this->boundingBox[$min] > $data[$min])
192 192
         ) {
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
      */
239 239
     public function deleteRecord(int $index): void
240 240
     {
241
-        if (! isset($this->records[$index])) {
241
+        if (!isset($this->records[$index])) {
242 242
             return;
243 243
         }
244 244
 
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
      *
258 258
      * @return mixed[]|null see setDBFHeader for more information
259 259
      */
260
-    public function getDBFHeader(): array|null
260
+    public function getDBFHeader(): array | null
261 261
     {
262 262
         return $this->dbfHeader;
263 263
     }
@@ -347,7 +347,7 @@  discard block
 block discarded – undo
347 347
      */
348 348
     private function deleteRecordFromDBF(int $index): void
349 349
     {
350
-        if ($this->dbfFile === false || ! @dbase_delete_record($this->dbfFile, $index)) {
350
+        if ($this->dbfFile === false || !@dbase_delete_record($this->dbfFile, $index)) {
351 351
             return;
352 352
         }
353 353
 
@@ -455,7 +455,7 @@  discard block
 block discarded – undo
455 455
     private function loadRecords(): bool
456 456
     {
457 457
         /* Need to start at offset 100 */
458
-        while (! $this->eofSHP()) {
458
+        while (!$this->eofSHP()) {
459 459
             $record = new ShapeRecord(ShapeType::Unknown);
460 460
             $record->loadFromFile($this, $this->dbfFile);
461 461
             if ($record->lastError !== '') {
@@ -508,7 +508,7 @@  discard block
 block discarded – undo
508 508
     {
509 509
         $shpName = $this->getFilename($extension);
510 510
         $result = @fopen($shpName, ($toWrite ? 'wb+' : 'rb'));
511
-        if (! $result) {
511
+        if (!$result) {
512 512
             $this->setError(sprintf('It wasn\'t possible to open the %s file "%s"', $name, $shpName));
513 513
 
514 514
             return false;
@@ -572,7 +572,7 @@  discard block
 block discarded – undo
572 572
      */
573 573
     private function createDBFFile(): bool
574 574
     {
575
-        if (! self::supportsDbase() || $this->dbfHeader === null || $this->dbfHeader === []) {
575
+        if (!self::supportsDbase() || $this->dbfHeader === null || $this->dbfHeader === []) {
576 576
             $this->dbfFile = false;
577 577
 
578 578
             return true;
@@ -601,14 +601,14 @@  discard block
 block discarded – undo
601 601
      */
602 602
     private function openDBFFile(): bool
603 603
     {
604
-        if (! self::supportsDbase()) {
604
+        if (!self::supportsDbase()) {
605 605
             $this->dbfFile = false;
606 606
 
607 607
             return true;
608 608
         }
609 609
 
610 610
         $dbfName = $this->getFilename('.dbf');
611
-        if (! is_readable($dbfName)) {
611
+        if (!is_readable($dbfName)) {
612 612
             $this->setError(sprintf('It wasn\'t possible to find the DBase file "%s"', $dbfName));
613 613
 
614 614
             return false;
@@ -650,7 +650,7 @@  discard block
 block discarded – undo
650 650
      *
651 651
      * @param int<0, max> $bytes
652 652
      */
653
-    public function readSHP(int $bytes): string|false
653
+    public function readSHP(int $bytes): string | false
654 654
     {
655 655
         if ($this->shpFile === false) {
656 656
             return false;
Please login to merge, or discard this patch.
tests/ShapeFileTest.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
      *
44 44
      * @dataProvider provideFiles
45 45
      */
46
-    public function testLoad(string $filename, int $records, int|null $parts): void
46
+    public function testLoad(string $filename, int $records, int | null $parts): void
47 47
     {
48 48
         $shp = new ShapeFile(ShapeType::Point);
49 49
         $shp->loadFromFile($filename);
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
      */
222 222
     public function testCreate(): void
223 223
     {
224
-        if (! ShapeFile::supportsDbase()) {
224
+        if (!ShapeFile::supportsDbase()) {
225 225
             $this->markTestSkipped('dbase extension missing');
226 226
         }
227 227
 
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
      */
238 238
     public function testDelete(): void
239 239
     {
240
-        if (! ShapeFile::supportsDbase()) {
240
+        if (!ShapeFile::supportsDbase()) {
241 241
             $this->markTestSkipped('dbase extension missing');
242 242
         }
243 243
 
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
      */
260 260
     public function testAdd(): void
261 261
     {
262
-        if (! ShapeFile::supportsDbase()) {
262
+        if (!ShapeFile::supportsDbase()) {
263 263
             $this->markTestSkipped('dbase extension missing');
264 264
         }
265 265
 
@@ -341,7 +341,7 @@  discard block
 block discarded – undo
341 341
 
342 342
         $items = ['numparts', 'numpoints'];
343 343
         foreach ($items as $item) {
344
-            if (! isset($record->shpData[$item])) {
344
+            if (!isset($record->shpData[$item])) {
345 345
                 continue;
346 346
             }
347 347
 
@@ -408,7 +408,7 @@  discard block
 block discarded – undo
408 408
             -1,
409 409
             $shp->getIndexFromDBFData('CNTRY_NAME', 'nonexisting'),
410 410
         );
411
-        if (! ShapeFile::supportsDbase()) {
411
+        if (!ShapeFile::supportsDbase()) {
412 412
             return;
413 413
         }
414 414
 
Please login to merge, or discard this patch.