Skip to content

Commit 9495e94

Browse files
committed
fix phpstan complaints
1 parent 659c58a commit 9495e94

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

lib/PHPExif/Mapper/Exiftool.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,9 @@ public function mapRawData(array $data): array
344344
$rotate = true;
345345
}
346346
}
347+
if (!isset($value_split[0]) || !isset($value_split[1])) {
348+
continue 2;
349+
}
347350
if (!array_key_exists(Exif::WIDTH, $mappedData)) {
348351
if (!($rotate)) {
349352
$mappedData[Exif::WIDTH] = intval($value_split[0]);
@@ -410,7 +413,9 @@ protected function extractGPSCoordinates(mixed $coordinates): float|false
410413
if (preg_match('!^([0-9.]+) deg ([0-9.]+)\' ([0-9.]+)"!', $coordinates, $matches) === 0) {
411414
return false;
412415
}
413-
416+
if (!isset($matches[1]) || !isset($matches[2]) || !isset($matches[3])) {
417+
return false;
418+
}
414419
return round(
415420
floatval($matches[1]) + (floatval($matches[2]) / 60) + (floatval($matches[3]) / 3600),
416421
self::ROUNDING_PRECISION

lib/PHPExif/Mapper/ImageMagick.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -278,9 +278,12 @@ protected function extractGPSCoordinates(string $coordinates): float|false
278278
if (preg_match($m, $coordinates, $matches) === 0) {
279279
return false;
280280
}
281+
if (!isset($matches[1])) {
282+
return false;
283+
}
281284
$degrees = $this->normalizeComponent($matches[1]);
282-
$minutes = $this->normalizeComponent($matches[2] ?? 0);
283-
$seconds = $this->normalizeComponent($matches[3] ?? 0);
285+
$minutes = $this->normalizeComponent($matches[2] ?? '0');
286+
$seconds = $this->normalizeComponent($matches[3] ?? '0');
284287
if ($degrees === false || $minutes === false || $seconds === false) {
285288
return false;
286289
}

0 commit comments

Comments
 (0)