Skip to content
This repository was archived by the owner on Feb 6, 2020. It is now read-only.

Commit 489f1ec

Browse files
bakura10weierophinney
authored andcommitted
Feedback
1 parent 6ea9695 commit 489f1ec

10 files changed

+21
-21
lines changed

CHANGELOG.md

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,11 @@ All notable changes to this project will be documented in this file, in reverse
1515

1616
```php
1717
$sm = new \Zend\ServiceManager\ServiceManager([
18-
'factories' => [
19-
MyClassA::class => MyFactory::class,
20-
MyClassB::class => MyFactory::class
21-
]
18+
'factories' => [
19+
MyClassA::class => MyFactory::class,
20+
MyClassB::class => MyFactory::class,
21+
'MyClassC' => 'MyFactory' // This is equivalent as using ::class
22+
],
2223
]);
2324

2425
$sm->get(MyClassA::class); // MyFactory will receive MyClassA::class as second parameter
@@ -53,9 +54,12 @@ All notable changes to this project will be documented in this file, in reverse
5354
In version 3, this becomes:
5455

5556
```php
57+
use Zend\ServiceManager\AbstractPluginManager;
58+
use Zend\Validator\ValidatorInterface;
59+
5660
class MyPluginManager extends AbstractPluginManager
5761
{
58-
protected $instanceOf = \Zend\Validator\ValidatorInterface::class;
62+
protected $instanceOf = ValidatorInterface::class;
5963
}
6064
```
6165

@@ -137,7 +141,7 @@ changes, outlined in this section.
137141
- The ServiceManager is now immutable. Once configured, it cannot be altered.
138142
You need to create a new service manager if you need to change the
139143
configuration. This ensures safer and more aggressive caching. A new method,
140-
`withConfig()` allows you to create a new instance that merges the provided
144+
`withConfig()`, allows you to create a new instance that merges the provided
141145
configuration.
142146

143147
- Interfaces for `FactoryInterface`, `DelegatorFactoryInterface` and

src/AbstractPluginManager.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ abstract class AbstractPluginManager extends ServiceManager implements PluginMan
1919
/**
2020
* An object type that the created instance must be instanced of
2121
*
22-
* @var string
22+
* @var null|string
2323
*/
24-
protected $instanceOf = null;
24+
In $instanceOf = null;
2525

2626
/**
2727
* @param ServiceLocatorInterface $parentLocator

src/Exception/ExceptionInterface.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@
1111

1212
use Interop\Container\Exception\ContainerException;
1313

14-
/**
15-
* Base exception
16-
*/
1714
interface ExceptionInterface extends ContainerException
1815
{
1916
}

src/Exception/InvalidArgumentException.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@
1111

1212
use InvalidArgumentException as SplInvalidArgumentException;
1313

14-
/**
15-
* InvalidFactoryException
16-
*/
1714
class InvalidArgumentException extends SplInvalidArgumentException implements ExceptionInterface
1815
{
1916
}

src/Exception/InvalidServiceException.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@
1212
use RuntimeException as SplRuntimeException;
1313

1414
/**
15-
* InvalidServiceException
16-
*
17-
* This exception is triggered by plugin managers when the created object does not match
15+
* This exception is thrown by plugin managers when the created object does not match
1816
* the plugin manager's conditions
1917
*/
2018
class InvalidServiceException extends SplRuntimeException implements ExceptionInterface

src/Exception/ServiceNotCreatedException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
use RuntimeException as SplRuntimeException;
1313

1414
/**
15-
* ServiceNotCreatedException
15+
* This exception is thrown when the service locator do not manage to create the service (factory that has an error...)
1616
*/
1717
class ServiceNotCreatedException extends SplRuntimeException implements ExceptionInterface
1818
{

src/Exception/ServiceNotFoundException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
use InvalidArgumentException as SplInvalidArgumentException;
1414

1515
/**
16-
* ServiceNotFoundException
16+
* This exception is thrown when the service locator do not manage to find a valid factory to create a service
1717
*/
1818
class ServiceNotFoundException extends SplInvalidArgumentException implements ExceptionInterface, NotFoundException
1919
{

src/PluginManagerInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ interface PluginManagerInterface extends ServiceLocatorInterface
2323
*
2424
* @param object $instance
2525
* @return void
26-
* @throws InvalidServiceException
26+
* @throws InvalidServiceException If created instance does not respect the constraint on type imposed by the plugin manager
2727
*/
2828
public function validate($instance);
2929
}

src/ServiceLocatorInterface.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99

1010
namespace Zend\ServiceManager;
1111

12+
use Zend\ServiceManager\Exception;
13+
1214
/**
1315
* Interface for service locator
1416
*/
@@ -20,6 +22,8 @@ interface ServiceLocatorInterface
2022
* @param string $name
2123
* @param array $options
2224
* @return object
25+
* @throws Exception\ServiceNotFoundException If no factory/abstract factory could be found to create the instance
26+
* @throws Exception\ServiceNotCreatedException If factory/delegator fails to create the instance
2327
*/
2428
public function get($name, array $options = []);
2529

test/bootstrap.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,4 @@
3131
*/
3232
if (defined('TESTS_ZEND_OB_ENABLED') && constant('TESTS_ZEND_OB_ENABLED')) {
3333
ob_start();
34-
}
34+
}

0 commit comments

Comments
 (0)