Skip to content

Commit 261a674

Browse files
authored
update travis (#36)
* update travis * Fix minimum allowed guzzle version * Fix travis * Make tests compatible with version 9
1 parent 8f355d9 commit 261a674

File tree

5 files changed

+142
-35
lines changed

5 files changed

+142
-35
lines changed

.travis.yml

+12-5
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
11
language: php
22

3-
php:
4-
- 7.2
5-
- 7.3
6-
- 7.4
3+
matrix:
4+
include:
5+
- php: 7.2
6+
dist: bionic
7+
- php: 7.2
8+
dist: bionic
9+
env: COMPOSER_FLAGS="--prefer-stable --prefer-lowest"
10+
- php: 7.3
11+
dist: bionic
12+
- php: 7.4
13+
dist: bionic
714

815
before_script:
9-
- composer install --prefer-dist --no-interaction
16+
- composer update $COMPOSER_FLAGS --prefer-dist --no-interaction
1017

1118
script:
1219
- php vendor/bin/phpunit --coverage-clover=clover.xml

composer.json

+5-5
Original file line numberDiff line numberDiff line change
@@ -28,22 +28,22 @@
2828
"require": {
2929
"php": ">=7.2",
3030
"ext-json": "*",
31-
"guzzlehttp/guzzle": "6.*",
31+
"guzzlehttp/guzzle": "^6.1",
3232
"psr/log": "^1.1"
3333
},
3434
"require-dev": {
35-
"phpstan/phpstan": "~0.12.30",
35+
"phpstan/phpstan": "~0.12.32",
3636
"phpstan/phpstan-phpunit": "^0.12.11",
3737
"phpstan/phpstan-strict-rules": "^0.12.2",
38-
"phpunit/phpunit": "~8.5.8",
39-
"webthink/codesniffer": "2.*"
38+
"phpunit/phpunit": "^8.5.8 || ^9.2.5",
39+
"squizlabs/php_codesniffer": "^3.5.5"
4040
},
4141
"suggest": {
4242
"monolog/monolog": "A PSR-3 logger to send your logs to files, sockets and various web services"
4343
},
4444
"scripts": {
4545
"test": "php vendor/bin/phpunit",
46-
"phpcs": "php vendor/bin/phpcs ./src ./tests",
46+
"phpcs": "php vendor/bin/phpcs ./src ./tests -n",
4747
"phpcbf": "php vendor/bin/phpcbf ./src ./tests"
4848
},
4949
"extra": {

phpcs.xml.dist

+118-11
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,127 @@
55

66
<config name="ignore_warnings_on_exit" value="1" />
77

8-
<rule ref="./vendor/webthink/codesniffer/src/Webthink/ruleset.xml">
9-
<exclude name="Generic.Files.LineLength.TooLong" />
10-
<exclude name="Generic.Strings.UnnecessaryStringConcat" />
11-
<exclude name="PEAR.Commenting.FunctionComment" />
12-
<exclude name="Webthink.Formatting.UseInAlphabeticalOrder.UseInAlphabeticalOrder" />
8+
<rule ref="PSR12" />
9+
<!-- Force array element indentation with 4 spaces -->
10+
<rule ref="Generic.Arrays.ArrayIndent"/>
11+
<!-- Forbid `array(...)` -->
12+
<rule ref="Generic.Arrays.DisallowLongArraySyntax"/>
13+
<!-- Forbid final methods in final classes -->
14+
<rule ref="Generic.CodeAnalysis.UnnecessaryFinalModifier"/>
15+
<!-- Forbid useless empty method overrides -->
16+
<rule ref="Generic.CodeAnalysis.UselessOverridingMethod"/>
17+
<!-- Forbid Yoda -->
18+
<rule ref="Generic.ControlStructures.DisallowYodaConditions"/>
19+
<!-- Forbid inline HTML in PHP code -->
20+
<rule ref="Generic.Files.InlineHTML"/>
21+
<!-- Forbid PHP 4 constructors -->
22+
<rule ref="Generic.NamingConventions.ConstructorName"/>
23+
<!-- Forbid any content before opening tag -->
24+
<rule ref="Generic.PHP.CharacterBeforePHPOpeningTag"/>
25+
<!-- Forbid deprecated functions -->
26+
<rule ref="Generic.PHP.DeprecatedFunctions"/>
27+
<rule ref="Generic.PHP.ForbiddenFunctions">
28+
<properties>
29+
<property name="forbiddenFunctions" type="array">
30+
<element key="chop" value="rtrim"/>
31+
<element key="close" value="closedir"/>
32+
<element key="compact" value="null"/>
33+
<element key="delete" value="unset"/>
34+
<element key="doubleval" value="floatval"/>
35+
<element key="extract" value="null"/>
36+
<element key="fputs" value="fwrite"/>
37+
<element key="ini_alter" value="ini_set"/>
38+
<element key="is_double" value="is_float"/>
39+
<element key="is_integer" value="is_int"/>
40+
<element key="is_long" value="is_int"/>
41+
<element key="is_null" value="null"/>
42+
<element key="is_real" value="is_float"/>
43+
<element key="is_writeable" value="is_writable"/>
44+
<element key="join" value="implode"/>
45+
<element key="key_exists" value="array_key_exists"/>
46+
<element key="pos" value="current"/>
47+
<element key="settype" value="null"/>
48+
<element key="show_source" value="highlight_file"/>
49+
<element key="sizeof" value="count"/>
50+
<element key="strchr" value="strstr"/>
51+
<element key="user_error" value="trigger_error"/>
52+
</property>
53+
</properties>
54+
</rule>
55+
<!-- Forbid useless inline string concatenation -->
56+
<rule ref="Generic.Strings.UnnecessaryStringConcat">
57+
<!-- But multiline is useful for readability -->
58+
<properties>
59+
<property name="allowMultiline" value="true"/>
60+
</properties>
61+
</rule>
62+
<!-- Forbid backtick operator -->
63+
<rule ref="Generic.PHP.BacktickOperator"/>
64+
<!-- Force PHP 7 param and return types to be lowercased -->
65+
<rule ref="Generic.PHP.LowerCaseType"/>
66+
<!-- Forbid `php_sapi_name()` function -->
67+
<rule ref="Generic.PHP.SAPIUsage"/>
68+
<!-- Forbid comments starting with # -->
69+
<rule ref="PEAR.Commenting.InlineComment"/>
70+
71+
<rule ref="PEAR.WhiteSpace.ObjectOperatorIndent" />
72+
73+
<!-- Forbid global functions -->
74+
<rule ref="Squiz.Functions.GlobalFunction" />
75+
<!-- Force camelCase variables -->
76+
<rule ref="Squiz.NamingConventions.ValidVariableName">
77+
<exclude name="Squiz.NamingConventions.ValidVariableName.PrivateNoUnderscore" />
78+
</rule>
79+
<!-- Forbid `AND` and `OR`, require `&&` and `||` -->
80+
<rule ref="Squiz.Operators.ValidLogicalOperators" />
81+
<!-- Forbid `global` -->
82+
<rule ref="Squiz.PHP.GlobalKeyword" />
83+
<!-- Forbid functions inside functions -->
84+
<rule ref="Squiz.PHP.InnerFunctions" />
85+
<!-- Require PHP function calls in lowercase -->
86+
<rule ref="Squiz.PHP.LowercasePHPFunctions" />
87+
<!-- Forbid dead code -->
88+
<rule ref="Squiz.PHP.NonExecutableCode" />
89+
90+
<!-- Forbid `$this` inside static function -->
91+
<rule ref="Squiz.Scope.StaticThisUsage" />
92+
93+
<!-- Disallow double quote usage -->
94+
<rule ref="Squiz.Strings.DoubleQuoteUsage">
95+
<exclude name="Squiz.Strings.DoubleQuoteUsage.ContainsVar" />
1396
</rule>
14-
<rule ref="Generic.CodeAnalysis.EmptyStatement">
15-
<exclude-pattern>/tests/</exclude-pattern>
97+
<!-- Forbid blank line after function opening brace -->
98+
<rule ref="Squiz.WhiteSpace.FunctionOpeningBraceSpace"/>
99+
<!-- Require 1 line before and after function, except at the top and bottom -->
100+
<rule ref="Squiz.WhiteSpace.FunctionSpacing">
101+
<properties>
102+
<property name="spacing" value="1" />
103+
<property name="spacingBeforeFirst" value="0"/>
104+
<property name="spacingAfterLast" value="0"/>
105+
</properties>
16106
</rule>
17-
<rule ref="Generic.Metrics.CyclomaticComplexity">
107+
<!-- Require space after language constructs -->
108+
<rule ref="Squiz.WhiteSpace.LanguageConstructSpacing" />
109+
<!-- Require space around logical operators -->
110+
<rule ref="Squiz.WhiteSpace.LogicalOperatorSpacing" />
111+
<!-- Forbid spaces around `->` operator -->
112+
<rule ref="Squiz.WhiteSpace.ObjectOperatorSpacing">
18113
<properties>
19-
<property name="complexity" value="5" />
20-
<property name="absoluteComplexity" value="10" />
114+
<property name="ignoreNewlines" value="true" />
21115
</properties>
22116
</rule>
23-
<rule ref="Squiz.Strings.DoubleQuoteUsage" />
117+
118+
<!-- Forbid spaces before semicolon `;` -->
119+
<rule ref="Squiz.WhiteSpace.SemicolonSpacing" />
120+
<!-- Forbid superfluous whitespaces -->
121+
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace">
122+
<properties>
123+
<!-- turned on by PSR-12 -> turning back off -->
124+
<property name="ignoreBlankLines" value="false" />
125+
</properties>
126+
</rule>
127+
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace.EmptyLines">
128+
<!-- turned off by PSR-12 -> turning back on -->
129+
<severity>5</severity>
130+
</rule>
24131
</ruleset>

phpstan.neon

+3
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,12 @@ includes:
44
parameters:
55
level: 8
66
checkMissingIterableValueType: false
7+
reportUnmatchedIgnoredErrors: false
78
paths:
89
- src
910
- tests
11+
ignoreErrors:
12+
- '#Parameter \#3 \$transferTime of class GuzzleHttp\\TransferStats constructor expects null, float given.#'
1013

1114
rules:
1215
- PHPStan\Rules\BooleansInConditions\BooleanInBooleanAndRule

tests/Handler/MultiRecordArrayHandlerTest.php

+4-14
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,8 @@ public function logTransactionWithJsonResponse(): void
7171
$this->assertSame('Guzzle HTTP request', $this->logger->records[0]['message']);
7272
$this->assertSame(LogLevel::DEBUG, $this->logger->records[1]['level']);
7373
$this->assertSame('Guzzle HTTP response', $this->logger->records[1]['message']);
74-
$this->assertContains(
75-
[
76-
'status' => true,
77-
'client' => 13000,
78-
],
79-
$this->logger->records[1]['context']['response']['body']
80-
);
74+
$this->assertTrue($this->logger->records[1]['context']['response']['body']['status']);
75+
$this->assertSame(13000, $this->logger->records[1]['context']['response']['body']['client']);
8176
}
8277

8378
/**
@@ -124,13 +119,8 @@ public function logTransactionWithJsonApiResponse(): void
124119
$this->assertSame('Guzzle HTTP request', $this->logger->records[0]['message']);
125120
$this->assertSame(LogLevel::DEBUG, $this->logger->records[1]['level']);
126121
$this->assertSame('Guzzle HTTP response', $this->logger->records[1]['message']);
127-
$this->assertContains(
128-
[
129-
'status' => true,
130-
'client' => 13000,
131-
],
132-
$this->logger->records[1]['context']['response']['body']
133-
);
122+
$this->assertTrue($this->logger->records[1]['context']['response']['body']['status']);
123+
$this->assertSame(13000, $this->logger->records[1]['context']['response']['body']['client']);
134124
}
135125

136126
/**

0 commit comments

Comments
 (0)