Skip to content

Commit

Permalink
Relax templated parameters for the plugin manager
Browse files Browse the repository at this point in the history
Not all implementations return objects and being too strict here causes problems downstream.

Note psalm errors raised in AbstractPluginManager::setService() have been baselined because otherwise, the whole of ServiceManager will need to be templated too.

Signed-off-by: George Steel <[email protected]>
  • Loading branch information
gsteel committed Jul 7, 2022
1 parent 6f96556 commit fba4ec6
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 18 deletions.
21 changes: 6 additions & 15 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
</LessSpecificReturnStatement>
<MissingClosureReturnType occurrences="1">
<code>function (ReflectionParameter $parameter) use ($container, $requestedName) {</code>
<code>function (ReflectionParameter $parameter) use ($container, $requestedName) {</code>
</MissingClosureReturnType>
<MissingParamType occurrences="1">
<code>$requestedName</code>
Expand All @@ -53,9 +52,15 @@
</UndefinedDocblockClass>
</file>
<file src="src/AbstractPluginManager.php">
<ImplementedParamTypeMismatch occurrences="1">
<code>$service</code>
</ImplementedParamTypeMismatch>
<MissingReturnType occurrences="1">
<code>setService</code>
</MissingReturnType>
<MixedArgumentTypeCoercion occurrences="1">
<code>$service</code>
</MixedArgumentTypeCoercion>
<ParamNameMismatch occurrences="1">
<code>$name</code>
</ParamNameMismatch>
Expand Down Expand Up @@ -110,10 +115,8 @@
<MixedArgument occurrences="5">
<code>$abstractFactory</code>
<code>$config['delegators']</code>
<code>$config['delegators']</code>
<code>$config['initializers']</code>
<code>$config['invokables']</code>
<code>$config['invokables']</code>
<code>$config['lazy_services']</code>
</MixedArgument>
<MixedArgumentTypeCoercion occurrences="2">
Expand Down Expand Up @@ -325,7 +328,6 @@
</MixedArgument>
<MixedAssignment occurrences="1">
<code>$instance</code>
<code>$instance</code>
</MixedAssignment>
<MixedFunctionCall occurrences="1">
<code>$callback()</code>
Expand Down Expand Up @@ -359,22 +361,18 @@
<code>$config['shared']</code>
</InvalidArrayOffset>
<MissingClosureParamType occurrences="10">
<code>$callback</code>
<code>$callback</code>
<code>$className</code>
<code>$container</code>
<code>$container</code>
<code>$container</code>
<code>$container</code>
<code>$container</code>
<code>$instance</code>
<code>$instance</code>
<code>$name</code>
<code>$name</code>
<code>$requestedName</code>
</MissingClosureParamType>
<MissingClosureReturnType occurrences="2">
<code>function ($container, $name, $callback) {</code>
<code>function ($container, $name, $callback) {</code>
<code>function ($container, $requestedName, ?array $options = null) {</code>
</MissingClosureReturnType>
Expand Down Expand Up @@ -411,7 +409,6 @@
<code>$idx1</code>
<code>$idx2</code>
<code>$instance</code>
<code>$instance</code>
<code>$lazyServices</code>
<code>$method</code>
<code>$name</code>
Expand All @@ -423,8 +420,6 @@
<code>$object1</code>
<code>$object1</code>
<code>$object1</code>
<code>$object1</code>
<code>$object2</code>
<code>$object2</code>
<code>$object2</code>
<code>$object2</code>
Expand All @@ -436,7 +431,6 @@
</MixedAssignment>
<MixedFunctionCall occurrences="1">
<code>$callback()</code>
<code>$callback()</code>
</MixedFunctionCall>
<MixedInferredReturnType occurrences="6">
<code>array</code>
Expand All @@ -448,7 +442,6 @@
</MixedInferredReturnType>
<MixedPropertyAssignment occurrences="1">
<code>$instance</code>
<code>$instance</code>
</MixedPropertyAssignment>
<PossiblyUndefinedVariable occurrences="5">
<code>$callSequences</code>
Expand Down Expand Up @@ -536,7 +529,6 @@
<code>$name</code>
<code>$name</code>
<code>$name</code>
<code>$name</code>
</MissingClosureParamType>
<MissingClosureReturnType occurrences="2">
<code>function (</code>
Expand All @@ -554,7 +546,6 @@
<code>$inc</code>
<code>$inc</code>
<code>$instance</code>
<code>$instance</code>
<code>$instance1</code>
<code>$instance1</code>
<code>$instance2</code>
Expand Down
3 changes: 1 addition & 2 deletions src/AbstractPluginManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
* The implementation extends `ServiceManager`, thus providing the same set
* of capabilities as found in that implementation.
*
* @template InstanceType of object
* @template InstanceType
* @implements PluginManagerInterface<InstanceType>
* @psalm-import-type ServiceManagerConfiguration from ServiceManager
* @psalm-suppress PropertyNotSetInConstructor
Expand Down Expand Up @@ -136,7 +136,6 @@ public function configure(array $config)
*
* @param string|class-string<InstanceType> $name
* @param InstanceType $service
* @psalm-suppress MoreSpecificImplementedParamType
*/
public function setService($name, $service)
{
Expand Down
2 changes: 1 addition & 1 deletion src/PluginManagerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*
* A plugin manager is a specialized service locator used to create homogeneous objects
*
* @template InstanceType of object
* @template InstanceType
*/
interface PluginManagerInterface extends ServiceLocatorInterface
{
Expand Down

0 comments on commit fba4ec6

Please sign in to comment.