Skip to content

Commit 5f95563

Browse files
authored
Merge pull request #29 from Codeception/regenerate-docs
Regenerated docs from comments
2 parents f29bd06 + 149c385 commit 5f95563

File tree

2 files changed

+40
-30
lines changed

2 files changed

+40
-30
lines changed

docs/Stub.md

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,12 @@ Stub::make('User', [
4242
], $this);
4343
```
4444

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
4647
* `param array` $params - properties and methods to set
4748
* `param bool|\PHPUnit\Framework\TestCase` $testCase
4849

49-
* return object - mock
50+
* return \PHPUnit\Framework\MockObject\MockObject&RealInstanceType - mock
5051
* throws \RuntimeException when class does not exist
5152
* throws \Exception
5253

@@ -99,13 +100,13 @@ Stub::makeEmptyExcept('User', 'validate', [
99100
'save' => \Codeception\Stub\Expected::once()
100101
], $this);
101102
```
102-
103-
* `param mixed` $class
103+
* template
104+
* `param class-string<RealInstanceType>|RealInstanceType|callable(): class-string<RealInstanceType>` $class - A class to be mocked
104105
* `param string` $method
105106
* `param array` $params
106107
* `param bool|\PHPUnit\Framework\TestCase` $testCase
107108

108-
* return object
109+
* return \PHPUnit\Framework\MockObject\MockObject&RealInstanceType
109110
* throws \Exception
110111

111112
#### *public static* makeEmpty($class, $params = null, $testCase = null)
@@ -133,7 +134,7 @@ and it's return value or callback function as parameter
133134
``` php
134135
<?php
135136
Stub::makeEmpty('User', ['save' => function () { return true; }]);
136-
Stub::makeEmpty('User', ['save' => true));
137+
Stub::makeEmpty('User', ['save' => true]);
137138
```
138139

139140
**To create a mock, pass current testcase name as last argument:**
@@ -145,11 +146,12 @@ Stub::makeEmpty('User', [
145146
], $this);
146147
```
147148

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
149151
* `param array` $params
150152
* `param bool|\PHPUnit\Framework\TestCase` $testCase
151153

152-
* return object
154+
* return \PHPUnit\Framework\MockObject\MockObject&RealInstanceType
153155
* throws \Exception
154156

155157
#### *public static* copy($obj, $params = null)
@@ -178,7 +180,7 @@ Accepts either name of class or object of that class
178180

179181
``` php
180182
<?php
181-
Stub::construct(new User, ['autosave' => false), ['name' => 'davert']);
183+
Stub::construct(new User, ['autosave' => false], ['name' => 'davert']);
182184
?>
183185
```
184186

@@ -201,12 +203,13 @@ Stub::construct('User', [], [
201203
], $this);
202204
```
203205

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
205208
* `param array` $constructorParams
206209
* `param array` $params
207210
* `param bool|\PHPUnit\Framework\TestCase` $testCase
208211

209-
* return object
212+
* return \PHPUnit\Framework\MockObject\MockObject&RealInstanceType
210213
* throws \Exception
211214

212215
#### *public static* constructEmpty($class, $constructorParams = null, $params = null, $testCase = null)
@@ -218,7 +221,7 @@ Even protected and private properties can be set.
218221
``` php
219222
<?php
220223
Stub::constructEmpty('User', ['autosave' => false]);
221-
Stub::constructEmpty('User', ['autosave' => false), ['name' => 'davert']);
224+
Stub::constructEmpty('User', ['autosave' => false], ['name' => 'davert']);
222225
```
223226

224227
Accepts either name of class or object of that class
@@ -246,12 +249,13 @@ Stub::constructEmpty('User', [], [
246249
], $this);
247250
```
248251

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
250254
* `param array` $constructorParams
251255
* `param array` $params
252256
* `param bool|\PHPUnit\Framework\TestCase` $testCase
253257

254-
* return object
258+
* return \PHPUnit\Framework\MockObject\MockObject&RealInstanceType
255259

256260
#### *public static* constructEmptyExcept($class, $method, $constructorParams = null, $params = null, $testCase = null)
257261
Instantiates a class instance by running constructor with all methods replaced with dummies, except one.
@@ -293,13 +297,14 @@ Stub::constructEmptyExcept('User', 'save', [], [
293297
], $this);
294298
```
295299

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
297302
* `param string` $method
298303
* `param array` $constructorParams
299304
* `param array` $params
300305
* `param bool|\PHPUnit\Framework\TestCase` $testCase
301306

