@@ -42,11 +42,12 @@ Stub::make('User', [
42
42
], $this);
43
43
```
44
44
45
- * ` param mixed ` $class - A class to be mocked
45
+ * template RealInstanceType of object
46
+ * ` param class-string<RealInstanceType>|RealInstanceType|callable(): class-string<RealInstanceType> ` $class - A class to be mocked
46
47
* ` param array ` $params - properties and methods to set
47
48
* ` param bool|\PHPUnit\Framework\TestCase ` $testCase
48
49
49
- * return object - mock
50
+ * return \PHPUnit\Framework\MockObject\MockObject&RealInstanceType - mock
50
51
* throws \RuntimeException when class does not exist
51
52
* throws \Exception
52
53
@@ -99,13 +100,13 @@ Stub::makeEmptyExcept('User', 'validate', [
99
100
'save' => \Codeception\Stub\Expected::once()
100
101
], $this);
101
102
```
102
-
103
- * ` param mixed ` $class
103
+ * template
104
+ * ` param class-string<RealInstanceType>|RealInstanceType|callable(): class-string<RealInstanceType> ` $class - A class to be mocked
104
105
* ` param string ` $method
105
106
* ` param array ` $params
106
107
* ` param bool|\PHPUnit\Framework\TestCase ` $testCase
107
108
108
- * return object
109
+ * return \PHPUnit\Framework\MockObject\MockObject&RealInstanceType
109
110
* throws \Exception
110
111
111
112
#### * public static* makeEmpty($class, $params = null, $testCase = null)
@@ -133,7 +134,7 @@ and it's return value or callback function as parameter
133
134
``` php
134
135
<?php
135
136
Stub::makeEmpty('User', ['save' => function () { return true; }]);
136
- Stub::makeEmpty('User', ['save' => true) );
137
+ Stub::makeEmpty('User', ['save' => true] );
137
138
```
138
139
139
140
** To create a mock, pass current testcase name as last argument:**
@@ -145,11 +146,12 @@ Stub::makeEmpty('User', [
145
146
], $this);
146
147
```
147
148
148
- * ` param mixed ` $class
149
+ * template RealInstanceType of object
150
+ * ` param class-string<RealInstanceType>|RealInstanceType|callable(): class-string<RealInstanceType> ` $class - A class to be mocked
149
151
* ` param array ` $params
150
152
* ` param bool|\PHPUnit\Framework\TestCase ` $testCase
151
153
152
- * return object
154
+ * return \PHPUnit\Framework\MockObject\MockObject&RealInstanceType
153
155
* throws \Exception
154
156
155
157
#### * public static* copy($obj, $params = null)
@@ -178,7 +180,7 @@ Accepts either name of class or object of that class
178
180
179
181
``` php
180
182
<?php
181
- Stub::construct(new User, ['autosave' => false) , ['name' => 'davert']);
183
+ Stub::construct(new User, ['autosave' => false] , ['name' => 'davert']);
182
184
?>
183
185
```
184
186
@@ -201,12 +203,13 @@ Stub::construct('User', [], [
201
203
], $this);
202
204
```
203
205
204
- * ` param mixed ` $class
206
+ * template RealInstanceType of object
207
+ * ` param class-string<RealInstanceType>|RealInstanceType|callable(): class-string<RealInstanceType> ` $class - A class to be mocked
205
208
* ` param array ` $constructorParams
206
209
* ` param array ` $params
207
210
* ` param bool|\PHPUnit\Framework\TestCase ` $testCase
208
211
209
- * return object
212
+ * return \PHPUnit\Framework\MockObject\MockObject&RealInstanceType
210
213
* throws \Exception
211
214
212
215
#### * public static* constructEmpty($class, $constructorParams = null, $params = null, $testCase = null)
@@ -218,7 +221,7 @@ Even protected and private properties can be set.
218
221
``` php
219
222
<?php
220
223
Stub::constructEmpty('User', ['autosave' => false]);
221
- Stub::constructEmpty('User', ['autosave' => false) , ['name' => 'davert']);
224
+ Stub::constructEmpty('User', ['autosave' => false] , ['name' => 'davert']);
222
225
```
223
226
224
227
Accepts either name of class or object of that class
@@ -246,12 +249,13 @@ Stub::constructEmpty('User', [], [
246
249
], $this);
247
250
```
248
251
249
- * ` param mixed ` $class
252
+ * template RealInstanceType of object
253
+ * ` param class-string<RealInstanceType>|RealInstanceType|callable(): class-string<RealInstanceType> ` $class - A class to be mocked
250
254
* ` param array ` $constructorParams
251
255
* ` param array ` $params
252
256
* ` param bool|\PHPUnit\Framework\TestCase ` $testCase
253
257
254
- * return object
258
+ * return \PHPUnit\Framework\MockObject\MockObject&RealInstanceType
255
259
256
260
#### * public static* constructEmptyExcept($class, $method, $constructorParams = null, $params = null, $testCase = null)
257
261
Instantiates a class instance by running constructor with all methods replaced with dummies, except one.
@@ -293,13 +297,14 @@ Stub::constructEmptyExcept('User', 'save', [], [
293
297
], $this);
294
298
```
295
299
296
- * ` param mixed ` $class
300
+ * template RealInstanceType of object
301
+ * ` param class-string<RealInstanceType>|RealInstanceType|callable(): class-string<RealInstanceType> ` $class - A class to be mocked
297
302
* ` param string ` $method
298
303
* ` param array ` $constructorParams
299
304
* ` param array ` $params
300
305
* ` param bool|\PHPUnit\Framework\TestCase ` $testCase
301
306
302
- * return object
307
+ * return \PHPUnit\Framework\MockObject\MockObject&RealInstanceType
303
308
304
309
#### * public static* update($mock, array $params)
305
310
Replaces properties of current stub
@@ -315,7 +320,7 @@ Stubbing a method call to return a list of values in the specified order.
315
320
316
321
``` php
317
322
<?php
318
- $user = Stub::make('User', array( 'getName' => Stub::consecutive('david', 'emma', 'sam', 'amy')) );
323
+ $user = Stub::make('User', [ 'getName' => Stub::consecutive('david', 'emma', 'sam', 'amy')] );
319
324
$user->getName(); //david
320
325
$user->getName(); //emma
321
326
$user->getName(); //sam
0 commit comments