Skip to content

Commit e6e2ee6

Browse files
authored
Use Laravel Pint as default code style fixer (#41)
* Use Laravel Pint as default code style fixer
1 parent 6a35e7d commit e6e2ee6

15 files changed

+74
-70
lines changed

.github/workflows/codestyle.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: codestyle
2+
on:
3+
pull_request:
4+
jobs:
5+
code-coverage:
6+
name: Code Coverage
7+
runs-on: ubuntu-latest
8+
strategy:
9+
fail-fast: false
10+
matrix:
11+
php-version:
12+
- 8.2
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v2
16+
17+
- name: Install PHP with extensions
18+
uses: shivammathur/setup-php@v2
19+
with:
20+
php-version: ${{ matrix.php-version }}
21+
coverage: pcov
22+
tools: composer:v2
23+
extensions: swoole, redis
24+
25+
- name: Install dependencies with composer
26+
run: composer update --no-ansi --no-interaction --no-progress
27+
28+
- name: Install Laravel Illuminate Contracts
29+
run: composer require "illuminate/contracts"
30+
31+
- name: Install Laravel pint
32+
run: composer require "laravel/pint"
33+
34+
- name: Code Style
35+
run: vendor/bin/pint --test
36+
37+
- name: Collect code coverage with phpunit
38+
run: vendor/bin/phpunit --coverage-clover=coverage.xml
39+
40+
- name: Send code coverage report to Codecov.io
41+
uses: codecov/codecov-action@v2
42+
with:
43+
token: ${{ secrets.CODECOV_TOKEN }}
44+
files: ./coverage.xml
Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,6 @@
1-
name: php
1+
name: test
22
on:
33
pull_request:
4-
branches:
5-
- master
6-
- dev
7-
push:
8-
branches:
9-
- master
10-
- dev
114
jobs:
125
phptests:
136
runs-on: ${{ matrix.operating-system }}
@@ -30,7 +23,7 @@ jobs:
3023
- name: Install dependencies
3124
uses: nick-invision/retry@v1
3225
with:
33-
timeout_minutes: 5
26+
timeout_minutes: 10
3427
max_attempts: 5
3528
command: composer update --prefer-stable --prefer-dist --no-interaction --no-progress
3629

.scrutinizer.yml

Lines changed: 0 additions & 15 deletions
This file was deleted.

.styleci.yml

Lines changed: 0 additions & 1 deletion
This file was deleted.

.travis.yml

Lines changed: 0 additions & 19 deletions
This file was deleted.

README-zh_CN.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
</p>
55
<p align="center">An ID Generator for PHP based on Snowflake Algorithm (Twitter announced).</p>
66
<p align="center">
7-
<a href="https://github.com/godruoyi/php-snowflake/actions/workflows/php.yml">
8-
<image src="https://github.com/godruoyi/php-snowflake/actions/workflows/php.yml/badge.svg" alt="build passed"></image>
7+
<a href="https://github.com/godruoyi/php-snowflake/actions/workflows/test.yml">
8+
<image src="https://github.com/godruoyi/php-snowflake/actions/workflows/test.yml/badge.svg" alt="build passed"></image>
99
</a>
1010
<a href="https://codecov.io/gh/godruoyi/php-snowflake">
1111
<img src="https://codecov.io/gh/godruoyi/php-snowflake/branch/master/graph/badge.svg?token=7AAOYCJK97"/>

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
</p>
55
<p align="center">An ID Generator for PHP based on Snowflake Algorithm (Twitter announced).</p>
66
<p align="center">
7-
<a href="https://github.com/godruoyi/php-snowflake/actions/workflows/php.yml">
8-
<image src="https://github.com/godruoyi/php-snowflake/actions/workflows/php.yml/badge.svg" alt="build passed"></image>
7+
<a href="https://github.com/godruoyi/php-snowflake/actions/workflows/test.yml">
8+
<image src="https://github.com/godruoyi/php-snowflake/actions/workflows/test.yml/badge.svg" alt="build passed"></image>
99
</a>
1010
<a href="https://codecov.io/gh/godruoyi/php-snowflake">
1111
<img src="https://codecov.io/gh/godruoyi/php-snowflake/branch/master/graph/badge.svg?token=7AAOYCJK97" alt=""/>

pint.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
3+
}

src/SequenceResolver.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ interface SequenceResolver
1515
/**
1616
* The snowflake.
1717
*
18-
* @param int|string $currentTime current request ms
19-
*
18+
* @param int|string $currentTime current request ms
2019
* @return int
2120
*/
2221
public function sequence(int $currentTime);

src/SwooleSequenceResolver.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,19 +54,19 @@ public function __construct()
5454
public function sequence(int $currentTime)
5555
{
5656
// If swoole lock failure,we will return a big number, and recall this method when next millisecond.
57-
if (!$this->lock->trylock()) {
57+
if (! $this->lock->trylock()) {
5858
if ($this->count >= 10) {
5959
throw new \Exception('Swoole lock failure, Unable to get the program lock after many attempts.');
6060
}
6161

62-
++$this->count;
62+
$this->count++;
6363

6464
// return a big number
6565
return 999999;
6666
}
6767

6868
if ($this->lastTimeStamp === $currentTime) {
69-
++$this->sequence;
69+
$this->sequence++;
7070
} else {
7171
$this->sequence = 0;
7272
}
@@ -79,11 +79,11 @@ public function sequence(int $currentTime)
7979
}
8080

8181
/**
82-
* @param \Swoole\Lock $lock
83-
*
82+
* @param \Swoole\Lock $lock
8483
* @return void
8584
*/
86-
public function resetLock(\Swoole\Lock $lock) {
85+
public function resetLock(\Swoole\Lock $lock)
86+
{
8787
$this->lock = $lock;
8888
}
8989
}

0 commit comments

Comments
 (0)