From 56905501b498a0dd21c24c60425814a10ad15286 Mon Sep 17 00:00:00 2001 From: Tavo Nieves J Date: Mon, 10 May 2021 12:12:48 -0500 Subject: [PATCH] Code standards updated to PHP 7.1 --- .github/workflows/main.yml | 4 +-- composer.json | 50 +++++++++++++------------- readme.md | 4 +++ src/Codeception/Module/DataFactory.php | 47 ++++++++++++------------ 4 files changed, 55 insertions(+), 50 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 501f8d1..f653150 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -8,7 +8,7 @@ jobs: strategy: matrix: - php: [5.6, 7.0, 7.1, 7.2, 7.3, 7.4, 8.0] + php: [7.1, 7.2, 7.3, 7.4, 8.0] steps: - name: Checkout code @@ -26,5 +26,5 @@ jobs: - name: Install dependencies run: composer install --prefer-dist --no-progress --no-interaction --no-suggest - - name: Run test suite + - name: Run php lint run: php -l src/Codeception/Module/DataFactory.php diff --git a/composer.json b/composer.json index a2cf3f2..0b5911b 100644 --- a/composer.json +++ b/composer.json @@ -1,26 +1,28 @@ { - "name":"codeception/module-datafactory", - "description":"DataFactory module for Codeception", - "keywords":["codeception"], - "homepage":"http://codeception.com/", - "type":"library", - "license":"MIT", - "authors":[ - { - "name":"Michael Bodnarchuk" - } - ], - "minimum-stability": "RC", - "require": { - "php": ">=5.6.0 <9.0", - "codeception/codeception": "^4.0", - "league/factory-muffin": "^3.0", - "league/factory-muffin-faker": "^2.1" - }, - "autoload":{ - "classmap": ["src/"] - }, - "config": { - "classmap-authoritative": true - } + "name": "codeception/module-datafactory", + "description": "DataFactory module for Codeception", + "keywords": [ "codeception" ], + "homepage": "https://codeception.com/", + "type": "library", + "license": "MIT", + "authors": [ + { + "name": "Michael Bodnarchuk" + } + ], + "minimum-stability": "RC", + "require": { + "php": "^7.1 || ^8.0", + "codeception/codeception": "^4.0", + "league/factory-muffin": "^3.0", + "league/factory-muffin-faker": "^2.1" + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "config": { + "classmap-authoritative": true + } } diff --git a/readme.md b/readme.md index 772ec2a..658d55b 100644 --- a/readme.md +++ b/readme.md @@ -7,6 +7,10 @@ A data factory module for Codeception. [![Total Downloads](https://poser.pugx.org/codeception/module-datafactory/downloads)](https://packagist.org/packages/codeception/module-datafactory) [![License](https://poser.pugx.org/codeception/module-datafactory/license)](/LICENSE) +## Requirements + +* `PHP 7.1` or higher. + ## Installation ``` diff --git a/src/Codeception/Module/DataFactory.php b/src/Codeception/Module/DataFactory.php index 4b8e67a..5316847 100644 --- a/src/Codeception/Module/DataFactory.php +++ b/src/Codeception/Module/DataFactory.php @@ -1,4 +1,7 @@ null, 'customStore' => null]; public function _requires() { return [ - 'League\FactoryMuffin\FactoryMuffin' => '"league/factory-muffin": "^3.0"', + \League\FactoryMuffin\FactoryMuffin::class => '"league/factory-muffin": "^3.0"', ]; } @@ -219,7 +229,7 @@ protected function getStore() : null; } - public function _inject(ORM $orm) + public function _inject(ORM $orm): void { $this->ormModule = $orm; } @@ -227,7 +237,11 @@ public function _inject(ORM $orm) public function _after(TestInterface $test) { $skipCleanup = array_key_exists('cleanup', $this->config) && $this->config['cleanup'] === false; - if ($skipCleanup || $this->ormModule->_getConfig('cleanup')) { + $cleanupOrmModule_Config = $this->ormModule->_getConfig('cleanup'); + if ($skipCleanup) { + return; + } + if ($cleanupOrmModule_Config) { return; } $this->factoryMuffin->deleteSaved(); @@ -235,7 +249,7 @@ public function _after(TestInterface $test) public function _depends() { - return ['Codeception\Lib\Interfaces\ORM' => $this->dependencyMessage]; + return [\Codeception\Lib\Interfaces\ORM::class => $this->dependencyMessage]; } @@ -262,14 +276,9 @@ public function onReconfigure($settings = []) * * ``` * - * @param string $model - * @param array $fields - * - * @return \League\FactoryMuffin\Definition - * * @throws \League\FactoryMuffin\Exceptions\DefinitionAlreadyDefinedException */ - public function _define($model, $fields) + public function _define(string $model, array $fields): Definition { return $this->factoryMuffin->define($model)->setDefinitions($fields); } @@ -284,12 +293,9 @@ public function _define($model, $fields) * * Returns an instance of created user. * - * @param string $name - * @param array $extraAttrs - * * @return object */ - public function have($name, array $extraAttrs = []) + public function have(string $name, array $extraAttrs = []) { return $this->factoryMuffin->create($name, $extraAttrs); } @@ -306,12 +312,9 @@ public function have($name, array $extraAttrs = []) * * Returns an instance of created user without creating a record in database. * - * @param string $name - * @param array $extraAttrs - * * @return object */ - public function make($name, array $extraAttrs = []) + public function make(string $name, array $extraAttrs = []) { return $this->factoryMuffin->instance($name, $extraAttrs); } @@ -324,13 +327,9 @@ public function make($name, array $extraAttrs = []) * $I->haveMultiple('User', 10, ['is_active' => true]); // create 10 active users * ``` * - * @param string $name - * @param int $times - * @param array $extraAttrs - * - * @return \object[] + * @return object[] */ - public function haveMultiple($name, $times, array $extraAttrs = []) + public function haveMultiple(string $name, int $times, array $extraAttrs = []): array { return $this->factoryMuffin->seed($times, $name, $extraAttrs); }