From 2aac4c7e86fed5314e49ad3d0aaf3d01fa82832d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20B=C3=B6sing?= <2189546+boesing@users.noreply.github.com> Date: Tue, 10 Oct 2023 21:59:10 +0200 Subject: [PATCH] qa: normalize psalm config to get rid of warnings when running psalm MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maximilian Bösing <2189546+boesing@users.noreply.github.com> --- psalm-baseline.xml | 53 ++++++++++++++++++++++++++++++++++++--- psalm.xml.dist | 2 +- src/ServiceManager.php | 4 +-- src/Tool/ConfigDumper.php | 2 +- 4 files changed, 54 insertions(+), 7 deletions(-) diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 85229872..bb99df15 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -1,5 +1,5 @@ - + new $requestedName(...$arguments) @@ -24,6 +24,11 @@ new $requestedName(...$parameters) + + + mapLazyService + + self::deDuplicateDetectedCycles($detectedCycles) @@ -38,6 +43,16 @@ new $requestedName() + + + Module + + + + + validate + + $wrappedInstance @@ -50,6 +65,9 @@ services[$service]]]> + + $service + function () use ($name, $options) { @@ -76,7 +94,6 @@ $abstractFactories $abstractFactory - $key aliases]]> factories]]> shared]]> @@ -88,6 +105,13 @@ + + $service + $target + + + DelegatorsConfiguration + @@ -112,7 +136,6 @@ $config[ConfigAbstractFactory::class][$className] - $dependency $key $value @@ -131,6 +154,11 @@ $instance + + + ignoreUnresolvedArguments + + $callback @@ -159,6 +187,14 @@ $instance + + + + + $container + $options + $requestedName + @@ -186,6 +222,9 @@ $initializer($wrappedInstance, $proxy) + + $wrappedInstance + @@ -205,6 +244,14 @@ $inc + + sampleFactory + + + + + ServiceManagerConfiguration + diff --git a/psalm.xml.dist b/psalm.xml.dist index eec24b01..a17d69e3 100644 --- a/psalm.xml.dist +++ b/psalm.xml.dist @@ -6,7 +6,7 @@ xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd" errorBaseline="psalm-baseline.xml" findUnusedPsalmSuppress="true" - findUnusedCode="false" + findUnusedCode="true" findUnusedBaselineEntry="true" > diff --git a/src/ServiceManager.php b/src/ServiceManager.php index 55340db2..26051496 100644 --- a/src/ServiceManager.php +++ b/src/ServiceManager.php @@ -264,7 +264,7 @@ public function build(string $name, ?array $options = null): mixed /** * {@inheritDoc} * - * @param string|class-string $name + * @param string|class-string $id * @return bool */ public function has(string $id): bool @@ -350,7 +350,7 @@ public function configure(array $config): static if (isset($config['abstract_factories'])) { $abstractFactories = $config['abstract_factories']; // $key not needed, but foreach is faster than foreach + array_values. - foreach ($abstractFactories as $key => $abstractFactory) { + foreach ($abstractFactories as $abstractFactory) { $this->resolveAbstractFactoryInstance($abstractFactory); } } diff --git a/src/Tool/ConfigDumper.php b/src/Tool/ConfigDumper.php index d115a0a4..ee4e9359 100644 --- a/src/Tool/ConfigDumper.php +++ b/src/Tool/ConfigDumper.php @@ -131,7 +131,7 @@ public function createFactoryMappingsFromConfig(array $config): array ); } - foreach ($config[ConfigAbstractFactory::class] as $className => $dependency) { + foreach (array_keys($config[ConfigAbstractFactory::class]) as $className) { $config = $this->createFactoryMappings($config, $className); } return $config;