Skip to content

Commit

Permalink
fix type error / manifest as array
Browse files Browse the repository at this point in the history
  • Loading branch information
passchn committed Jun 3, 2022
1 parent 9b37941 commit a806152
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/Utilities/ViteManifest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@

/**
* Reads the information in the manifest.json file provided by ViteJs after running 'vite build'
*
* FIXME php-stan error 'Argument of an invalid type stdClass supplied for foreach, only iterables are supported.' as $this->manifest is a stdClass
*/
class ViteManifest
{
Expand All @@ -21,7 +19,7 @@ class ViteManifest
protected string $mainJs;
protected ?string $baseDir;
protected string $manifestDir;
protected \stdClass $manifest;
protected array $manifest;

/**
* @throws \ViteHelper\Errors\ManifestNotFoundException
Expand Down Expand Up @@ -119,10 +117,10 @@ public function getBuildAssetsDir(): string
}

/**
* @return \stdClass
* @return array
* @throws \ViteHelper\Errors\ManifestNotFoundException
*/
protected function getManifest(): \stdClass
protected function getManifest(): array
{
$path = $this->getPath();

Expand All @@ -138,6 +136,11 @@ protected function getManifest(): \stdClass
throw new ManifestNotFoundException("No valid manifest.json found at path $path. Did you build your js? Error: {$e->getMessage()}");
}

return $manifest;
$manifestArray = [];
foreach (get_object_vars($manifest) as $property => $value) {
$manifestArray[$property] = $value;
}

return $manifestArray;
}
}

0 comments on commit a806152

Please sign in to comment.