Skip to content

Commit

Permalink
fix: increase PHP static analysis level (#5)
Browse files Browse the repository at this point in the history
* fix: bump static analysis level

* fix: bump Psalm and include tests

* build: bump devcontainer to PHP8.2

* ci: bump Psalm error level to 5

* !fixup
  • Loading branch information
JoshuaLicense authored Oct 24, 2023
1 parent fd3c443 commit 24040f9
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"image": "mcr.microsoft.com/devcontainers/base:ubuntu-22.04",
"features": {
"ghcr.io/devcontainers/features/php:1": {
"version": "8.0"
"version": "8.2"
}
},
"containerEnv": {
Expand Down
2 changes: 1 addition & 1 deletion phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
parameters:
level: 4
level: 7
paths:
- src
- test
3 changes: 2 additions & 1 deletion psalm.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<psalm
errorLevel="7"
errorLevel="5"
resolveFromConfigFile="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
Expand All @@ -10,6 +10,7 @@
>
<projectFiles>
<directory name="src"/>
<directory name="test"/>
<ignoreFiles>
<directory name="vendor"/>
</ignoreFiles>
Expand Down
4 changes: 3 additions & 1 deletion src/Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function onMergeConfig(ModuleEvent $e): void

$provider = $fqcn::create($config);

$parameters = array_merge($parameters, ...array_map(fn($id) => $provider($id), $ids));
$parameters = array_merge($parameters, ...array_map(fn(string $id) => $provider($id), $ids));
}

$bag = new ParameterBag($parameters);
Expand All @@ -66,6 +66,8 @@ public function onMergeConfig(ModuleEvent $e): void

/**
* @return array<string, mixed>
*
* @psalm-return array{config_parameters: array{providers: array<string, string[]>}}
*/
public function getConfig(): array
{
Expand Down
10 changes: 8 additions & 2 deletions test/Functional/ModuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
use Laminas\ServiceManager\ServiceManager;
use PHPUnit\Framework\TestCase;

/**
* @psalm-api
*/
class ModuleTest extends TestCase
{
public function testProcessParameters(): void
Expand Down Expand Up @@ -60,8 +63,8 @@ public function testProcessParameters(): void

$config = $application->getConfig();

$this->assertEquals('secret', $config['secret']);
$this->assertEquals('parameter', $config['parameter']);
$this->assertEquals('secret', $config['secret'] ?? null);
$this->assertEquals('parameter', $config['parameter'] ?? null);
}

public function testMissingParametersThrowException(): void
Expand Down Expand Up @@ -96,6 +99,9 @@ public function testMissingParametersThrowException(): void
$application->getConfig();
}

/**
* @param array<string, mixed> $moduleConfig
*/
protected function createApplication(array $moduleConfig): Application
{
$configuration = [
Expand Down
3 changes: 3 additions & 0 deletions test/Unit/ParameterProvider/Aws/ParameterStoreTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
use Dvsa\LaminasConfigCloudParameters\ParameterProvider\Aws\ParameterStore;
use PHPUnit\Framework\TestCase;

/**
* @psalm-api
*/
class ParameterStoreTest extends TestCase
{
public function testThrowsLibraryException(): void
Expand Down
3 changes: 3 additions & 0 deletions test/Unit/ParameterProvider/Aws/SecretsManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
use Dvsa\LaminasConfigCloudParameters\ParameterProvider\Aws\SecretsManager;
use PHPUnit\Framework\TestCase;

/**
* @psalm-api
*/
class SecretsManagerTest extends TestCase
{
public function testThrowsLibraryException(): void
Expand Down

0 comments on commit 24040f9

Please sign in to comment.