Skip to content

Commit

Permalink
qa: normalize psalm config to get rid of warnings when running psalm
Browse files Browse the repository at this point in the history
Signed-off-by: Maximilian Bösing <2189546+boesing@users.noreply.github.com>
  • Loading branch information
boesing committed Oct 10, 2023
1 parent 604ef5a commit 2aac4c7
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 7 deletions.
53 changes: 50 additions & 3 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="5.10.0@a5effd2d2dddd1a7ea7a0f6a051ce63ff979e356">
<files psalm-version="5.15.0@5c774aca4746caf3d239d9c8cadb9f882ca29352">
<file src="src/AbstractFactory/ConfigAbstractFactory.php">
<InvalidStringClass>
<code>new $requestedName(...$arguments)</code>
Expand All @@ -24,6 +24,11 @@
<code>new $requestedName(...$parameters)</code>
</MixedMethodCall>
</file>
<file src="src/AbstractPluginManager.php">
<PossiblyUnusedMethod>
<code>mapLazyService</code>
</PossiblyUnusedMethod>
</file>
<file src="src/Exception/CyclicAliasException.php">
<InvalidArgument>
<code>self::deDuplicateDetectedCycles($detectedCycles)</code>
Expand All @@ -38,6 +43,16 @@
<code>new $requestedName()</code>
</InvalidStringClass>
</file>
<file src="src/Module.php">
<UnusedClass>
<code>Module</code>
</UnusedClass>
</file>
<file src="src/PluginManagerInterface.php">
<PossiblyUnusedMethod>
<code>validate</code>
</PossiblyUnusedMethod>
</file>
<file src="src/Proxy/LazyServiceFactory.php">
<MissingClosureParamType>
<code>$wrappedInstance</code>
Expand All @@ -50,6 +65,9 @@
<InvalidArrayOffset>
<code><![CDATA[$this->services[$service]]]></code>
</InvalidArrayOffset>
<InvalidCast>
<code>$service</code>
</InvalidCast>
<MissingClosureReturnType>
<code>function () use ($name, $options) {</code>
</MissingClosureReturnType>
Expand All @@ -76,7 +94,6 @@
<code>$abstractFactories</code>
<code>$abstractFactory</code>
<code><![CDATA[$config['aliases']]]></code>
<code>$key</code>
<code><![CDATA[$this->aliases]]></code>
<code><![CDATA[$this->factories]]></code>
<code><![CDATA[$this->shared]]></code>
Expand All @@ -88,6 +105,13 @@
<code><![CDATA[$config['factories']]]></code>
<code><![CDATA[$config['shared']]]></code>
</MixedOperand>
<UnusedForeachValue>
<code>$service</code>
<code>$target</code>
</UnusedForeachValue>
<UnusedReturnValue>
<code>DelegatorsConfiguration</code>
</UnusedReturnValue>
</file>
<file src="src/Test/CommonPluginManagerTrait.php">
<ArgumentTypeCoercion>
Expand All @@ -112,7 +136,6 @@
<code>$config[ConfigAbstractFactory::class][$className]</code>
</MixedArrayAssignment>
<MixedAssignment>
<code>$dependency</code>
<code>$key</code>
<code>$value</code>
</MixedAssignment>
Expand All @@ -131,6 +154,11 @@
<code>$instance</code>
</MixedPropertyAssignment>
</file>
<file src="test/Command/ConfigDumperCommandTest.php">
<PossiblyUnusedMethod>
<code>ignoreUnresolvedArguments</code>
</PossiblyUnusedMethod>
</file>
<file src="test/CommonServiceLocatorBehaviorsTrait.php">
<MissingClosureParamType>
<code>$callback</code>
Expand Down Expand Up @@ -159,6 +187,14 @@
<MixedPropertyAssignment>
<code>$instance</code>
</MixedPropertyAssignment>
<PossiblyUndefinedArrayOffset>
<code><![CDATA[$object['get'][0]]]></code>
</PossiblyUndefinedArrayOffset>
<UnusedClosureParam>
<code>$container</code>
<code>$options</code>
<code>$requestedName</code>
</UnusedClosureParam>
</file>
<file src="test/LazyServiceIntegrationTest.php">
<InvalidReturnStatement>
Expand Down Expand Up @@ -186,6 +222,9 @@
<MixedFunctionCall>
<code>$initializer($wrappedInstance, $proxy)</code>
</MixedFunctionCall>
<UnusedVariable>
<code>$wrappedInstance</code>
</UnusedVariable>
</file>
<file src="test/ServiceManagerTest.php">
<MixedAssignment>
Expand All @@ -205,6 +244,14 @@
<MixedOperand>
<code>$inc</code>
</MixedOperand>
<PossiblyUnusedMethod>
<code>sampleFactory</code>
</PossiblyUnusedMethod>
</file>
<file src="test/StaticAnalysis/ServiceManagerConfiguration.php">
<UnusedClass>
<code>ServiceManagerConfiguration</code>
</UnusedClass>
</file>
<file src="test/Tool/ConfigDumperTest.php">
<MixedAssignment>
Expand Down
2 changes: 1 addition & 1 deletion psalm.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -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"
>
<projectFiles>
Expand Down
4 changes: 2 additions & 2 deletions src/ServiceManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Tool/ConfigDumper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {

Check failure on line 134 in src/Tool/ConfigDumper.php

View workflow job for this annotation

GitHub Actions / ci / QA Checks (PHPCodeSniffer [8.1, locked], ubuntu-latest, laminas/laminas-continuous-integration-ac...

Function array_keys() should not be referenced via a fallback global name, but via a use statement.

Check failure on line 134 in src/Tool/ConfigDumper.php

View workflow job for this annotation

GitHub Actions / ci / QA Checks (PHPCodeSniffer [8.1, locked], ubuntu-latest, laminas/laminas-continuous-integration-ac...

Function array_keys() should not be referenced via a fallback global name, but via a use statement.
$config = $this->createFactoryMappings($config, $className);
}
return $config;
Expand Down

0 comments on commit 2aac4c7

Please sign in to comment.