Skip to content

Commit 06be16d

Browse files
authored
Validate PSR12 codestyle with PHPCS #69 (#70)
1 parent ad61407 commit 06be16d

24 files changed

+104
-113
lines changed

.github/workflows/main.yml

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,28 @@ name: CI
33
on: [push, pull_request]
44

55
jobs:
6+
phpcs:
7+
name: Code style
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
- name: Checkout
12+
uses: actions/checkout@v4
13+
14+
- name: Install PHP
15+
uses: shivammathur/setup-php@v2
16+
with:
17+
php-version: '8.3'
18+
tools: phpcs
19+
20+
- name: Check production code style
21+
run: composer cs-prod
22+
23+
- name: Check test code style
24+
run: composer cs-tests
25+
626
tests:
27+
name: Unit tests
728
runs-on: ubuntu-latest
829

930
services:
@@ -53,7 +74,7 @@ jobs:
5374
run: /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P 'P@ssw0rd' -Q 'CREATE DATABASE codeception_test'
5475

5576
- name: Checkout code
56-
uses: actions/checkout@v2
77+
uses: actions/checkout@v4
5778

5879
- name: Setup PHP
5980
uses: shivammathur/setup-php@v2

composer.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,26 @@
2121
"ext-pdo": "*",
2222
"codeception/codeception": "*@dev"
2323
},
24+
"require-dev": {
25+
"squizlabs/php_codesniffer": "*"
26+
},
2427
"conflict": {
2528
"codeception/codeception": "<5.0"
2629
},
2730
"autoload":{
2831
"classmap": ["src/"]
2932
},
33+
"autoload-dev": {
34+
"classmap": ["tests/"]
35+
},
36+
"scripts": {
37+
"cs-prod": "phpcs src/",
38+
"cs-tests": "phpcs tests/ --standard=tests/phpcs.xml"
39+
},
40+
"scripts-descriptions": {
41+
"cs-prod": "Check production code style",
42+
"cs-tests": "Check test code style"
43+
},
3044
"config": {
3145
"classmap-authoritative": true,
3246
"sort-packages": true

docker-compose.amd64.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
version: '3.9'
2-
31
services:
42
php:
53
platform: linux/amd64

docker-compose.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
version: "3.9"
2-
31
services:
42
php:
53
container_name: codeception-module-db

phpcs.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0"?>
2+
<ruleset name="Codeception">
3+
<description>Codeception code standard</description>
4+
<rule ref="PSR12">
5+
<exclude name="Generic.Files.LineLength.TooLong"/>
6+
<exclude name="PSR2.Methods.MethodDeclaration.Underscore"/>
7+
</rule>
8+
</ruleset>

src/Codeception/Lib/DbPopulator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ protected function buildCommand(string $command, string $dumpFile = null): strin
7474

7575
foreach ($vars as $key => $value) {
7676
if (!is_array($value)) {
77-
$vars['$'.$key] = $value;
77+
$vars['$' . $key] = $value;
7878
}
7979

8080
unset($vars[$key]);

src/Codeception/Lib/Driver/MySql.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function getPrimaryKey(string $tableName): array
4343
$columns = $stmt->fetchAll(PDO::FETCH_ASSOC);
4444

4545
foreach ($columns as $column) {
46-
$primaryKey []= $column['Column_name'];
46+
$primaryKey[] = $column['Column_name'];
4747
}
4848
$this->primaryKeys[$tableName] = $primaryKey;
4949
}

src/Codeception/Lib/Driver/Oci.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public function getPrimaryKey(string $tableName): array
104104
$columns = $stmt->fetchAll(\PDO::FETCH_ASSOC);
105105

106106
foreach ($columns as $column) {
107-
$primaryKey []= $column['COLUMN_NAME'];
107+
$primaryKey[] = $column['COLUMN_NAME'];
108108
}
109109

110110
$this->primaryKeys[$tableName] = $primaryKey;

src/Codeception/Lib/Driver/PostgreSql.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ public function getPrimaryKey(string $tableName): array
169169
$stmt = $this->executeQuery($query, []);
170170
$columns = $stmt->fetchAll(PDO::FETCH_ASSOC);
171171
foreach ($columns as $column) {
172-
$primaryKey []= $column['attname'];
172+
$primaryKey[] = $column['attname'];
173173
}
174174

175175
$this->primaryKeys[$tableName] = $primaryKey;

src/Codeception/Lib/Driver/SqlSrv.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public function getPrimaryKey(string $tableName): array
7777
$columns = $stmt->fetchAll(PDO::FETCH_ASSOC);
7878

7979
foreach ($columns as $column) {
80-
$primaryKey []= $column['Column_Name'];
80+
$primaryKey[] = $column['Column_Name'];
8181
}
8282

8383
$this->primaryKeys[$tableName] = $primaryKey;

0 commit comments

Comments
 (0)