Skip to content

Commit d455ed9

Browse files
author
simialbi
committed
Fixed #21
updated code style introduced ecs
1 parent f8a1f3b commit d455ed9

33 files changed

+606
-577
lines changed

.github/workflows/build.yml

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,41 @@
11
name: build
22

3-
on: [push, pull_request, workflow_dispatch]
3+
on: [ push, pull_request, workflow_dispatch ]
44

55
env:
66
DEFAULT_COMPOSER_FLAGS: "--prefer-dist --no-interaction --no-progress --optimize-autoloader"
77

88
jobs:
99
phpunit:
10-
name: PHP ${{ matrix.php }} on ${{ matrix.os }}
10+
name: PHP ${{ matrix.php }}-${{ matrix.os }}
1111
runs-on: ${{ matrix.os }}
1212
strategy:
1313
fail-fast: false
1414
matrix:
15-
os: [ubuntu-latest]
16-
php: ['7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4']
15+
os: [ ubuntu-latest ]
16+
php: [ "7.3", "7.4", "8.0", "8.1", "8.2", "8.3", "8.4" ]
1717

1818
steps:
19-
- name: Checkout
20-
uses: actions/checkout@v2
21-
- name: Install PHP
22-
uses: shivammathur/setup-php@v2
23-
with:
24-
php-version: ${{ matrix.php }}
25-
extensions: apc, curl, dom, intl, mbstring, mcrypt
26-
ini-values: date.timezone='UTC'
27-
- name: Get composer cache directory
28-
id: composer-cache
29-
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
30-
- name: Cache composer dependencies
31-
uses: actions/cache@v4
32-
with:
33-
path: ${{ steps.composer-cache.outputs.dir }}
34-
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
35-
restore-keys: ${{ runner.os }}-composer-
36-
- name: Install dependencies
37-
run: composer update $DEFAULT_COMPOSER_FLAGS
38-
- name: PHP Unit tests
39-
run: vendor/bin/phpunit --verbose
19+
- name: Checkout
20+
uses: actions/checkout@v4
21+
- name: Install PHP
22+
uses: shivammathur/setup-php@v2
23+
with:
24+
php-version: ${{ matrix.php }}
25+
extensions: apc, curl, dom, intl, mbstring, mcrypt
26+
ini-values: date.timezone='UTC'
27+
- name: Determine composer cache directory
28+
id: composer-cache
29+
run: echo "COMPOSER_CACHE_DIR=$(composer config cache-dir)" >> $GITHUB_ENV
30+
- name: Cache dependencies composer installed with composer
31+
uses: actions/cache@v4
32+
with:
33+
path: ${{ env.COMPOSER_CACHE_DIR }}
34+
key: php${{ matrix.php }}-composer-${{ hashFiles('composer.json') }}
35+
restore-keys: php${{ matrix.php }}-composer-
36+
- name: Update composer
37+
run: composer self-update
38+
- name: Install dependencies with composer
39+
run: composer update $DEFAULT_COMPOSER_FLAGS
40+
- name: Run unit tests
41+
run: vendor/bin/phpunit --verbose --colors=always

