@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | * |
| 43 | 43 | * @dataProvider provideFiles |
| 44 | 44 | */ |
| 45 | - public function testLoad(string $filename, int $records, int|null $parts): void |
|
| 45 | + public function testLoad(string $filename, int $records, int | null $parts): void |
|
| 46 | 46 | { |
| 47 | 47 | $shp = new ShapeFile(1); |
| 48 | 48 | $shp->loadFromFile($filename); |
@@ -220,7 +220,7 @@ discard block |
||
| 220 | 220 | */ |
| 221 | 221 | public function testCreate(): void |
| 222 | 222 | { |
| 223 | - if (! ShapeFile::supportsDbase()) { |
|
| 223 | + if (!ShapeFile::supportsDbase()) { |
|
| 224 | 224 | $this->markTestSkipped('dbase extension missing'); |
| 225 | 225 | } |
| 226 | 226 | |
@@ -236,7 +236,7 @@ discard block |
||
| 236 | 236 | */ |
| 237 | 237 | public function testDelete(): void |
| 238 | 238 | { |
| 239 | - if (! ShapeFile::supportsDbase()) { |
|
| 239 | + if (!ShapeFile::supportsDbase()) { |
|
| 240 | 240 | $this->markTestSkipped('dbase extension missing'); |
| 241 | 241 | } |
| 242 | 242 | |
@@ -258,7 +258,7 @@ discard block |
||
| 258 | 258 | */ |
| 259 | 259 | public function testAdd(): void |
| 260 | 260 | { |
| 261 | - if (! ShapeFile::supportsDbase()) { |
|
| 261 | + if (!ShapeFile::supportsDbase()) { |
|
| 262 | 262 | $this->markTestSkipped('dbase extension missing'); |
| 263 | 263 | } |
| 264 | 264 | |
@@ -339,7 +339,7 @@ discard block |
||
| 339 | 339 | |
| 340 | 340 | $items = ['numparts', 'numpoints']; |
| 341 | 341 | foreach ($items as $item) { |
| 342 | - if (! isset($record->shpData[$item])) { |
|
| 342 | + if (!isset($record->shpData[$item])) { |
|
| 343 | 343 | continue; |
| 344 | 344 | } |
| 345 | 345 | |
@@ -406,7 +406,7 @@ discard block |
||
| 406 | 406 | -1, |
| 407 | 407 | $shp->getIndexFromDBFData('CNTRY_NAME', 'nonexisting'), |
| 408 | 408 | ); |
| 409 | - if (! ShapeFile::supportsDbase()) { |
|
| 409 | + if (!ShapeFile::supportsDbase()) { |
|
| 410 | 410 | return; |
| 411 | 411 | } |
| 412 | 412 | |
@@ -38,7 +38,7 @@ |
||
| 38 | 38 | * |
| 39 | 39 | * @dataProvider data |
| 40 | 40 | */ |
| 41 | - public function testLoadData(string $type, string|false $data, mixed $expected): void |
|
| 41 | + public function testLoadData(string $type, string | false $data, mixed $expected): void |
|
| 42 | 42 | { |
| 43 | 43 | $this->assertEquals( |
| 44 | 44 | $expected, |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | |
| 34 | 34 | class Util |
| 35 | 35 | { |
| 36 | - private static bool|null $littleEndian = null; |
|
| 36 | + private static bool | null $littleEndian = null; |
|
| 37 | 37 | |
| 38 | 38 | private const SHAPE_NAMES = [ |
| 39 | 39 | 0 => 'Null Shape', |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | * @param string $type type for unpack() |
| 59 | 59 | * @param string|false $data Data to process |
| 60 | 60 | */ |
| 61 | - public static function loadData(string $type, string|false $data): mixed |
|
| 61 | + public static function loadData(string $type, string | false $data): mixed |
|
| 62 | 62 | { |
| 63 | 63 | if ($data === false || $data === '') { |
| 64 | 64 | return false; |
@@ -63,7 +63,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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(-1); |
| 460 | 460 | $record->loadFromFile($this, $this->dbfFile); |
| 461 | 461 | if ($record->lastError !== '') { |
@@ -508,7 +508,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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; |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | /** @var resource */ |
| 43 | 43 | private $shpFile; |
| 44 | 44 | |
| 45 | - private ShapeFile|null $shapeFile = null; |
|
| 45 | + private ShapeFile | null $shapeFile = null; |
|
| 46 | 46 | |
| 47 | 47 | private int $size = 0; |
| 48 | 48 | |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | $this->setError(sprintf('Failed to parse record, read=%d, size=%d', $this->read, $this->size)); |
| 106 | 106 | } |
| 107 | 107 | |
| 108 | - if (! ShapeFile::supportsDbase() || $dbfFile === false) { |
|
| 108 | + if (!ShapeFile::supportsDbase() || $dbfFile === false) { |
|
| 109 | 109 | return; |
| 110 | 110 | } |
| 111 | 111 | |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | default => $this->setError(sprintf('The Shape Type "%s" is not supported.', $this->shapeType)), |
| 143 | 143 | }; |
| 144 | 144 | |
| 145 | - if (! ShapeFile::supportsDbase() || $dbfFile === false) { |
|
| 145 | + if (!ShapeFile::supportsDbase() || $dbfFile === false) { |
|
| 146 | 146 | return; |
| 147 | 147 | } |
| 148 | 148 | |
@@ -332,7 +332,7 @@ discard block |
||
| 332 | 332 | private function loadMultiPointMZRecord(string $type): void |
| 333 | 333 | { |
| 334 | 334 | /* The m dimension is optional, depends on bounding box data */ |
| 335 | - if ($type === 'm' && ! $this->shapeFile->hasMeasure()) { |
|
| 335 | + if ($type === 'm' && !$this->shapeFile->hasMeasure()) { |
|
| 336 | 336 | return; |
| 337 | 337 | } |
| 338 | 338 | |
@@ -422,8 +422,8 @@ discard block |
||
| 422 | 422 | } |
| 423 | 423 | |
| 424 | 424 | if ( |
| 425 | - ! isset($this->shpData['parts'][$part]['points']) |
|
| 426 | - || ! is_array($this->shpData['parts'][$part]['points']) |
|
| 425 | + !isset($this->shpData['parts'][$part]['points']) |
|
| 426 | + || !is_array($this->shpData['parts'][$part]['points']) |
|
| 427 | 427 | ) { |
| 428 | 428 | $this->shpData['parts'][$part] = ['points' => []]; |
| 429 | 429 | } |
@@ -435,7 +435,7 @@ discard block |
||
| 435 | 435 | private function loadPolyLineMZRecord(string $type): void |
| 436 | 436 | { |
| 437 | 437 | /* The m dimension is optional, depends on bounding box data */ |
| 438 | - if ($type === 'm' && ! $this->shapeFile->hasMeasure()) { |
|
| 438 | + if ($type === 'm' && !$this->shapeFile->hasMeasure()) { |
|
| 439 | 439 | return; |
| 440 | 440 | } |
| 441 | 441 | |
@@ -556,13 +556,13 @@ discard block |
||
| 556 | 556 | { |
| 557 | 557 | // Adjusts bounding box based on point |
| 558 | 558 | foreach (['x', 'y', 'z', 'm'] as $direction) { |
| 559 | - if (! isset($point[$direction])) { |
|
| 559 | + if (!isset($point[$direction])) { |
|
| 560 | 560 | continue; |
| 561 | 561 | } |
| 562 | 562 | |
| 563 | 563 | $min = $direction . 'min'; |
| 564 | 564 | $max = $direction . 'max'; |
| 565 | - if (! isset($this->shpData[$min]) || ($this->shpData[$min] > $point[$direction])) { |
|
| 565 | + if (!isset($this->shpData[$min]) || ($this->shpData[$min] > $point[$direction])) { |
|
| 566 | 566 | $this->shpData[$min] = $point[$direction]; |
| 567 | 567 | } |
| 568 | 568 | |
@@ -719,7 +719,7 @@ discard block |
||
| 719 | 719 | /** |
| 720 | 720 | * Returns length of content. |
| 721 | 721 | */ |
| 722 | - public function getContentLength(): int|null |
|
| 722 | + public function getContentLength(): int | null |
|
| 723 | 723 | { |
| 724 | 724 | // The content length for a record is the length of the record contents section measured in 16-bit words. |
| 725 | 725 | // one coordinate makes 4 16-bit words (64 bit double) |
@@ -797,10 +797,10 @@ discard block |
||
| 797 | 797 | |
| 798 | 798 | unset($this->dbfData['deleted']); |
| 799 | 799 | if ($this->recordNumber <= dbase_numrecords($dbfFile)) { |
| 800 | - if (! dbase_replace_record($dbfFile, array_values($this->dbfData), $this->recordNumber)) { |
|
| 800 | + if (!dbase_replace_record($dbfFile, array_values($this->dbfData), $this->recordNumber)) { |
|
| 801 | 801 | $this->setError("I wasn't possible to update the information in the DBF file."); |
| 802 | 802 | } |
| 803 | - } elseif (! dbase_add_record($dbfFile, array_values($this->dbfData))) { |
|
| 803 | + } elseif (!dbase_add_record($dbfFile, array_values($this->dbfData))) { |
|
| 804 | 804 | $this->setError("I wasn't possible to add the information to the DBF file."); |
| 805 | 805 | } |
| 806 | 806 | } |