Skip to content

Commit

Permalink
Remove phpstan deprecation
Browse files Browse the repository at this point in the history
  • Loading branch information
DZunke committed May 17, 2024
1 parent 908f549 commit c703cf6
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 13 deletions.
1 change: 0 additions & 1 deletion phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ includes:
- vendor/phpstan/phpstan-deprecation-rules/rules.neon

parameters:
checkMissingIterableValueType: false
level: 8
paths:
- panaly
Expand Down
18 changes: 13 additions & 5 deletions src/Configuration/ConfigurationFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@
use function array_map;
use function array_values;

/**
* @phpstan-type PluginConfig array<class-string, array<string, mixed>|null>
* @phpstan-type StorageConfig array<string, array<string, mixed>|null>
* @phpstan-type ReportingConfig array<string, array<string, mixed>|null>
* @phpstan-type MetricGroupConfig array<string, array<string, mixed>|null>
* @phpstan-type MetricConfig array<string, array<string, mixed>|null>
*/
class ConfigurationFile
{
/**
Expand All @@ -31,6 +38,7 @@ public function __construct(
) {
}

/** @param array{plugins?: PluginConfig, groups?: MetricGroupConfig, storage?: StorageConfig, reporting?: ReportingConfig} $config */
public static function fromArray(array $config): ConfigurationFile
{
return new self(
Expand All @@ -42,7 +50,7 @@ public static function fromArray(array $config): ConfigurationFile
}

/**
* @param array<class-string, array|null> $pluginConfig
* @param PluginConfig $pluginConfig
*
* @return list<Plugin>
*/
Expand All @@ -56,7 +64,7 @@ private static function buildPluginConfig(array $pluginConfig): array
}

/**
* @param array<string, array|null> $reportingConfig
* @param ReportingConfig $reportingConfig
*
* @return list<Reporting>
*/
Expand All @@ -71,7 +79,7 @@ private static function buildReportingConfig(array $reportingConfig): array
}

/**
* @param array<string, array|null> $storageConfig
* @param StorageConfig $storageConfig
*
* @return list<Storage>
*/
Expand All @@ -86,7 +94,7 @@ private static function buildStorageConfig(array $storageConfig): array
}

/**
* @param array<string, array|null> $metricGroupConfig
* @param MetricGroupConfig $metricGroupConfig
*
* @return list<MetricGroup>
*/
Expand All @@ -105,7 +113,7 @@ private static function buildMetricGroupConfig(array $metricGroupConfig): array
}

/**
* @param array<string, array|null> $metricConfig
* @param MetricConfig $metricConfig
*
* @return list<Metric>
*/
Expand Down
1 change: 1 addition & 0 deletions src/Configuration/ConfigurationFile/Metric.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

class Metric
{
/** @param array<string, mixed> $options */
public function __construct(
public readonly string $identifier,
public readonly string $metric,
Expand Down
1 change: 1 addition & 0 deletions src/Configuration/ConfigurationFile/Reporting.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

class Reporting
{
/** @param array<string, mixed> $options */
public function __construct(
public readonly string $identifier,
public readonly array $options,
Expand Down
1 change: 1 addition & 0 deletions src/Configuration/ConfigurationFile/Storage.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

class Storage
{
/** @param array<string, mixed> $options */
public function __construct(
public readonly string $identifier,
public readonly array $options,
Expand Down
1 change: 1 addition & 0 deletions src/Event/BeforeMetricCalculate.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

final class BeforeMetricCalculate
{
/** @param array<string, mixed> $options */
public function __construct(
public readonly Metric $metricConfiguration,
private array $options,
Expand Down
19 changes: 16 additions & 3 deletions src/Plugin/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,31 @@

interface Plugin
{
/** @param array<string, mixed> $options */
public function initialize(
ConfigurationFile $configurationFile,
RuntimeConfiguration $runtimeConfiguration,
array $options,
): void;

/** @return list<Metric> */
/**
* @param array<string, mixed> $options
*
* @return list<Metric>
*/
public function getAvailableMetrics(array $options): array;

/** @return list<Storage> */
/**
* @param array<string, mixed> $options
*
* @return list<Storage>
*/
public function getAvailableStorages(array $options): array;

/** @return list<Reporting> */
/**
* @param array<string, mixed> $options
*
* @return list<Reporting>
*/
public function getAvailableReporting(array $options): array;
}
8 changes: 7 additions & 1 deletion tests/Configuration/PluginLoaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,13 @@ public function testThatThePluginsAreCorrectLoaded(): void
public function testThatOptionsAreHandOverToThePlugin(): void
{
$plugin = new class () extends BasePlugin {
/** @var array<string, array|null> */
/** @var array{
* initialize: array<string, mixed>|null,
* metrics: array<string, mixed>|null,
* storages: array<string, mixed>|null,
* reporting: array<string, mixed>|null
* }
*/
public array $expectedCalls = [
'initialize' => null,
'metrics' => null,
Expand Down
6 changes: 3 additions & 3 deletions tests/Fixtures/Plugin/TestPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

class TestPlugin extends BasePlugin
{
/** @return list<Metric> */
/** @inheritDoc */
public function getAvailableMetrics(array $options): array
{
return [
Expand All @@ -45,7 +45,7 @@ public function calculate(array $options): Value
];
}

/** @return list<Storage> */
/** @inheritDoc */
public function getAvailableStorages(array $options): array
{
return [
Expand Down Expand Up @@ -74,7 +74,7 @@ public function store(Result $result, array $options): void
];
}

/** @return list<Reporting> */
/** @inheritDoc */
public function getAvailableReporting(array $options): array
{
return [
Expand Down

0 comments on commit c703cf6

Please sign in to comment.