Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion benchmarks/BenchAsset/AbstractFactoryFoo.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

namespace LaminasBench\ServiceManager\BenchAsset;

use Interop\Container\ContainerInterface;
use Laminas\ServiceManager\Factory\AbstractFactoryInterface;
use Psr\Container\ContainerInterface;

class AbstractFactoryFoo implements AbstractFactoryInterface
{
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/BenchAsset/FactoryFoo.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

namespace LaminasBench\ServiceManager\BenchAsset;

use Interop\Container\ContainerInterface;
use Laminas\ServiceManager\Factory\FactoryInterface;
use Psr\Container\ContainerInterface;

class FactoryFoo implements FactoryInterface
{
Expand Down
12 changes: 8 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,21 +51,22 @@
"vimeo/psalm": "^4.8"
},
"provide": {
"container-interop/container-interop-implementation": "^1.2",
Comment thread
boesing marked this conversation as resolved.
"psr/container-implementation": "^1.0"
},
"conflict": {
"container-interop/container-interop": "<1.2.0",
"laminas/laminas-code": "<3.3.1",
"zendframework/zend-code": "<3.3.1",
"zendframework/zend-servicemanager": "*",
"laminas/laminas-code": "<3.3.1"
"zendframework/zend-servicemanager": "*"
},
"suggest": {
"ocramius/proxy-manager": "ProxyManager ^2.1.1 to handle lazy initialization of services"
},
"autoload": {
"psr-4": {
"Laminas\\ServiceManager\\": "src/"
}
},
"files": ["src/autoload.php"]
},
"autoload-dev": {
"files": [
Expand All @@ -91,5 +92,8 @@
"test": "phpunit --colors=always",
"test-coverage": "phpunit --colors=always --coverage-clover clover.xml",
"static-analysis" : "psalm --shepherd --stats"
},
"replace": {
"container-interop/container-interop": "^1.2.0"
}
}
40 changes: 2 additions & 38 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

59 changes: 1 addition & 58 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="4.20.0@f82a70e7edfc6cf2705e9374c8a0b6a974a779ed">
<files psalm-version="4.22.0@fc2c6ab4d5fa5d644d8617089f012f3bb84b8703">
<file src="src/AbstractFactory/ConfigAbstractFactory.php">
<InvalidStringClass occurrences="1">
<code>new $requestedName(...$arguments)</code>
Expand Down Expand Up @@ -53,9 +53,6 @@
</UndefinedDocblockClass>
</file>
<file src="src/AbstractPluginManager.php">
<DocblockTypeContradiction occurrences="1">
<code>gettype($configInstanceOrParentLocator)</code>
</DocblockTypeContradiction>
<MissingReturnType occurrences="1">
<code>setService</code>
</MissingReturnType>
Expand Down Expand Up @@ -304,21 +301,6 @@
<code>assertInstanceOf</code>
<code>assertInstanceOf</code>
</DocblockTypeContradiction>
<MixedArgument occurrences="13">
<code>$this-&gt;container-&gt;reveal()</code>
<code>$this-&gt;container-&gt;reveal()</code>
<code>$this-&gt;container-&gt;reveal()</code>
<code>$this-&gt;container-&gt;reveal()</code>
<code>$this-&gt;container-&gt;reveal()</code>
<code>$this-&gt;container-&gt;reveal()</code>
<code>$this-&gt;container-&gt;reveal()</code>
<code>$this-&gt;container-&gt;reveal()</code>
<code>$this-&gt;container-&gt;reveal()</code>
<code>$this-&gt;container-&gt;reveal()</code>
<code>$this-&gt;container-&gt;reveal()</code>
<code>$this-&gt;container-&gt;reveal()</code>
<code>$this-&gt;container-&gt;reveal()</code>
</MixedArgument>
<MixedInferredReturnType occurrences="1">
<code>array</code>
</MixedInferredReturnType>
Expand All @@ -327,9 +309,6 @@
<DeprecatedMethod occurrences="1">
<code>setServiceLocator</code>
</DeprecatedMethod>
<InternalMethod occurrences="1">
<code>getContainer</code>
</InternalMethod>
<InvalidArgument occurrences="5"/>
<MissingClosureParamType occurrences="4">
<code>$callback</code>
Expand Down Expand Up @@ -549,46 +528,10 @@
<code>$initializer</code>
</MissingClosureParamType>
<MixedFunctionCall occurrences="1"/>
<MixedMethodCall occurrences="3">
<code>method</code>
<code>method</code>
<code>willReturnCallback</code>
</MixedMethodCall>
<PossiblyInvalidArgument occurrences="2">
<code>$container</code>
<code>$container</code>
</PossiblyInvalidArgument>
<UndefinedDocblockClass occurrences="5">
<code>$container</code>
<code>$this-&gt;proxyFactory</code>
<code>$this-&gt;proxyFactory</code>
<code>ContainerInterface|MockObject</code>
<code>LazyLoadingValueHolderFactory|MockObject</code>
</UndefinedDocblockClass>
<UndefinedMethod occurrences="2">
<code>expects</code>
<code>expects</code>
</UndefinedMethod>
<UnusedVariable occurrences="1">
<code>$wrappedInstance</code>
</UnusedVariable>
</file>
<file src="test/PsrContainerDecoratorTest.php">
<InternalClass occurrences="3">
<code>new PsrContainerDecorator($psrContainer)</code>
<code>new PsrContainerDecorator($psrContainer)</code>
<code>new PsrContainerDecorator($psrContainer)</code>
</InternalClass>
<InternalMethod occurrences="7">
<code>get</code>
<code>getContainer</code>
<code>has</code>
<code>has</code>
<code>new PsrContainerDecorator($psrContainer)</code>
<code>new PsrContainerDecorator($psrContainer)</code>
<code>new PsrContainerDecorator($psrContainer)</code>
</InternalMethod>
</file>
<file src="test/ServiceManagerTest.php">
<MissingClosureParamType occurrences="5">
<code>$context</code>
Expand Down
16 changes: 16 additions & 0 deletions psalm.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,22 @@
<directory name="test/**/TestAsset"/>
</ignoreFiles>
</projectFiles>