.github/workflows/ecs.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: ecs
2+
3+
on: [ push, pull_request, workflow_dispatch ]
4+
5+
env:
6+
DEFAULT_COMPOSER_FLAGS: "--prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi --ignore-platform-req=php"
7+
8+
jobs:
9+
easy-coding-standard:
10+
name: PHP ${{ matrix.php }}-${{ matrix.os }}
11+
runs-on: ${{ matrix.os }}
12+
strategy:
13+
fail-fast: false
14+
matrix:
15+
os: [ ubuntu-latest ]
16+
php: [ "8.0", "8.1", "8.2", "8.3", "8.4" ]
17+
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v4
21+
- name: Install PHP
22+
uses: shivammathur/setup-php@v2
23+
with:
24+
php-version: ${{ matrix.php }}
25+
- name: Determine composer cache directory
26+
id: composer-cache
27+
run: echo "COMPOSER_CACHE_DIR=$(composer config cache-dir)" >> $GITHUB_ENV
28+
- name: Cache dependencies composer installed with composer
29+
uses: actions/cache@v4
30+
with:
31+
path: ${{ env.COMPOSER_CACHE_DIR }}
32+
key: php${{ matrix.php }}-composer-${{ hashFiles('composer.json') }}
33+
restore-keys: php${{ matrix.php }}-composer-
34+
- name: Update composer
35+
run: composer self-update
36+
- name: Install dependencies with composer
37+
run: composer update $DEFAULT_COMPOSER_FLAGS
38+
- name: Run easy-coding-standard
39+
run: vendor/bin/ecs check src tests --ansi

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@
3232
},
3333
"require-dev": {
3434
"yiisoft/yii2-coding-standards": "~2.0",
35-
"phpunit/phpunit": "^9.5.21"
35+
"phpunit/phpunit": "^9.6.22",
36+
"symplify/easy-coding-standard": "^12.1"
3637
},
3738
"autoload": {
3839
"psr-4": {

ecs.php

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use PhpCsFixer\Fixer\ClassNotation\ClassDefinitionFixer;
6+
use PhpCsFixer\Fixer\ClassNotation\OrderedTraitsFixer;
7+
use PhpCsFixer\Fixer\Import\NoUnusedImportsFixer;
8+
use Symplify\EasyCodingStandard\Config\ECSConfig;
9+
10+
return ECSConfig::configure()
11+
->withConfiguredRule(
12+
ClassDefinitionFixer::class,
13+
[
14+
'space_before_parenthesis' => true,
15+
],
16+
)
17+
->withFileExtensions(['php'])
18+
->withPaths(
19+
[
20+
__DIR__ . '/src',
21+
__DIR__ . '/tests',
22+
]
23+
)
24+
->withPhpCsFixerSets(false, false, false, false, false, true)
25+
->withPreparedSets(
26+
true,
27+
false,
28+
false,
29+
false,
30+
true,
31+
true,
32+
true,
33+
false,
34+
true,
35+
false,
36+
false,
37+
true,
38+
true
39+
)
40+
->withRules([NoUnusedImportsFixer::class, OrderedTraitsFixer::class]);

src/ActiveFixture.php

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
<?php
2+
3+
declare(strict_types=1);
24
/**
35
* @package yii2-rest-client
46
* @author Simon Karlen <[email protected]>
@@ -35,8 +37,6 @@ class ActiveFixture extends BaseActiveFixture
3537

3638

3739
/**
38-
* {@inheritDoc}
39-
*
4040
* @throws InvalidConfigException
4141
*/
4242
public function init()
@@ -51,8 +51,6 @@ public function init()
5151
}
5252

5353
/**
54-
* {@inheritDoc}
55-
*
5654
* @throws InvalidConfigException
5755
* @throws \ReflectionException
5856
*/
@@ -65,10 +63,7 @@ public function load()
6563
}
6664

6765
/**
68-
* {@inheritDoc}
69-
*
7066
* @throws InvalidConfigException
71-
* @throws \ReflectionException
7267
*/
7368
protected function getData(): array
7469
{
@@ -85,9 +80,6 @@ protected function getData(): array
8580
return parent::getData();
8681
}
8782

88-
/**
89-
* {@inheritDoc}
90-
*/
9183
public function getModel($name)
9284
{
9385
if (!isset($this->data[$name])) {
@@ -101,14 +93,14 @@ public function getModel($name)
10193
throw new InvalidConfigException('The "modelClass" property must be set.');
10294
}
10395
$row = $this->data[$name];
104-
/* @var $modelClass ActiveRecord */
96+
/** @var ActiveRecord $modelClass */
10597
$modelClass = $this->modelClass;
10698
$keys = [];
10799
foreach ($modelClass::primaryKey() as $key) {
108100
$keys[$key] = $row[$key] ?? null;
109101
}
110102

111-
/* @var $model ActiveRecord */
103+
/** @var ActiveRecord $model */
112104
$model = new $modelClass();
113105
$model->setOldAttributes($row);
114106
$model->setAttributes($row, false);

0 commit comments

Comments
 (0)