Skip to content

Commit 1eb9b3b

Browse files
authored
Update codebase to PHP 7.4 (#14)
1 parent 4b9d3ab commit 1eb9b3b

File tree

4 files changed

+15
-28
lines changed

4 files changed

+15
-28
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88

99
strategy:
1010
matrix:
11-
php: [7.1, 7.2, 7.3, 7.4, 8.0]
11+
php: [7.4, 8.0, 8.1]
1212

1313
steps:
1414
- name: Checkout code

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
],
1313
"minimum-stability": "RC",
1414
"require": {
15-
"php": "^7.1 || ^8.0",
15+
"php": "^7.4 || ^8.0",
1616
"codeception/codeception": "^4.0",
1717
"league/factory-muffin": "^3.0",
1818
"league/factory-muffin-faker": "^2.1"

readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ A data factory module for Codeception.
99

1010
## Requirements
1111

12-
* `PHP 7.1` or higher.
12+
* `PHP 7.4` or higher.
1313

1414
## Installation
1515

src/Codeception/Module/DataFactory.php

Lines changed: 12 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -158,10 +158,7 @@
158158
*/
159159
class DataFactory extends \Codeception\Module implements DependsOnModule, RequiresPackage
160160
{
161-
/**
162-
* @var string
163-
*/
164-
protected $dependencyMessage = <<<EOF
161+
protected string $dependencyMessage = <<<EOF
165162
ORM module (like Doctrine2) or Framework module with ActiveRecord support is required:
166163
--
167164
modules:
@@ -173,15 +170,10 @@ class DataFactory extends \Codeception\Module implements DependsOnModule, Requir
173170

174171
/**
175172
* ORM module on which we we depend on.
176-
*
177-
* @var ORM
178173
*/
179-
public $ormModule;
174+
public ?ORM $ormModule = null;
180175

181-
/**
182-
* @var FactoryMuffin
183-
*/
184-
public $factoryMuffin;
176+
public ?FactoryMuffin $factoryMuffin = null;
185177

186178
/**
187179
* @var array
@@ -191,7 +183,7 @@ class DataFactory extends \Codeception\Module implements DependsOnModule, Requir
191183
public function _requires()
192184
{
193185
return [
194-
\League\FactoryMuffin\FactoryMuffin::class => '"league/factory-muffin": "^3.0"',
186+
FactoryMuffin::class => '"league/factory-muffin": "^3.0"',
195187
];
196188
}
197189

@@ -206,15 +198,13 @@ public function _beforeSuite($settings = [])
206198
if ($realpath === false) {
207199
throw new ModuleException($this, 'The path to one of your factories is not correct. Please specify the directory relative to the codeception.yml file (ie. _support/factories).');
208200
}
201+
209202
$this->factoryMuffin->loadFactories($realpath);
210203
}
211204
}
212205
}
213206

214-
/**
215-
* @return StoreInterface|null
216-
*/
217-
protected function getStore()
207+
protected function getStore(): ?StoreInterface
218208
{
219209
if (!empty($this->config['customStore'])) {
220210
$store = new $this->config['customStore'];
@@ -242,18 +232,19 @@ public function _after(TestInterface $test)
242232
if ($skipCleanup) {
243233
return;
244234
}
235+
245236
if ($cleanupOrmModule_Config) {
246237
return;
247238
}
239+
248240
$this->factoryMuffin->deleteSaved();
249241
}
250242

251243
public function _depends()
252244
{
253-
return [\Codeception\Lib\Interfaces\ORM::class => $this->dependencyMessage];
245+
return [ORM::class => $this->dependencyMessage];
254246
}
255247

256-
257248
/**
258249
* @throws ModuleException
259250
*/
@@ -263,6 +254,7 @@ public function onReconfigure($settings = [])
263254
if (!$skipCleanup && !$this->ormModule->_getConfig('cleanup')) {
264255
$this->factoryMuffin->deleteSaved();
265256
}
257+
266258
$this->_beforeSuite($settings);
267259
}
268260

@@ -274,7 +266,6 @@ public function onReconfigure($settings = [])
274266
* 'name' => $faker->name,
275267
* 'email' => $faker->email
276268
* ]);
277-
*
278269
* ```
279270
*
280271
* @throws \League\FactoryMuffin\Exceptions\DefinitionAlreadyDefinedException
@@ -293,10 +284,8 @@ public function _define(string $model, array $fields): Definition
293284
* ```
294285
*
295286
* Returns an instance of created user.
296-
*
297-
* @return object
298287
*/
299-
public function have(string $name, array $extraAttrs = [])
288+
public function have(string $name, array $extraAttrs = []): object
300289
{
301290
return $this->factoryMuffin->create($name, $extraAttrs);
302291
}
@@ -312,10 +301,8 @@ public function have(string $name, array $extraAttrs = [])
312301
* ```
313302
*
314303
* Returns an instance of created user without creating a record in database.
315-
*
316-
* @return object
317304
*/
318-
public function make(string $name, array $extraAttrs = [])
305+
public function make(string $name, array $extraAttrs = []): object
319306
{
320307
return $this->factoryMuffin->instance($name, $extraAttrs);
321308
}

0 commit comments

Comments
 (0)