<issueHandlers>
<InvalidCatch>
<errorLevel type="suppress">
<!-- PSR does not implement Throwable in 1.x version -->
<referencedClass name="Psr\Container\ContainerExceptionInterface"/>
<referencedClass name="Psr\Container\NotFoundExceptionInterface"/>
</errorLevel>
</InvalidCatch>
<InvalidThrow>
<errorLevel type="suppress">
<!-- PSR does not implement Throwable in 1.x version -->
<referencedClass name="Psr\Container\ContainerExceptionInterface"/>
</errorLevel>
</InvalidThrow>
</issueHandlers>

<issueHandlers>
<DeprecatedClass>
Expand Down
2 changes: 1 addition & 1 deletion src/AbstractFactory/ConfigAbstractFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
namespace Laminas\ServiceManager\AbstractFactory;

use ArrayObject;
use Interop\Container\ContainerInterface;
use Laminas\ServiceManager\Exception\ServiceNotCreatedException;
use Laminas\ServiceManager\Factory\AbstractFactoryInterface;
use Psr\Container\ContainerInterface;

use function array_key_exists;
use function array_map;
Expand Down
2 changes: 1 addition & 1 deletion src/AbstractFactory/ReflectionBasedAbstractFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

namespace Laminas\ServiceManager\AbstractFactory;

use Interop\Container\ContainerInterface;
use Laminas\ServiceManager\Exception\ServiceNotFoundException;
use Laminas\ServiceManager\Factory\AbstractFactoryInterface;
use Psr\Container\ContainerInterface;
use ReflectionClass;
use ReflectionNamedType;
use ReflectionParameter;
Expand Down
4 changes: 2 additions & 2 deletions src/AbstractFactoryInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
*
* - rename the method `canCreateServiceWithName()` to `canCreate()`, and:
* - rename the `$serviceLocator` argument to `$container`, and change the
* typehint to `Interop\Container\ContainerInterface`
* typehint to `Psr\Container\ContainerInterface`
* - merge the `$name` and `$requestedName` arguments
* - rename the method `createServiceWithName()` to `__invoke()`, and:
* - rename the `$serviceLocator` argument to `$container`, and change the
* typehint to `Interop\Container\ContainerInterface`
* typehint to `Psr\Container\ContainerInterface`
* - merge the `$name` and `$requestedName` arguments
* - add the optional `array $options = null` argument.
* - create a `canCreateServiceWithName()` method as defined in this interface, and have it
Expand Down
17 changes: 3 additions & 14 deletions src/AbstractPluginManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@

namespace Laminas\ServiceManager;

use Interop\Container\ContainerInterface;
use Laminas\ServiceManager\Exception\ContainerModificationsNotAllowedException;
use Laminas\ServiceManager\Exception\InvalidServiceException;
use Psr\Container\ContainerInterface as PsrContainerInterface;
use Psr\Container\ContainerInterface;

