mirror of
https://github.com/Vateron-Media/XC_VM.git
synced 2026-09-14 12:01:31 +02:00
chore(dead-code): comment out unused ImageUtils::resize/generateThumbnail + add index
Both methods have zero call sites anywhere under src/ (grep, excluding vendor). Comment them out rather than delete (kept as a record), and start a dead-code index (DEAD_CODE.md) tracking such symbols per file with the verification command. Also resolves the last PHPStan level-5 error: generateThumbnail contained an unreachable 32x64 branch (type 5 is matched earlier); the whole method is dead regardless, so commenting it out clears the finding. PHPStan is now clean.
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
# Dead code index
|
||||
|
||||
Functions/methods with **no call sites** anywhere under `src/` (verified by grep,
|
||||
excluding `vendor/`). They are **commented out, not deleted** — kept as a record
|
||||
pending a decision to remove for good.
|
||||
|
||||
How each entry was verified:
|
||||
|
||||
```bash
|
||||
grep -rn '<name>' src/ --include='*.php' | grep -v vendor
|
||||
# returns only the definition → 0 call sites
|
||||
```
|
||||
|
||||
When you edit a file listed here, either delete its dead block or re-confirm it
|
||||
is still unused and leave a note.
|
||||
|
||||
| File | Symbol | Refs | Commented out | Notes |
|
||||
|------|--------|------|---------------|-------|
|
||||
| `src/Core/Util/ImageUtils.php` | `resize(string $rURL, int $rMaxW, int $rMaxH)` | 0 | 2026-09-13 | `resize.php?url=` in views is a separate public endpoint, not this method. |
|
||||
| `src/Core/Util/ImageUtils.php` | `generateThumbnail(string $rImage, int $rType)` | 0 | 2026-09-13 | Also had a pre-existing unreachable 32×64 branch (type 5 matched earlier); the whole method is unused regardless. |
|
||||
@@ -35,86 +35,86 @@ class ImageUtils {
|
||||
return $rURL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the URL of a cached resized image, or the validated original.
|
||||
*
|
||||
* @param string $rURL Source image URL.
|
||||
* @param int $rMaxW Max width.
|
||||
* @param int $rMaxH Max height.
|
||||
* @return string Public URL of the resized image, or the validated source.
|
||||
*/
|
||||
public static function resize(string $rURL, int $rMaxW, int $rMaxH) {
|
||||
list($rExtension) = explode('.', strtolower(pathinfo($rURL)['extension']));
|
||||
$rImagePath = IMAGES_PATH . 'admin/' . md5($rURL) . '_' . $rMaxW . '_' . $rMaxH . '.' . $rExtension;
|
||||
// /**
|
||||
// * Return the URL of a cached resized image, or the validated original.
|
||||
// *
|
||||
// * @param string $rURL Source image URL.
|
||||
// * @param int $rMaxW Max width.
|
||||
// * @param int $rMaxH Max height.
|
||||
// * @return string Public URL of the resized image, or the validated source.
|
||||
// */
|
||||
// public static function resize(string $rURL, int $rMaxW, int $rMaxH) {
|
||||
// list($rExtension) = explode('.', strtolower(pathinfo($rURL)['extension']));
|
||||
// $rImagePath = IMAGES_PATH . 'admin/' . md5($rURL) . '_' . $rMaxW . '_' . $rMaxH . '.' . $rExtension;
|
||||
|
||||
if (file_exists($rImagePath)) {
|
||||
$rServerInfo = ServerRepository::getAll()[SERVER_ID];
|
||||
$rDomain = (empty($rServerInfo['domain_name']) ? $rServerInfo['server_ip'] : explode(',', $rServerInfo['domain_name'])[0]);
|
||||
// if (file_exists($rImagePath)) {
|
||||
// $rServerInfo = ServerRepository::getAll()[SERVER_ID];
|
||||
// $rDomain = (empty($rServerInfo['domain_name']) ? $rServerInfo['server_ip'] : explode(',', $rServerInfo['domain_name'])[0]);
|
||||
|
||||
return $rServerInfo['server_protocol'] . '://' . $rDomain . ':' . $rServerInfo['request_port'] . '/images/admin/' . md5($rURL) . '_' . $rMaxW . '_' . $rMaxH . '.' . $rExtension;
|
||||
}
|
||||
// return $rServerInfo['server_protocol'] . '://' . $rDomain . ':' . $rServerInfo['request_port'] . '/images/admin/' . md5($rURL) . '_' . $rMaxW . '_' . $rMaxH . '.' . $rExtension;
|
||||
// }
|
||||
|
||||
return self::validateURL($rURL);
|
||||
}
|
||||
// return self::validateURL($rURL);
|
||||
// }
|
||||
|
||||
/**
|
||||
* Generate and cache a thumbnail sized for the given stream type.
|
||||
*
|
||||
* @param string $rImage Source image path/URL.
|
||||
* @param int $rType Stream type controlling target dimensions.
|
||||
* @return bool True if the thumbnail exists/was created, false otherwise.
|
||||
*/
|
||||
public static function generateThumbnail(string $rImage, int $rType) {
|
||||
if ($rType == 1 || $rType == 5 || $rType == 4) {
|
||||
$rMaxW = 96;
|
||||
$rMaxH = 32;
|
||||
} else {
|
||||
if ($rType == 2) {
|
||||
$rMaxW = 58;
|
||||
$rMaxH = 32;
|
||||
} else {
|
||||
if ($rType == 5) {
|
||||
$rMaxW = 32;
|
||||
$rMaxH = 64;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
list($rExtension) = explode('.', strtolower(pathinfo($rImage)['extension']));
|
||||
if (!in_array($rExtension, ['png', 'jpg', 'jpeg'])) {
|
||||
} else {
|
||||
$rImagePath = IMAGES_PATH . 'admin/' . md5($rImage) . '_' . $rMaxW . '_' . $rMaxH . '.' . $rExtension;
|
||||
if (file_exists($rImagePath)) {
|
||||
} else {
|
||||
if (self::isAbsoluteUrl($rImage)) {
|
||||
$rActURL = $rImage;
|
||||
} else {
|
||||
$rActURL = IMAGES_PATH . basename($rImage);
|
||||
}
|
||||
list($rWidth, $rHeight) = getimagesize($rActURL);
|
||||
$rImageSize = self::getImageSizeKeepAspectRatio($rWidth, $rHeight, $rMaxW, $rMaxH);
|
||||
if (!($rImageSize['width'] && $rImageSize['height'])) {
|
||||
} else {
|
||||
$rImageP = imagecreatetruecolor($rImageSize['width'], $rImageSize['height']);
|
||||
if ($rExtension == 'png') {
|
||||
$rImage = imagecreatefrompng($rActURL);
|
||||
} else {
|
||||
$rImage = imagecreatefromjpeg($rActURL);
|
||||
}
|
||||
imagealphablending($rImageP, false);
|
||||
imagesavealpha($rImageP, true);
|
||||
imagecopyresampled($rImageP, $rImage, 0, 0, 0, 0, $rImageSize['width'], $rImageSize['height'], $rWidth, $rHeight);
|
||||
imagepng($rImageP, $rImagePath);
|
||||
}
|
||||
}
|
||||
if (!file_exists($rImagePath)) {
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
// /**
|
||||
// * Generate and cache a thumbnail sized for the given stream type.
|
||||
// *
|
||||
// * @param string $rImage Source image path/URL.
|
||||
// * @param int $rType Stream type controlling target dimensions.
|
||||
// * @return bool True if the thumbnail exists/was created, false otherwise.
|
||||
// */
|
||||
// public static function generateThumbnail(string $rImage, int $rType) {
|
||||
// if ($rType == 1 || $rType == 5 || $rType == 4) {
|
||||
// $rMaxW = 96;
|
||||
// $rMaxH = 32;
|
||||
// } else {
|
||||
// if ($rType == 2) {
|
||||
// $rMaxW = 58;
|
||||
// $rMaxH = 32;
|
||||
// } else {
|
||||
// if ($rType == 5) {
|
||||
// $rMaxW = 32;
|
||||
// $rMaxH = 64;
|
||||
// } else {
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// list($rExtension) = explode('.', strtolower(pathinfo($rImage)['extension']));
|
||||
// if (!in_array($rExtension, ['png', 'jpg', 'jpeg'])) {
|
||||
// } else {
|
||||
// $rImagePath = IMAGES_PATH . 'admin/' . md5($rImage) . '_' . $rMaxW . '_' . $rMaxH . '.' . $rExtension;
|
||||
// if (file_exists($rImagePath)) {
|
||||
// } else {
|
||||
// if (self::isAbsoluteUrl($rImage)) {
|
||||
// $rActURL = $rImage;
|
||||
// } else {
|
||||
// $rActURL = IMAGES_PATH . basename($rImage);
|
||||
// }
|
||||
// list($rWidth, $rHeight) = getimagesize($rActURL);
|
||||
// $rImageSize = self::getImageSizeKeepAspectRatio($rWidth, $rHeight, $rMaxW, $rMaxH);
|
||||
// if (!($rImageSize['width'] && $rImageSize['height'])) {
|
||||
// } else {
|
||||
// $rImageP = imagecreatetruecolor($rImageSize['width'], $rImageSize['height']);
|
||||
// if ($rExtension == 'png') {
|
||||
// $rImage = imagecreatefrompng($rActURL);
|
||||
// } else {
|
||||
// $rImage = imagecreatefromjpeg($rActURL);
|
||||
// }
|
||||
// imagealphablending($rImageP, false);
|
||||
// imagesavealpha($rImageP, true);
|
||||
// imagecopyresampled($rImageP, $rImage, 0, 0, 0, 0, $rImageSize['width'], $rImageSize['height'], $rWidth, $rHeight);
|
||||
// imagepng($rImageP, $rImagePath);
|
||||
// }
|
||||
// }
|
||||
// if (!file_exists($rImagePath)) {
|
||||
// } else {
|
||||
// return true;
|
||||
// }
|
||||
// }
|
||||
// return false;
|
||||
// }
|
||||
|
||||
/**
|
||||
* Download a remote image into the local image cache.
|
||||
|
||||
Reference in New Issue
Block a user