Skip to content

Commit 746b10b

Browse files
SenseExceptionDavertMik
authored andcommitted
Add missing type hints and parameter types to FuncProxy (#135)
* Add missing type hints and parameter types to FuncProxy * Adapt test to fit for array type hint
1 parent 895c55f commit 746b10b

File tree

2 files changed

+32
-13
lines changed

2 files changed

+32
-13
lines changed

src/AspectMock/Proxy/FuncProxy.php

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,30 @@
2525
*/
2626
class FuncProxy
2727
{
28+
/**
29+
* @var string
30+
*/
2831
protected $func;
32+
33+
/**
34+
* @var string
35+
*/
2936
protected $ns;
37+
38+
/**
39+
* @var string
40+
*/
3041
protected $fullFuncName;
3142

3243
/**
3344
* @var FuncVerifier
3445
*/
3546
protected $funcVerifier;
3647

48+
/**
49+
* @param string
50+
* @param string
51+
*/
3752
public function __construct($namespace, $func)
3853
{
3954
$this->func = $func;
@@ -43,34 +58,34 @@ public function __construct($namespace, $func)
4358
}
4459

4560
/**
46-
* @param null $params
61+
* @param null|array $params
4762
*/
48-
public function verifyInvoked($params = null)
63+
public function verifyInvoked(array $params = null)
4964
{
5065
$this->funcVerifier->verifyInvoked($this->func, $params);
5166
}
5267

5368
/**
54-
* @param null $params
69+
* @param null|array $params
5570
*/
56-
public function verifyInvokedOnce($params = null)
71+
public function verifyInvokedOnce(array $params = null)
5772
{
5873
$this->funcVerifier->verifyInvokedMultipleTimes($this->func, 1, $params);
5974
}
6075

6176
/**
62-
* @param null $params
77+
* @param null|array $params
6378
*/
64-
public function verifyNeverInvoked($params = null)
79+
public function verifyNeverInvoked(array $params = null)
6580
{
6681
$this->funcVerifier->verifyNeverInvoked($this->func, $params);
6782
}
6883

6984
/**
70-
* @param $times
71-
* @param null $params
85+
* @param int $times
86+
* @param null|array $params
7287
*/
73-
public function verifyInvokedMultipleTimes($times, $params = null)
88+
public function verifyInvokedMultipleTimes($times, array $params = null)
7489
{
7590
$this->funcVerifier->verifyInvokedMultipleTimes($this->func, $times, $params);
7691
}
@@ -84,10 +99,13 @@ public function __invoke()
8499
return call_user_func_array($this->ns .'\\'.$this->func, func_get_args());
85100
}
86101

87-
102+
/**
103+
* @param string
104+
* @return array
105+
*/
88106
public function getCallsForMethod($func)
89107
{
90108
$calls = Registry::getFuncCallsFor($this->ns . '\\' . $func);
91109
return $calls;
92110
}
93-
}
111+
}

tests/unit/FunctionInjectorTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,19 @@
33

44
use AspectMock\Intercept\FunctionInjector;
55
use AspectMock\Test as test;
6-
use Codeception\TestCase;
76

87
class FunctionInjectorTest extends \Codeception\TestCase\Test
98
{
109
/**
1110
* @var FunctionInjector
1211
*/
1312
protected $funcInjector;
13+
1414
/**
1515
* @var FunctionInjector
1616
*/
1717
protected $funcOptionalParameterInjector;
18+
1819
/**
1920
* @var FunctionInjector
2021
*/
@@ -101,7 +102,7 @@ public function testFailedVerification()
101102
{
102103
$func = test::func('demo', 'strlen', function() { return 10; });
103104
expect(strlen('hello'))->equals(10);
104-
$func->verifyNeverInvoked('strlen');
105+
$func->verifyNeverInvoked();
105106
}
106107

107108
public function testReferencedParameter()

0 commit comments

Comments
 (0)