Skip to content

Commit 74a7504

Browse files
authored
Merge pull request #5 from patchlevel/fix-enums
Upgrade phpcs rules to fix enums
2 parents ff90717 + f1bc7a9 commit 74a7504

File tree

6 files changed

+66
-6
lines changed

6 files changed

+66
-6
lines changed

.github/workflows/test.yaml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# https://help.github.com/en/categories/automating-your-workflow-with-github-actions
2+
3+
name: "Check Coding Standard"
4+
5+
on:
6+
pull_request:
7+
push:
8+
branches:
9+
- "[0-9]+.[0-9]+.x"
10+
- "renovate/*"
11+
12+
jobs:
13+
static-analysis-coding-standard:
14+
name: "Static Analysis by patchlevel/coding-standard"
15+
16+
runs-on: ${{ matrix.operating-system }}
17+
18+
strategy:
19+
matrix:
20+
dependencies:
21+
- "locked"
22+
php-version:
23+
- "8.1"
24+
operating-system:
25+
- "ubuntu-latest"
26+
27+
steps:
28+
- name: "Checkout"
29+
uses: "actions/checkout@v2"
30+
31+
- name: "Install PHP"
32+
uses: "shivammathur/setup-php@v2"
33+
with:
34+
coverage: "pcov"
35+
php-version: "${{ matrix.php-version }}"
36+
ini-values: memory_limit=-1
37+
extensions: pdo_sqlite
38+
39+
- uses: "ramsey/composer-install@v2"
40+
with:
41+
dependency-versions: ${{ matrix.dependencies }}
42+
43+
- name: "Coding Standard"
44+
run: "vendor/bin/phpcs tests/fixed"

composer.json

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,14 @@
2828
],
2929
"require": {
3030
"php": "^7.4 || ^8.0",
31-
"dealerdirect/phpcodesniffer-composer-installer": "^0.7.1",
32-
"slevomat/coding-standard": "^7.0.10",
33-
"squizlabs/php_codesniffer": "^3.6.0"
31+
"dealerdirect/phpcodesniffer-composer-installer": "^0.7.2",
32+
"slevomat/coding-standard": "^8.1.0",
33+
"squizlabs/php_codesniffer": "^3.7.1"
3434
},
3535
"config": {
36-
"sort-packages": true
36+
"sort-packages": true,
37+
"allow-plugins": {
38+
"dealerdirect/phpcodesniffer-composer-installer": true
39+
}
3740
}
3841
}

phpcs.xml.dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@
1414
<arg value="p"/>
1515
<file>src</file>
1616

17-
<rule ref="Patchlevel"/>
17+
<rule ref="PatchlevelCodingStandard"/>
1818
</ruleset>

src/PatchlevelCodingStandard/ruleset.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@
396396
</property>
397397
</properties>
398398
</rule>
399-
<rule ref="SlevomatCodingStandard.TypeHints.PropertyTypeHintSpacing"/>
399+
<rule ref="SlevomatCodingStandard.Classes.PropertyDeclaration"/>
400400
<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHint">
401401
<properties>
402402
<property name="traversableTypeHints" type="array">

tests/fixed/Suit.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Tests\Fixed;
6+
7+
enum Suit: string
8+
{
9+
case Hearts = 'H';
10+
case Diamonds = 'D';
11+
case Clubs = 'C';
12+
case Spades = 'S';
13+
}

0 commit comments

Comments
 (0)