Skip to content

Commit 35b0d91

Browse files
authored
v5.0 (#28)
* 升级版本依赖 * 修复测试 * test * test * test * PHP >= 7.1 * test * test * test * 修复 * 修复测试 * 修复
1 parent 427d17c commit 35b0d91

39 files changed

+334
-242
lines changed

.github/prepare-test.sh

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,20 @@ __DIR__=$(cd `dirname $0`; pwd)
44

55
cd $__DIR__
66

7-
if [[ `expr $PHP_DOCKER_VERSION \< 7` -eq 0 ]]; then
7+
if [[ `expr $PHP_DOCKER_VERSION \< 7.1` -eq 0 ]]; then
88
export PHP_DOCKER_FILE="php.dockerfile"
99
else
10-
export PHP_DOCKER_FILE="php-5.dockerfile"
10+
export PHP_DOCKER_FILE="php-low.dockerfile"
1111
fi
1212

1313
containerName=$1
1414

1515
docker-compose up -d $containerName \
1616
&& docker exec $containerName php -v \
1717
&& docker exec $containerName php -m \
18-
&& docker exec $containerName composer -V \
18+
&& docker exec $containerName php --ri curl
19+
docker exec $containerName php --ri swoole
20+
docker exec $containerName composer -V \
1921
&& docker ps -a
2022

2123
n=0

.github/print-logs.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
$dir = dirname(__DIR__) . '/tests/server/';
4+
5+
foreach ([
6+
$dir . 'Http/log.log',
7+
$dir . 'Http2/log.log',
8+
$dir . 'WebSocket/log.log',
9+
] as $fileName)
10+
{
11+
echo '[',$fileName,']', \PHP_EOL;
12+
if (is_file($fileName))
13+
{
14+
echo file_get_contents($fileName), \PHP_EOL;
15+
}
16+
}

.github/workflows/ci.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
strategy:
1010
fail-fast: false
1111
matrix:
12-
php: [5.5, 5.6, 7.0, 7.1]
12+
php: ["7.1"]
1313

1414
env:
1515
PHP_DOCKER_VERSION: ${{ matrix.php }}
@@ -24,6 +24,10 @@ jobs:
2424
- name: test
2525
run: docker exec php composer test
2626

27+
- name: Print logs
28+
if: failure()
29+
run: php .github/print-logs.php
30+
2731
ci-curl-swoole:
2832
runs-on: ubuntu-20.04
2933

@@ -57,3 +61,7 @@ jobs:
5761
5862
- name: test
5963
run: docker exec swoole composer test
64+
65+
- name: Print logs
66+
if: failure()
67+
run: php .github/print-logs.php

.github/workflows/phpcs.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
strategy:
1010
fail-fast: false
1111
matrix:
12-
swoole: [4.6-php7.4]
12+
swoole: [5.0-php8.2]
1313

1414
env:
1515
SWOOLE_DOCKER_VERSION: ${{ matrix.swoole }}
@@ -20,7 +20,7 @@ jobs:
2020
- name: Prepare
2121
run: |
2222
./.github/prepare-test.sh swoole
23-
docker exec swoole composer require friendsofphp/php-cs-fixer:^2.19 --dev
23+
docker exec swoole composer require php-cs-fixer/shim:~3.35.0 --dev
2424
2525
- name: Test
2626
run: docker exec swoole ./vendor/bin/php-cs-fixer fix --dry-run --diff

.github/workflows/phpstan.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
strategy:
1010
fail-fast: false
1111
matrix:
12-
swoole: [4.6-php7.4]
12+
swoole: [5.0-php8.2]
1313

1414
env:
1515
SWOOLE_DOCKER_VERSION: ${{ matrix.swoole }}
@@ -20,7 +20,7 @@ jobs:
2020
- name: Prepare
2121
run: |
2222
./.github/prepare-test.sh swoole
23-
docker exec swoole composer require phpstan/phpstan:^0.12.91 --dev
23+
docker exec swoole composer require phpstan/phpstan:~1.10.0 --dev
2424
2525
- name: Test
2626
run: docker exec swoole ./vendor/bin/phpstan analyse --memory-limit 1G

.php-cs-fixer.dist.php

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
<?php
2+
3+
if (!file_exists(__DIR__ . '/src'))
4+
{
5+
exit(0);
6+
}
7+
8+
return (new PhpCsFixer\Config())
9+
->setRules([
10+
'@Symfony' => true,
11+
'@Symfony:risky' => true,
12+
'php_unit_dedicate_assert' => ['target' => '5.6'],
13+
'array_syntax' => ['syntax' => 'short'],
14+
'array_indentation' => true,
15+
'binary_operator_spaces' => [
16+
'operators' => [
17+
'=>' => 'align_single_space',
18+
],
19+
],
20+
'concat_space' => [
21+
'spacing' => 'one',
22+
],
23+
'fopen_flags' => false,
24+
'protected_to_private' => false,
25+
'native_constant_invocation' => true,
26+
'single_quote' => true,
27+
'single_space_around_construct' => [
28+
'constructs_followed_by_a_single_space' => [
29+
'abstract',
30+
'as',
31+
'attribute',
32+
'break',
33+
'case',
34+
'catch',
35+
'class',
36+
'clone',
37+
'comment',
38+
'const',
39+
'const_import',
40+
'continue',
41+
'do',
42+
'echo',
43+
'else',
44+
'elseif',
45+
'enum',
46+
'extends',
47+
'final',
48+
'finally',
49+
'for',
50+
'foreach',
51+
'function',
52+
'function_import',
53+
'global',
54+
'goto',
55+
'if',
56+
'implements',
57+
'include',
58+
'include_once',
59+
'instanceof',
60+
'insteadof',
61+
'interface',
62+
'match',
63+
'named_argument',
64+
// 'namespace', // 兼容性移除
65+
'new',
66+
'open_tag_with_echo',
67+
'php_doc',
68+
'php_open',
69+
'print',
70+
'private',
71+
'protected',
72+
'public',
73+
'readonly',
74+
'require',
75+
'require_once',
76+
'return',
77+
'static',
78+
'switch',
79+
'throw',
80+
'trait',
81+
'try',
82+
'type_colon',
83+
'use',
84+
'use_lambda',
85+
'use_trait',
86+
'var',
87+
'while',
88+
'yield',
89+
'yield_from',
90+
],
91+
],
92+
'control_structure_continuation_position' => [
93+
'position' => 'next_line',
94+
],
95+
'curly_braces_position' => [
96+
'control_structures_opening_brace' => 'next_line_unless_newline_at_signature_end',
97+
],
98+
'no_superfluous_phpdoc_tags' => false,
99+
'single_line_comment_style' => false,
100+
'combine_nested_dirname' => false,
101+
'backtick_to_shell_exec' => false,
102+
'visibility_required' => false,
103+
])
104+
->setRiskyAllowed(true)
105+
->setFinder(
106+
PhpCsFixer\Finder::create()
107+
->exclude(__DIR__ . '/vendor')
108+
->in(__DIR__ . '/.github')
109+
->in(__DIR__ . '/src')
110+
->in(__DIR__ . '/examples')
111+
->in(__DIR__ . '/tests')
112+
->append([__FILE__])
113+
)
114+
;

.php_cs.dist

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

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
"name": "yurunsoft/yurun-http",
33
"description": "YurunHttp 是开源的 PHP HTTP 类库,支持链式操作,简单易用。支持 Curl、Swoole,支持 Http、Http2、WebSocket!",
44
"require": {
5-
"php": ">=5.5.0",
6-
"psr/http-message": "~1.0",
5+
"php": ">=7.1",
6+
"psr/http-message": "~1.0|~2.0",
77
"psr/log": "~1.0|~2.0|~3.0"
88
},
99
"require-dev": {

examples/http2Client.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323
{
2424
$response = $client->recv();
2525
var_dump($response->body());
26-
} while ($response->success);
26+
}
27+
while ($response->success);
2728
});
2829

2930
// 客户端请求和响应获取
@@ -52,7 +53,8 @@
5253
{
5354
++$returnCount;
5455
}
55-
} while ($returnCount < $count);
56+
}
57+
while ($returnCount < $count);
5658

5759
$client->close();
5860
});

0 commit comments

Comments
 (0)