for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
namespace Hyde\Framework\Services;
use Hyde\Hyde;
use function Hyde\unixsum_file;
use function str_replace;
use function in_array;
use function Hyde\unslash;
use function glob;
/**
* @internal This class may be refactored to better suit its intended purpose.
*
* Helper methods to interact with the virtual filecache that is used to compare
* published Blade views with the original Blade views in the Hyde Framework
* so the user can be warned before overwriting their customizations.
* Since we currently never use this class more than one in the request cycle,
* there is no reason to cache the results of the file index in the instance.
*/
class ViewDiffService
{
/** @return array<string, array{unixsum: string}> */
public static function getViewFileHashIndex(): array
$filecache = [];
foreach (glob(Hyde::vendorPath('resources/views/**/*.blade.php')) as $file) {
$filecache[unslash(str_replace(Hyde::vendorPath(), '', (string) $file))] = [
vendorPath()
Hyde\Hyde
__callStatic
If this is a false-positive, you can also ignore this issue in your code via the ignore-call annotation
ignore-call
$filecache[unslash(str_replace(Hyde::/** @scrutinizer ignore-call */ vendorPath(), '', (string) $file))] = [
'unixsum' => unixsum_file($file),
];
}
return $filecache;
/** @return array<string> */
public static function getChecksums(): array
$checksums = [];
foreach (static::getViewFileHashIndex() as $file) {
$checksums[] = $file['unixsum'];
return $checksums;
public static function checksumMatchesAny(string $checksum): bool
return in_array($checksum, static::getChecksums());