Skip to content

Commit

Permalink
update travis (#36)
Browse files Browse the repository at this point in the history
* update travis

* Fix minimum allowed guzzle version

* Fix travis

* Make tests compatible with version 9
  • Loading branch information
gmponos authored Jul 5, 2020
1 parent 8f355d9 commit 261a674
Show file tree
Hide file tree
Showing 5 changed files with 142 additions and 35 deletions.
17 changes: 12 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
language: php

php:
- 7.2
- 7.3
- 7.4
matrix:
include:
- php: 7.2
dist: bionic
- php: 7.2
dist: bionic
env: COMPOSER_FLAGS="--prefer-stable --prefer-lowest"
- php: 7.3
dist: bionic
- php: 7.4
dist: bionic

before_script:
- composer install --prefer-dist --no-interaction
- composer update $COMPOSER_FLAGS --prefer-dist --no-interaction

script:
- php vendor/bin/phpunit --coverage-clover=clover.xml
Expand Down
10 changes: 5 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,22 @@
"require": {
"php": ">=7.2",
"ext-json": "*",
"guzzlehttp/guzzle": "6.*",
"guzzlehttp/guzzle": "^6.1",
"psr/log": "^1.1"
},
"require-dev": {
"phpstan/phpstan": "~0.12.30",
"phpstan/phpstan": "~0.12.32",
"phpstan/phpstan-phpunit": "^0.12.11",
"phpstan/phpstan-strict-rules": "^0.12.2",
"phpunit/phpunit": "~8.5.8",
"webthink/codesniffer": "2.*"
"phpunit/phpunit": "^8.5.8 || ^9.2.5",
"squizlabs/php_codesniffer": "^3.5.5"
},
"suggest": {
"monolog/monolog": "A PSR-3 logger to send your logs to files, sockets and various web services"
},
"scripts": {
"test": "php vendor/bin/phpunit",
"phpcs": "php vendor/bin/phpcs ./src ./tests",
"phpcs": "php vendor/bin/phpcs ./src ./tests -n",
"phpcbf": "php vendor/bin/phpcbf ./src ./tests"
},
"extra": {
Expand Down
129 changes: 118 additions & 11 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,127 @@

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

<rule ref="./vendor/webthink/codesniffer/src/Webthink/ruleset.xml">
<exclude name="Generic.Files.LineLength.TooLong" />
<exclude name="Generic.Strings.UnnecessaryStringConcat" />
<exclude name="PEAR.Commenting.FunctionComment" />
<exclude name="Webthink.Formatting.UseInAlphabeticalOrder.UseInAlphabeticalOrder" />
<rule ref="PSR12" />
<!-- Force array element indentation with 4 spaces -->
<rule ref="Generic.Arrays.ArrayIndent"/>
<!-- Forbid `array(...)` -->
<rule ref="Generic.Arrays.DisallowLongArraySyntax"/>
<!-- Forbid final methods in final classes -->
<rule ref="Generic.CodeAnalysis.UnnecessaryFinalModifier"/>
<!-- Forbid useless empty method overrides -->
<rule ref="Generic.CodeAnalysis.UselessOverridingMethod"/>
<!-- Forbid Yoda -->
<rule ref="Generic.ControlStructures.DisallowYodaConditions"/>
<!-- Forbid inline HTML in PHP code -->
<rule ref="Generic.Files.InlineHTML"/>
<!-- Forbid PHP 4 constructors -->
<rule ref="Generic.NamingConventions.ConstructorName"/>
<!-- Forbid any content before opening tag -->
<rule ref="Generic.PHP.CharacterBeforePHPOpeningTag"/>
<!-- Forbid deprecated functions -->
<rule ref="Generic.PHP.DeprecatedFunctions"/>
<rule ref="Generic.PHP.ForbiddenFunctions">
<properties>
<property name="forbiddenFunctions" type="array">
<element key="chop" value="rtrim"/>
<element key="close" value="closedir"/>
<element key="compact" value="null"/>
<element key="delete" value="unset"/>
<element key="doubleval" value="floatval"/>
<element key="extract" value="null"/>
<element key="fputs" value="fwrite"/>
<element key="ini_alter" value="ini_set"/>
<element key="is_double" value="is_float"/>
<element key="is_integer" value="is_int"/>
<element key="is_long" value="is_int"/>
<element key="is_null" value="null"/>
<element key="is_real" value="is_float"/>
<element key="is_writeable" value="is_writable"/>
<element key="join" value="implode"/>
<element key="key_exists" value="array_key_exists"/>
<element key="pos" value="current"/>
<element key="settype" value="null"/>
<element key="show_source" value="highlight_file"/>
<element key="sizeof" value="count"/>
<element key="strchr" value="strstr"/>
<element key="user_error" value="trigger_error"/>
</property>
</properties>
</rule>
<!-- Forbid useless inline string concatenation -->
<rule ref="Generic.Strings.UnnecessaryStringConcat">
<!-- But multiline is useful for readability -->
<properties>
<property name="allowMultiline" value="true"/>
</properties>
</rule>
<!-- Forbid backtick operator -->
<rule ref="Generic.PHP.BacktickOperator"/>
<!-- Force PHP 7 param and return types to be lowercased -->
<rule ref="Generic.PHP.LowerCaseType"/>
<!-- Forbid `php_sapi_name()` function -->
<rule ref="Generic.PHP.SAPIUsage"/>
<!-- Forbid comments starting with # -->
<rule ref="PEAR.Commenting.InlineComment"/>

<rule ref="PEAR.WhiteSpace.ObjectOperatorIndent" />

<!-- Forbid global functions -->
<rule ref="Squiz.Functions.GlobalFunction" />
<!-- Force camelCase variables -->
<rule ref="Squiz.NamingConventions.ValidVariableName">
<exclude name="Squiz.NamingConventions.ValidVariableName.PrivateNoUnderscore" />
</rule>
<!-- Forbid `AND` and `OR`, require `&&` and `||` -->
<rule ref="Squiz.Operators.ValidLogicalOperators" />
<!-- Forbid `global` -->
<rule ref="Squiz.PHP.GlobalKeyword" />
<!-- Forbid functions inside functions -->
<rule ref="Squiz.PHP.InnerFunctions" />
<!-- Require PHP function calls in lowercase -->
<rule ref="Squiz.PHP.LowercasePHPFunctions" />
<!-- Forbid dead code -->
<rule ref="Squiz.PHP.NonExecutableCode" />

<!-- Forbid `$this` inside static function -->
<rule ref="Squiz.Scope.StaticThisUsage" />

<!-- Disallow double quote usage -->
<rule ref="Squiz.Strings.DoubleQuoteUsage">
<exclude name="Squiz.Strings.DoubleQuoteUsage.ContainsVar" />
</rule>
<rule ref="Generic.CodeAnalysis.EmptyStatement">
<exclude-pattern>/tests/</exclude-pattern>
<!-- Forbid blank line after function opening brace -->
<rule ref="Squiz.WhiteSpace.FunctionOpeningBraceSpace"/>
<!-- Require 1 line before and after function, except at the top and bottom -->
<rule ref="Squiz.WhiteSpace.FunctionSpacing">
<properties>
<property name="spacing" value="1" />
<property name="spacingBeforeFirst" value="0"/>
<property name="spacingAfterLast" value="0"/>
</properties>
</rule>
<rule ref="Generic.Metrics.CyclomaticComplexity">
<!-- Require space after language constructs -->
<rule ref="Squiz.WhiteSpace.LanguageConstructSpacing" />
<!-- Require space around logical operators -->
<rule ref="Squiz.WhiteSpace.LogicalOperatorSpacing" />
<!-- Forbid spaces around `->` operator -->
<rule ref="Squiz.WhiteSpace.ObjectOperatorSpacing">
<properties>
<property name="complexity" value="5" />
<property name="absoluteComplexity" value="10" />
<property name="ignoreNewlines" value="true" />
</properties>
</rule>
<rule ref="Squiz.Strings.DoubleQuoteUsage" />

<!-- Forbid spaces before semicolon `;` -->
<rule ref="Squiz.WhiteSpace.SemicolonSpacing" />
<!-- Forbid superfluous whitespaces -->
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace">
<properties>
<!-- turned on by PSR-12 -> turning back off -->
<property name="ignoreBlankLines" value="false" />
</properties>
</rule>
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace.EmptyLines">
<!-- turned off by PSR-12 -> turning back on -->
<severity>5</severity>
</rule>
</ruleset>
3 changes: 3 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@ includes:
parameters:
level: 8
checkMissingIterableValueType: false
reportUnmatchedIgnoredErrors: false
paths:
- src
- tests
ignoreErrors:
- '#Parameter \#3 \$transferTime of class GuzzleHttp\\TransferStats constructor expects null, float given.#'

rules:
- PHPStan\Rules\BooleansInConditions\BooleanInBooleanAndRule
Expand Down
18 changes: 4 additions & 14 deletions tests/Handler/MultiRecordArrayHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,8 @@ public function logTransactionWithJsonResponse(): void
$this->assertSame('Guzzle HTTP request', $this->logger->records[0]['message']);
$this->assertSame(LogLevel::DEBUG, $this->logger->records[1]['level']);
$this->assertSame('Guzzle HTTP response', $this->logger->records[1]['message']);
$this->assertContains(
[
'status' => true,
'client' => 13000,
],
$this->logger->records[1]['context']['response']['body']
);
$this->assertTrue($this->logger->records[1]['context']['response']['body']['status']);
$this->assertSame(13000, $this->logger->records[1]['context']['response']['body']['client']);
}

/**
Expand Down Expand Up @@ -124,13 +119,8 @@ public function logTransactionWithJsonApiResponse(): void
$this->assertSame('Guzzle HTTP request', $this->logger->records[0]['message']);
$this->assertSame(LogLevel::DEBUG, $this->logger->records[1]['level']);
$this->assertSame('Guzzle HTTP response', $this->logger->records[1]['message']);
$this->assertContains(
[
'status' => true,
'client' => 13000,
],
$this->logger->records[1]['context']['response']['body']
);
$this->assertTrue($this->logger->records[1]['context']['response']['body']['status']);
$this->assertSame(13000, $this->logger->records[1]['context']['response']['body']['client']);
}

/**
Expand Down

0 comments on commit 261a674

Please sign in to comment.