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

Commit 266a09f

Browse files
committed
CS/consistency fixes for InvalidArgumentException
- Adds parameter and return value annotations - Make line lengths similar - Use verbiage consistent with other exceptions - Fixes test exception expectation messages to match
1 parent d464520 commit 266a09f

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

src/Exception/InvalidArgumentException.php

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,30 +8,37 @@
88
namespace Zend\ServiceManager\Exception;
99

1010
use InvalidArgumentException as SplInvalidArgumentException;
11-
use Zend\ServiceManager\Initializer\InitializerInterface;
1211
use Zend\ServiceManager\AbstractFactoryInterface;
12+
use Zend\ServiceManager\Initializer\InitializerInterface;
1313

1414
/**
1515
* @inheritDoc
1616
*/
1717
class InvalidArgumentException extends SplInvalidArgumentException implements ExceptionInterface
1818
{
19+
/**
20+
* @param mixed $initializer
21+
* @return self
22+
*/
1923
public static function fromInvalidInitializer($initializer)
2024
{
2125
return new self(sprintf(
22-
'An invalid initializer was registered. Expected a callable, or an instance of '
23-
. '(or valid class name or function name resolving to) "%s", '
24-
. 'but "%s" was received',
26+
'An invalid initializer was registered. Expected a callable or an'
27+
. ' instance of "%s"; received "%s"',
2528
InitializerInterface::class,
2629
is_object($initializer) ? get_class($initializer) : gettype($initializer)
2730
));
2831
}
2932

33+
/**
34+
* @param mixed $abstractFactory
35+
* @return self
36+
*/
3037
public static function fromInvalidAbstractFactory($abstractFactory)
3138
{
3239
return new self(sprintf(
33-
'An invalid abstract factory was registered. Expected an instance of or a '
34-
. 'valid class name resolving to an implementation of "%s", but "%s" was received.',
40+
'An invalid abstract factory was registered. Expected an instance of or a valid'
41+
. ' class name resolving to an implementation of "%s", but "%s" was received.',
3542
AbstractFactoryInterface::class,
3643
is_object($abstractFactory) ? get_class($abstractFactory) : gettype($abstractFactory)
3744
));

test/CommonServiceLocatorBehaviorsTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,7 @@ public function testCanSpecifyInitializerUsingStringViaConfiguration()
545545
public function invalidInitializers()
546546
{
547547
$factories = $this->invalidFactories();
548-
$factories['non-class-string'] = ['non-callable-string', 'valid class name or function name'];
548+
$factories['non-class-string'] = ['non-callable-string', 'callable or an instance of'];
549549
return $factories;
550550
}
551551

0 commit comments

Comments
 (0)