Skip to content

Commit

Permalink
Configure and run PHPStan in CI (#4)
Browse files Browse the repository at this point in the history
* Configure and run PHPStan in CI
* Document iterable array types
  • Loading branch information
hlubek authored May 7, 2024
1 parent 3767fba commit 4cd0904
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 1 deletion.
28 changes: 28 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,31 @@ jobs:
- name: Run functional tests
run: |
bin/phpunit --colors -c Build/BuildEssentials/PhpUnit/FunctionalTests.xml Packages/Application/${PACKAGE_NAME}/Tests/Functional
- name: Run PHPStan
run: |
composer require --dev networkteam/flow-phpstan
cat <<EOF >> phpstan-baseline.neon
parameters:
ignoreErrors: []
EOF
cat <<EOF >> phpstan.neon
includes:
- phpstan-baseline.neon
- Packages/Libraries/networkteam/flow-phpstan/extension.neon
parameters:
# 0: basic checks
# 1: possibly undefined variable, ...
# 2: unknown methods checked on all expressions
# 3: return types, types assigned to properties
# 4: basic dead code checking
# 5: checking types of arguments passed to methods and functions
# 6: check for missing typehints
# 7: report partially wrong union types
# 8: report calling methods and accessing properties on nullable types
level: 8
reportUnmatchedIgnoredErrors: true
EOF
bin/phpstan analyse Packages/Application/${PACKAGE_NAME}/Classes
17 changes: 16 additions & 1 deletion Classes/AssetIncludesBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class AssetIncludesBuilder
{
/**
* @Flow\InjectConfiguration(path="server")
* @var array
* @var array<mixed>
*/
protected $serverConfiguration;

Expand Down Expand Up @@ -110,6 +110,9 @@ private function getManifestPath(): string
return Files::concatenatePaths([$this->outputPath, $this->manifest]);
}

/**
* @return array<mixed>
*/
private function getManifest(): array
{
$manifestPath = $this->getManifestPath();
Expand All @@ -120,6 +123,12 @@ private function getManifest(): array
return $manifestJson;
}

/**
* @param array<string> $includes
* @param array<mixed> $manifestJson
* @param array<string> $imports
* @return void
*/
private function recurseImportedChunksCSS(array &$includes, array $manifestJson, array $imports): void
{
foreach ($imports as $import) {
Expand All @@ -135,6 +144,12 @@ private function recurseImportedChunksCSS(array &$includes, array $manifestJson,
}
}

/**
* @param array<string> $includes
* @param array<mixed> $manifestJson
* @param array<string> $imports
* @return void
*/
private function recurseImportedChunkFiles(array &$includes, array $manifestJson, array $imports): void
{
foreach ($imports as $import) {
Expand Down

0 comments on commit 4cd0904

Please sign in to comment.