@@ -13,23 +13,23 @@ |
||
13 | 13 | */ |
14 | 14 | class PHPUnit_Framework_MockObject_Invocation_Object extends PHPUnit_Framework_MockObject_Invocation_Static |
15 | 15 | { |
16 | - /** |
|
17 | - * @var object |
|
18 | - */ |
|
19 | - public $object; |
|
16 | + /** |
|
17 | + * @var object |
|
18 | + */ |
|
19 | + public $object; |
|
20 | 20 | |
21 | - /** |
|
22 | - * @param string $className |
|
23 | - * @param string $methodName |
|
24 | - * @param array $parameters |
|
25 | - * @param string $returnType |
|
26 | - * @param object $object |
|
27 | - * @param bool $cloneObjects |
|
28 | - */ |
|
29 | - public function __construct($className, $methodName, array $parameters, $returnType, $object, $cloneObjects = false) |
|
30 | - { |
|
31 | - parent::__construct($className, $methodName, $parameters, $returnType, $cloneObjects); |
|
21 | + /** |
|
22 | + * @param string $className |
|
23 | + * @param string $methodName |
|
24 | + * @param array $parameters |
|
25 | + * @param string $returnType |
|
26 | + * @param object $object |
|
27 | + * @param bool $cloneObjects |
|
28 | + */ |
|
29 | + public function __construct($className, $methodName, array $parameters, $returnType, $object, $cloneObjects = false) |
|
30 | + { |
|
31 | + parent::__construct($className, $methodName, $parameters, $returnType, $cloneObjects); |
|
32 | 32 | |
33 | - $this->object = $object; |
|
34 | - } |
|
33 | + $this->object = $object; |
|
34 | + } |
|
35 | 35 | } |
@@ -13,24 +13,24 @@ |
||
13 | 13 | */ |
14 | 14 | class PHPUnit_Framework_MockObject_Stub_ReturnArgument extends PHPUnit_Framework_MockObject_Stub_Return |
15 | 15 | { |
16 | - protected $argumentIndex; |
|
16 | + protected $argumentIndex; |
|
17 | 17 | |
18 | - public function __construct($argumentIndex) |
|
19 | - { |
|
20 | - $this->argumentIndex = $argumentIndex; |
|
21 | - } |
|
18 | + public function __construct($argumentIndex) |
|
19 | + { |
|
20 | + $this->argumentIndex = $argumentIndex; |
|
21 | + } |
|
22 | 22 | |
23 | - public function invoke(PHPUnit_Framework_MockObject_Invocation $invocation) |
|
24 | - { |
|
25 | - if (isset($invocation->parameters[$this->argumentIndex])) { |
|
26 | - return $invocation->parameters[$this->argumentIndex]; |
|
27 | - } else { |
|
28 | - return; |
|
29 | - } |
|
30 | - } |
|
23 | + public function invoke(PHPUnit_Framework_MockObject_Invocation $invocation) |
|
24 | + { |
|
25 | + if (isset($invocation->parameters[$this->argumentIndex])) { |
|
26 | + return $invocation->parameters[$this->argumentIndex]; |
|
27 | + } else { |
|
28 | + return; |
|
29 | + } |
|
30 | + } |
|
31 | 31 | |
32 | - public function toString() |
|
33 | - { |
|
34 | - return sprintf('return argument #%d', $this->argumentIndex); |
|
35 | - } |
|
32 | + public function toString() |
|
33 | + { |
|
34 | + return sprintf('return argument #%d', $this->argumentIndex); |
|
35 | + } |
|
36 | 36 | } |
@@ -15,25 +15,25 @@ |
||
15 | 15 | */ |
16 | 16 | class PHPUnit_Framework_MockObject_Stub_Return implements PHPUnit_Framework_MockObject_Stub |
17 | 17 | { |
18 | - protected $value; |
|
18 | + protected $value; |
|
19 | 19 | |
20 | - public function __construct($value) |
|
21 | - { |
|
22 | - $this->value = $value; |
|
23 | - } |
|
20 | + public function __construct($value) |
|
21 | + { |
|
22 | + $this->value = $value; |
|
23 | + } |
|
24 | 24 | |
25 | - public function invoke(PHPUnit_Framework_MockObject_Invocation $invocation) |
|
26 | - { |
|
27 | - return $this->value; |
|
28 | - } |
|
25 | + public function invoke(PHPUnit_Framework_MockObject_Invocation $invocation) |
|
26 | + { |
|
27 | + return $this->value; |
|
28 | + } |
|
29 | 29 | |
30 | - public function toString() |
|
31 | - { |
|
32 | - $exporter = new Exporter; |
|
30 | + public function toString() |
|
31 | + { |
|
32 | + $exporter = new Exporter; |
|
33 | 33 | |
34 | - return sprintf( |
|
35 | - 'return user-specified value %s', |
|
36 | - $exporter->export($this->value) |
|
37 | - ); |
|
38 | - } |
|
34 | + return sprintf( |
|
35 | + 'return user-specified value %s', |
|
36 | + $exporter->export($this->value) |
|
37 | + ); |
|
38 | + } |
|
39 | 39 | } |
@@ -13,11 +13,11 @@ |
||
13 | 13 | */ |
14 | 14 | interface PHPUnit_Framework_MockObject_Stub_MatcherCollection |
15 | 15 | { |
16 | - /** |
|
17 | - * Adds a new matcher to the collection which can be used as an expectation |
|
18 | - * or a stub. |
|
19 | - * |
|
20 | - * @param PHPUnit_Framework_MockObject_Matcher_Invocation $matcher Matcher for invocations to mock objects |
|
21 | - */ |
|
22 | - public function addMatcher(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher); |
|
16 | + /** |
|
17 | + * Adds a new matcher to the collection which can be used as an expectation |
|
18 | + * or a stub. |
|
19 | + * |
|
20 | + * @param PHPUnit_Framework_MockObject_Matcher_Invocation $matcher Matcher for invocations to mock objects |
|
21 | + */ |
|
22 | + public function addMatcher(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher); |
|
23 | 23 | } |
@@ -15,32 +15,32 @@ |
||
15 | 15 | */ |
16 | 16 | class PHPUnit_Framework_MockObject_Stub_Exception implements PHPUnit_Framework_MockObject_Stub |
17 | 17 | { |
18 | - protected $exception; |
|
18 | + protected $exception; |
|
19 | 19 | |
20 | - public function __construct($exception) |
|
21 | - { |
|
22 | - // TODO Replace check with type declaration when support for PHP 5 is dropped |
|
23 | - if (!$exception instanceof Throwable && !$exception instanceof Exception) { |
|
24 | - throw new PHPUnit_Framework_MockObject_RuntimeException( |
|
25 | - 'Exception must be an instance of Throwable (PHP 7) or Exception (PHP 5)' |
|
26 | - ); |
|
27 | - } |
|
20 | + public function __construct($exception) |
|
21 | + { |
|
22 | + // TODO Replace check with type declaration when support for PHP 5 is dropped |
|
23 | + if (!$exception instanceof Throwable && !$exception instanceof Exception) { |
|
24 | + throw new PHPUnit_Framework_MockObject_RuntimeException( |
|
25 | + 'Exception must be an instance of Throwable (PHP 7) or Exception (PHP 5)' |
|
26 | + ); |
|
27 | + } |
|
28 | 28 | |
29 | - $this->exception = $exception; |
|
30 | - } |
|
29 | + $this->exception = $exception; |
|
30 | + } |
|
31 | 31 | |
32 | - public function invoke(PHPUnit_Framework_MockObject_Invocation $invocation) |
|
33 | - { |
|
34 | - throw $this->exception; |
|
35 | - } |
|
32 | + public function invoke(PHPUnit_Framework_MockObject_Invocation $invocation) |
|
33 | + { |
|
34 | + throw $this->exception; |
|
35 | + } |
|
36 | 36 | |
37 | - public function toString() |
|
38 | - { |
|
39 | - $exporter = new Exporter; |
|
37 | + public function toString() |
|
38 | + { |
|
39 | + $exporter = new Exporter; |
|
40 | 40 | |
41 | - return sprintf( |
|
42 | - 'raise user-specified exception %s', |
|
43 | - $exporter->export($this->exception) |
|
44 | - ); |
|
45 | - } |
|
41 | + return sprintf( |
|
42 | + 'raise user-specified exception %s', |
|
43 | + $exporter->export($this->exception) |
|
44 | + ); |
|
45 | + } |
|
46 | 46 | } |
@@ -15,32 +15,32 @@ |
||
15 | 15 | */ |
16 | 16 | class PHPUnit_Framework_MockObject_Stub_ConsecutiveCalls implements PHPUnit_Framework_MockObject_Stub |
17 | 17 | { |
18 | - protected $stack; |
|
19 | - protected $value; |
|
20 | - |
|
21 | - public function __construct($stack) |
|
22 | - { |
|
23 | - $this->stack = $stack; |
|
24 | - } |
|
25 | - |
|
26 | - public function invoke(PHPUnit_Framework_MockObject_Invocation $invocation) |
|
27 | - { |
|
28 | - $this->value = array_shift($this->stack); |
|
29 | - |
|
30 | - if ($this->value instanceof PHPUnit_Framework_MockObject_Stub) { |
|
31 | - $this->value = $this->value->invoke($invocation); |
|
32 | - } |
|
33 | - |
|
34 | - return $this->value; |
|
35 | - } |
|
36 | - |
|
37 | - public function toString() |
|
38 | - { |
|
39 | - $exporter = new Exporter; |
|
40 | - |
|
41 | - return sprintf( |
|
42 | - 'return user-specified value %s', |
|
43 | - $exporter->export($this->value) |
|
44 | - ); |
|
45 | - } |
|
18 | + protected $stack; |
|
19 | + protected $value; |
|
20 | + |
|
21 | + public function __construct($stack) |
|
22 | + { |
|
23 | + $this->stack = $stack; |
|
24 | + } |
|
25 | + |
|
26 | + public function invoke(PHPUnit_Framework_MockObject_Invocation $invocation) |
|
27 | + { |
|
28 | + $this->value = array_shift($this->stack); |
|
29 | + |
|
30 | + if ($this->value instanceof PHPUnit_Framework_MockObject_Stub) { |
|
31 | + $this->value = $this->value->invoke($invocation); |
|
32 | + } |
|
33 | + |
|
34 | + return $this->value; |
|
35 | + } |
|
36 | + |
|
37 | + public function toString() |
|
38 | + { |
|
39 | + $exporter = new Exporter; |
|
40 | + |
|
41 | + return sprintf( |
|
42 | + 'return user-specified value %s', |
|
43 | + $exporter->export($this->value) |
|
44 | + ); |
|
45 | + } |
|
46 | 46 | } |
@@ -13,20 +13,20 @@ |
||
13 | 13 | */ |
14 | 14 | class PHPUnit_Framework_MockObject_Stub_ReturnSelf implements PHPUnit_Framework_MockObject_Stub |
15 | 15 | { |
16 | - public function invoke(PHPUnit_Framework_MockObject_Invocation $invocation) |
|
17 | - { |
|
18 | - if (!$invocation instanceof PHPUnit_Framework_MockObject_Invocation_Object) { |
|
19 | - throw new PHPUnit_Framework_MockObject_RuntimeException( |
|
20 | - 'The current object can only be returned when mocking an ' . |
|
21 | - 'object, not a static class.' |
|
22 | - ); |
|
23 | - } |
|
16 | + public function invoke(PHPUnit_Framework_MockObject_Invocation $invocation) |
|
17 | + { |
|
18 | + if (!$invocation instanceof PHPUnit_Framework_MockObject_Invocation_Object) { |
|
19 | + throw new PHPUnit_Framework_MockObject_RuntimeException( |
|
20 | + 'The current object can only be returned when mocking an ' . |
|
21 | + 'object, not a static class.' |
|
22 | + ); |
|
23 | + } |
|
24 | 24 | |
25 | - return $invocation->object; |
|
26 | - } |
|
25 | + return $invocation->object; |
|
26 | + } |
|
27 | 27 | |
28 | - public function toString() |
|
29 | - { |
|
30 | - return 'return the current object'; |
|
31 | - } |
|
28 | + public function toString() |
|
29 | + { |
|
30 | + return 'return the current object'; |
|
31 | + } |
|
32 | 32 | } |
@@ -13,8 +13,8 @@ |
||
13 | 13 | */ |
14 | 14 | class PHPUnit_Framework_MockObject_Stub_ReturnReference extends PHPUnit_Framework_MockObject_Stub_Return |
15 | 15 | { |
16 | - public function __construct(&$value) |
|
17 | - { |
|
18 | - $this->value = &$value; |
|
19 | - } |
|
16 | + public function __construct(&$value) |
|
17 | + { |
|
18 | + $this->value = &$value; |
|
19 | + } |
|
20 | 20 | } |
@@ -13,33 +13,33 @@ |
||
13 | 13 | */ |
14 | 14 | class PHPUnit_Framework_MockObject_Stub_ReturnValueMap implements PHPUnit_Framework_MockObject_Stub |
15 | 15 | { |
16 | - protected $valueMap; |
|
16 | + protected $valueMap; |
|
17 | 17 | |
18 | - public function __construct(array $valueMap) |
|
19 | - { |
|
20 | - $this->valueMap = $valueMap; |
|
21 | - } |
|
18 | + public function __construct(array $valueMap) |
|
19 | + { |
|
20 | + $this->valueMap = $valueMap; |
|
21 | + } |
|
22 | 22 | |
23 | - public function invoke(PHPUnit_Framework_MockObject_Invocation $invocation) |
|
24 | - { |
|
25 | - $parameterCount = count($invocation->parameters); |
|
23 | + public function invoke(PHPUnit_Framework_MockObject_Invocation $invocation) |
|
24 | + { |
|
25 | + $parameterCount = count($invocation->parameters); |
|
26 | 26 | |
27 | - foreach ($this->valueMap as $map) { |
|
28 | - if (!is_array($map) || $parameterCount != count($map) - 1) { |
|
29 | - continue; |
|
30 | - } |
|
27 | + foreach ($this->valueMap as $map) { |
|
28 | + if (!is_array($map) || $parameterCount != count($map) - 1) { |
|
29 | + continue; |
|
30 | + } |
|
31 | 31 | |
32 | - $return = array_pop($map); |
|
33 | - if ($invocation->parameters === $map) { |
|
34 | - return $return; |
|
35 | - } |
|
36 | - } |
|
32 | + $return = array_pop($map); |
|
33 | + if ($invocation->parameters === $map) { |
|
34 | + return $return; |
|
35 | + } |
|
36 | + } |
|
37 | 37 | |
38 | - return; |
|
39 | - } |
|
38 | + return; |
|
39 | + } |
|
40 | 40 | |
41 | - public function toString() |
|
42 | - { |
|
43 | - return 'return value from a map'; |
|
44 | - } |
|
41 | + public function toString() |
|
42 | + { |
|
43 | + return 'return value from a map'; |
|
44 | + } |
|
45 | 45 | } |