302-
* return object
307+
* return \PHPUnit\Framework\MockObject\MockObject&RealInstanceType
303308

304309
#### *public static* update($mock, array $params)
305310
Replaces properties of current stub
@@ -315,7 +320,7 @@ Stubbing a method call to return a list of values in the specified order.
315320

316321
``` php
317322
<?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')]);
319324
$user->getName(); //david
320325
$user->getName(); //emma
321326
$user->getName(); //sam

docs/StubTrait.md

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,11 @@ and it's return value or callback function as parameter
4747
$this->make('User', ['save' => function () { return true; }]);
4848
$this->make('User', ['save' => true]);
4949
```
50-
51-
* `param mixed` $class - A class to be mocked
50+
* template RealInstanceType of object
51+
* `param class-string<RealInstanceType>|RealInstanceType|callable(): class-string<RealInstanceType>` $class - A class to be mocked
5252
* `param array` $params - properties and methods to set
5353

54-
* return object - mock
54+
* return \PHPUnit\Framework\MockObject\MockObject&RealInstanceType - mock
5555
* throws \RuntimeException when class does not exist
5656
* throws \Exception
5757

@@ -83,11 +83,12 @@ $this->makeEmpty('User', ['save' => function () { return true; }]);
8383
$this->makeEmpty('User', ['save' => true));
8484
```
8585

86-
* `param mixed` $class
86+
* template RealInstanceType of object
87+
* `param class-string<RealInstanceType>|RealInstanceType|callable(): class-string<RealInstanceType>` $class - A class to be mocked
8788
* `param array` $params
8889
* `param bool|\PHPUnit\Framework\TestCase` $testCase
8990

90-
* return object
91+
* return \PHPUnit\Framework\MockObject\MockObject&RealInstanceType
9192
* throws \Exception
9293

9394
#### *public* makeEmptyExcept($class, $method, $params = null)
@@ -120,11 +121,12 @@ $this->makeEmptyExcept('User', 'save', ['isValid' => function () { return true;
120121
$this->makeEmptyExcept('User', 'save', ['isValid' => true]);
121122
```
122123

123-
* `param mixed` $class
124+
* template RealInstanceType of object
125+
* `param class-string<RealInstanceType>|RealInstanceType|callable(): class-string<RealInstanceType>` $class - A class to be mocked
124126
* `param string` $method
125127
* `param array` $params
126128

127-
* return object
129+
* return \PHPUnit\Framework\MockObject\MockObject&RealInstanceType
128130
* throws \Exception
129131

130132
#### *public* construct($class, $constructorParams = null, $params = null)
@@ -158,12 +160,13 @@ $this->construct('User', [], ['save' => true]);
158160
?>
159161
```
160162

161-
* `param mixed` $class
163+
* template RealInstanceType of object
164+
* `param class-string<RealInstanceType>|RealInstanceType|callable(): class-string<RealInstanceType>` $class - A class to be mocked
162165
* `param array` $constructorParams
163166
* `param array` $params
164167
* `param bool|\PHPUnit\Framework\TestCase` $testCase
165168

166-
* return object
169+
* return \PHPUnit\Framework\MockObject\MockObject&RealInstanceType
167170
* throws \Exception
168171

169172
#### *public* constructEmpty($class, $constructorParams = null, $params = null)
@@ -203,11 +206,12 @@ $this->constructEmpty('User', [], [
203206
]);
204207
```
205208

206-
* `param mixed` $class
209+
* template RealInstanceType of object
210+
* `param class-string<RealInstanceType>|RealInstanceType|callable(): class-string<RealInstanceType>` $class - A class to be mocked
207211
* `param array` $constructorParams
208212
* `param array` $params
209213

210-
* return object
214+
* return \PHPUnit\Framework\MockObject\MockObject&RealInstanceType
211215

212216
#### *public* constructEmptyExcept($class, $method, $constructorParams = null, $params = null)
213217
Instantiates a class instance by running constructor with all methods replaced with dummies, except one.
@@ -240,11 +244,12 @@ $this->constructEmptyExcept('User', 'save', [], ['save' => true]);
240244
?>
241245
```
242246

243-
* `param mixed` $class
247+
* template RealInstanceType of object
248+
* `param class-string<RealInstanceType>|RealInstanceType|callable(): class-string<RealInstanceType>` $class - A class to be mocked
244249
* `param string` $method
245250
* `param array` $constructorParams
246251
* `param array` $params
247252

248-
* return object
253+
* return \PHPUnit\Framework\MockObject\MockObject&RealInstanceType
249254

250255

0 commit comments

Comments
 (0)