Skip to content

Commit

Permalink
code style
Browse files Browse the repository at this point in the history
  • Loading branch information
passchn committed Sep 20, 2023
1 parent c692190 commit 6d93f76
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 54 deletions.
96 changes: 48 additions & 48 deletions src/Utilities/ViteManifest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,61 +10,61 @@
*/
class ViteManifest
{
/**
* Returns the manifest records as a Collection
*
* @param \ViteHelper\Utilities\ViteHelperConfig $config plugin config instance
* @return \ViteHelper\Utilities\ManifestRecords|\ViteHelper\Utilities\ManifestRecord[]
* @throws \ViteHelper\Exception\ManifestNotFoundException
* @internal
*/
public static function getRecords(ViteHelperConfig $config): ManifestRecords
{
$manifestPath = $config->read('build.manifest', ConfigDefaults::BUILD_MANIFEST);
/**
* Returns the manifest records as a Collection
*
* @param \ViteHelper\Utilities\ViteHelperConfig $config plugin config instance
* @return \ViteHelper\Utilities\ManifestRecords|\ViteHelper\Utilities\ManifestRecord[]
* @throws \ViteHelper\Exception\ManifestNotFoundException
* @internal
*/
public static function getRecords(ViteHelperConfig $config): ManifestRecords
{
$manifestPath = $config->read('build.manifest', ConfigDefaults::BUILD_MANIFEST);

if (!is_readable($manifestPath)) {
throw new ManifestNotFoundException(
"No valid manifest.json found at path {$manifestPath}. Did you build your js?",
);
}
if (!is_readable($manifestPath)) {
throw new ManifestNotFoundException(
"No valid manifest.json found at path {$manifestPath}. Did you build your js?",
);
}

$json = @file_get_contents($manifestPath);
$json = @file_get_contents($manifestPath);

if ($json === false) {
throw new ManifestNotFoundException('Could not parse manifest.json');
}
if ($json === false) {
throw new ManifestNotFoundException('Could not parse manifest.json');
}

$json = str_replace(
[
"\u0000",
],
'',
$json
);
$json = str_replace(
[
"\u0000",
],
'',
$json
);

$manifest = json_decode($json, false, 512, JSON_THROW_ON_ERROR);
$manifest = json_decode($json, false, 512, JSON_THROW_ON_ERROR);

$manifestArray = [];
foreach (get_object_vars($manifest) as $property => $value) {
$manifestArray[$property] = new ManifestRecord($property, $value, $config);
}
$manifestArray = [];
foreach (get_object_vars($manifest) as $property => $value) {
$manifestArray[$property] = new ManifestRecord($property, $value, $config);
}

/**
* Legacy Polyfills must come first.
*/
usort($manifestArray, function ($file) {
/** @var \ViteHelper\Utilities\ManifestRecord $file */
return $file->isPolyfill() ? 0 : 1;
});
/**
* Legacy Polyfills must come first.
*/
usort($manifestArray, function ($file) {
/** @var \ViteHelper\Utilities\ManifestRecord $file */
return $file->isPolyfill() ? 0 : 1;
});

/**
* ES-module scripts must come last.
*/
usort($manifestArray, function ($file) {
/** @var \ViteHelper\Utilities\ManifestRecord $file */
return !$file->isPolyfill() && !$file->isLegacy() ? 1 : 0;
});
/**
* ES-module scripts must come last.
*/
usort($manifestArray, function ($file) {
/** @var \ViteHelper\Utilities\ManifestRecord $file */
return !$file->isPolyfill() && !$file->isLegacy() ? 1 : 0;
});

return new ManifestRecords($manifestArray, $manifestPath);
}
return new ManifestRecords($manifestArray, $manifestPath);
}
}
12 changes: 6 additions & 6 deletions src/View/Helper/ViteScriptsHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -240,12 +240,12 @@ private function getFilesForDevelopment(array $options, ViteHelperConfig $config
);
}

$arrayIsList = static function (mixed $value) : bool {
return is_array($value) && (PHP_VERSION_ID < 80100
? !$value || array_keys($value) === range(0, count($value) - 1)
: array_is_list($value)
);
};
$arrayIsList = static function (mixed $value): bool {
return is_array($value) && (PHP_VERSION_ID < 80100
? !$value || array_keys($value) === range(0, count($value) - 1)
: array_is_list($value)
);
};

if (!$arrayIsList($files)) {
throw new ConfigurationException(sprintf(
Expand Down

0 comments on commit 6d93f76

Please sign in to comment.