use function class_exists;
use function get_class;
Expand Down Expand Up @@ -58,23 +57,13 @@ abstract class AbstractPluginManager extends ServiceManager implements PluginMan
* factories; for $config, {@see \Laminas\ServiceManager\ServiceManager::configure()}
* for details on its accepted structure.
*
* @param null|ConfigInterface|ContainerInterface|PsrContainerInterface $configInstanceOrParentLocator
* @param null|ConfigInterface|ContainerInterface $configInstanceOrParentLocator
* @param array $config
* @psalm-param ServiceManagerConfiguration $config
*/
public function __construct($configInstanceOrParentLocator = null, array $config = [])
{
if (
$configInstanceOrParentLocator instanceof PsrContainerInterface
&& ! $configInstanceOrParentLocator instanceof ContainerInterface
) {
/**
* {@see \Laminas\ServiceManager\Factory\FactoryInterface} typehints
* against interop container and as such cannot accept non-interop
* psr container. Decorate it as interop.
*/
$configInstanceOrParentLocator = new PsrContainerDecorator($configInstanceOrParentLocator);
}
/** @psalm-suppress DocblockTypeContradiction */
if (
null !== $configInstanceOrParentLocator
Comment thread
boesing marked this conversation as resolved.
&& ! $configInstanceOrParentLocator instanceof ConfigInterface
Expand Down
2 changes: 1 addition & 1 deletion src/ConfigInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace Laminas\ServiceManager;

use ArrayAccess;
use Interop\Container\ContainerInterface;
use Psr\Container\ContainerInterface;

/**
* @see ContainerInterface
Expand Down
2 changes: 1 addition & 1 deletion src/DelegatorFactoryInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*
* - rename the method `createDelegatorWithName()` to `__invoke()`, and:
* - rename the `$serviceLocator` argument to `$container`, and change the
* typehint to `Interop\Container\ContainerInterface`
* typehint to `Psr\Container\ContainerInterface`
* - merge the `$name` and `$requestedName` arguments
* - add the `callable` typehint to the `$callback` argument
* - add the optional `array $options = null` argument as a final argument
Expand Down
4 changes: 2 additions & 2 deletions src/Exception/ExceptionInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

namespace Laminas\ServiceManager\Exception;

use Interop\Container\Exception\ContainerException;
use Psr\Container\ContainerExceptionInterface;

/**
* Base exception for all Laminas\ServiceManager exceptions.
*/
interface ExceptionInterface extends ContainerException
interface ExceptionInterface extends ContainerExceptionInterface
Comment thread
boesing marked this conversation as resolved.
{
}
2 changes: 0 additions & 2 deletions src/Exception/ServiceNotCreatedException.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,13 @@

namespace Laminas\ServiceManager\Exception;

use Interop\Container\Exception\ContainerException;
use RuntimeException as SplRuntimeException;

/**
* This exception is thrown when the service locator do not manage to create
* the service (factory that has an error...)
*/
class ServiceNotCreatedException extends SplRuntimeException implements
ContainerException,
Comment thread
boesing marked this conversation as resolved.
ExceptionInterface
{
}
4 changes: 2 additions & 2 deletions src/Exception/ServiceNotFoundException.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@

namespace Laminas\ServiceManager\Exception;

use Interop\Container\Exception\NotFoundException;
use InvalidArgumentException as SplInvalidArgumentException;
use Psr\Container\NotFoundExceptionInterface;

/**
* This exception is thrown when the service locator do not manage to find a
* valid factory to create a service
*/
class ServiceNotFoundException extends SplInvalidArgumentException implements
ExceptionInterface,
NotFoundException
Comment thread
boesing marked this conversation as resolved.
NotFoundExceptionInterface
{
}
2 changes: 1 addition & 1 deletion src/Factory/AbstractFactoryInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Laminas\ServiceManager\Factory;

use Interop\Container\ContainerInterface;
use Psr\Container\ContainerInterface;

/**
* Interface for an abstract factory.
Expand Down
6 changes: 3 additions & 3 deletions src/Factory/DelegatorFactoryInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

namespace Laminas\ServiceManager\Factory;

use Interop\Container\ContainerInterface;
use Interop\Container\Exception\ContainerException;
use Laminas\ServiceManager\Exception\ServiceNotCreatedException;
use Laminas\ServiceManager\Exception\ServiceNotFoundException;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\ContainerInterface;

/**
* Delegator factory interface.
Expand All @@ -28,7 +28,7 @@ interface DelegatorFactoryInterface
* @return object
* @throws ServiceNotFoundException If unable to resolve the service.
* @throws ServiceNotCreatedException If an exception is raised when creating a service.
* @throws ContainerException If any other error occurs.
* @throws ContainerExceptionInterface If any other error occurs.
*/
public function __invoke(ContainerInterface $container, $name, callable $callback, ?array $options = null);
}
Loading