Skip to content

Commit

Permalink
Sync with Contributte standards
Browse files Browse the repository at this point in the history
  • Loading branch information
mabar authored and Milan Felix Šulc committed Nov 20, 2018
1 parent 46734bf commit fafece6
Show file tree
Hide file tree
Showing 20 changed files with 128 additions and 86 deletions.
16 changes: 16 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# EditorConfig is awesome: http://EditorConfig.org

root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
indent_style = tab
indent_size = tab
tab_width = 4

[{*.json,*.yml,*.md}]
indent_style = space
indent_size = 2
10 changes: 10 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Not archived
.docs export-ignore
tests export-ignore
.editorconfig export-ignore
.gitattributes export-ignore
.gitignore export-ignore
.travis.yml export-ignore
phpstan.neon export-ignore
README.md export-ignore
ruleset.xml export-ignore
15 changes: 9 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
.idea
composer.lock
vendor
# IDE
/.idea

tests/php-unix.generated.ini
tests/cases/output
tests/cases/**/output
# Composer
/vendor
/composer.lock

# Tests
/temp
/coverage.xml
78 changes: 48 additions & 30 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,47 +1,65 @@
language: php
php:
- 7.1
- 7.2
- 7.3

env:
- PHP_BIN=php
- 7.1
- 7.2
- 7.3

before_install:
# turn off XDebug
- phpenv config-rm xdebug.ini || return 0
# Turn off XDebug
- phpenv config-rm xdebug.ini || return 0

install:
- travis_retry composer install --no-progress --prefer-dist
# Composer
- travis_retry composer install --no-progress --prefer-dist

script:
- composer run-script tester
# Tests
- composer run-script tests

after_failure:
# Print *.actual content
- for i in $(find tests -name \*.actual); do echo "--- $i"; cat $i; echo; echo; done

jobs:
include:
- stage: Code Standard Checker
php: 7.1
script:
- composer run-script phpstan
- composer run-script qa
include:
- env: title="Lowest Dependencies 7.1"
php: 7.1
install:
- travis_retry composer update --no-progress --prefer-dist --prefer-lowest
script:
- composer run-script tests

- stage: Quality Assurance
php: 7.1
script:
- composer run-script qa

- stage: Phpstan
php: 7.1
script:
- composer run-script phpstan-install
- composer run-script phpstan

- stage: Code Coverage
php: 7.1
script:
- vendor/bin/tester -p phpdbg tests/cases -s --coverage ./coverage.xml --coverage-src ./src
after_script:
- wget https://github.com/satooshi/php-coveralls/releases/download/v1.0.1/coveralls.phar
- php coveralls.phar --verbose --config tests/config/.coveralls.yml
- stage: Test Coverage
if: branch = master AND type = push
php: 7.1
script:
- composer run-script coverage
after_script:
- wget https://github.com/php-coveralls/php-coveralls/releases/download/v2.1.0/php-coveralls.phar
- php php-coveralls.phar --verbose --config tests/.coveralls.yml

allow_failures:
- stage: Code Coverage
- stage: Outdated Dependencies
if: branch = master AND type = cron
php: 7.1
script:
- composer outdated --direct --strict

allow_failures:
- stage: Test Coverage

sudo: false

cache:
directories:
- $HOME/.composer/cache

notifications:
email: false
directories:
- $HOME/.composer/cache
10 changes: 0 additions & 10 deletions Makefile

This file was deleted.

6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
[![Build Status](https://img.shields.io/travis/contributte/thepay-api.svg?style=flat-square)](https://travis-ci.org/contributte/thepay-api)
[![Code coverage](https://img.shields.io/coveralls/contributte/thepay-api.svg?style=flat-square)](https://coveralls.io/r/contributte/thepay-api)
[![Licence](https://img.shields.io/packagist/l/contributte/thepay-api.svg?style=flat-square)](https://packagist.org/packages/contributte/thepay-api)

[![Downloads this Month](https://img.shields.io/packagist/dm/contributte/thepay-api.svg?style=flat-square)](https://packagist.org/packages/contributte/thepay-api)
[![Downloads total](https://img.shields.io/packagist/dt/contributte/thepay-api.svg?style=flat-square)](https://packagist.org/packages/contributte/thepay-api)
[![Latest stable](https://img.shields.io/packagist/v/contributte/thepay-api.svg?style=flat-square)](https://packagist.org/packages/contributte/thepay-api)
[![PHPStan](https://img.shields.io/badge/PHPStan-enabled-brightgreen.svg?style=flat)](https://github.com/phpstan/phpstan)

## Discussion / Help

Expand Down Expand Up @@ -40,7 +40,7 @@ composer require contributte/thepay-api
<tr>
<td align="center">
<a href="https://github.com/trejjam">
<img width="150" height="150" src="https://avatars2.githubusercontent.com/u/3594540?s=460&v=4">
<img width="150" height="150" src="https://avatars2.githubusercontent.com/u/3594540?s=150&v=4">
</a>
</br>
<a href="https://github.com/trejjam">Jan Trejbal</a>
Expand All @@ -53,7 +53,7 @@ composer require contributte/thepay-api
<a href="https://github.com/f3l1x">Milan Felix Šulc</a>
</td>
</tr>
<tbody>
</tbody>
</table>

-----
Expand Down
23 changes: 12 additions & 11 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,16 @@
"keywords": [
"the pay"
],
"license": [
"MIT"
],
"license": "MIT",
"require": {
"php": ">=7.1",
"ext-json": "*",
"ext-soap": "*",
"ext-hash": "*"
},
"require-dev": {
"nette/tester": "^2.0.2",
"phpstan/phpstan": "^0.10.2",
"phpstan/phpstan-strict-rules": "^0.10.1",
"ninjify/qa": "^0.8.0@dev",
"ninjify/nunjuck": "^0.2.0"
"ninjify/qa": "^0.8.0",
"ninjify/nunjuck": "^0.2.1"
},
"suggest": {
"contributte/thepay": "to use as nette extension"
Expand All @@ -38,14 +33,20 @@
"linter src tests/cases",
"codesniffer src tests/cases"
],
"tester": [
"tests": [
"tester -s -p php --colors 1 -C -d soap.so tests/cases"
],
"coverage": [
"tester -s -p php --colors 1 -C -d soap.so -d extension=xdebug.so --coverage coverage.xml --coverage-src src tests/cases"
"tester -s -p phpdbg --colors 1 -C -d soap.so --coverage coverage.xml --coverage-src src tests/cases"
],
"phpstan-install": [
"mkdir -p temp/phpstan",
"composer require -d temp/phpstan phpstan/phpstan:^0.10",
"composer require -d temp/phpstan phpstan/phpstan-deprecation-rules:^0.10",
"composer require -d temp/phpstan phpstan/phpstan-strict-rules:^0.10"
],
"phpstan": [
"phpstan analyse -l max -c tests/config/phpstan.neon src tests/cases"
"temp/phpstan/vendor/bin/phpstan analyse -l max -c phpstan.neon src tests/cases"
]
},
"extra": {
Expand Down
7 changes: 5 additions & 2 deletions tests/config/phpstan.neon → phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
includes:
# Many errors that should be fixed
# - temp/phpstan/vendor/phpstan/phpstan-deprecation-rules/rules.neon
# - temp/phpstan/vendor/phpstan/phpstan-strict-rules/rules.neon

parameters:
includes:
- temp/phpstan/vendor/phpstan/phpstan-strict-rules/rules.neon
ignoreErrors:
- '#Call to an undefined method SoapClient::#'
- '#Method Tp\\Helper\\DataApi::[a-zA-Z]+\(\) should return Tp\\DataApi\\Responses\\[a-zA-Z]+ but returns Tp\\DataApi\\Responses\\Response\.#'
8 changes: 0 additions & 8 deletions ruleset.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,6 @@
<exclude-pattern>*</exclude-pattern>
</rule>

<rule ref="SlevomatCodingStandard.Functions.UnusedParameter.UnusedParameter">
<exclude-pattern>*</exclude-pattern>
</rule>

<rule ref="SlevomatCodingStandard.ControlStructures.NewWithParentheses.MissingParentheses">
<exclude-pattern>*</exclude-pattern>
</rule>

<rule ref="Squiz.Commenting.VariableComment.MissingVar">
<exclude-pattern>*</exclude-pattern>
</rule>
Expand Down
2 changes: 1 addition & 1 deletion src/DataApi/Parameters/Signature.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public static function validate(array $data, string $password, ?string $signatur
$computed = static::compute($data, $password);

if ($computed !== $signature) {
throw new InvalidSignatureException;
throw new InvalidSignatureException();
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/DataApi/Processors/Digester.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class Digester

public static function process(array $input): string
{
$instance = new static;
$instance = new static();
// Start with an empty path [].
return $instance->processHash($input);
}
Expand Down
2 changes: 1 addition & 1 deletion src/DataApi/Processors/Processor.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ abstract class Processor

public static function process(array $input): array
{
$instance = new static;
$instance = new static();
// Start with an empty path [].
return $instance->processHash($input, []);
}
Expand Down
8 changes: 4 additions & 4 deletions src/Helper/Card.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public static function depositPayment(
);

if (!$result) {
throw new Exception;
throw new Exception();
}

return new PaymentResponse($result);
Expand Down Expand Up @@ -74,7 +74,7 @@ public static function stornoPayment(
);

if (!$result) {
throw new Exception;
throw new Exception();
}

return new PaymentResponse($result);
Expand Down Expand Up @@ -112,7 +112,7 @@ public static function createNewRecurrentPayment(
);

if (!$result) {
throw new Exception;
throw new Exception();
}

return new PaymentResponse($result);
Expand Down Expand Up @@ -140,7 +140,7 @@ public static function getCardInfo(
]);

if (!$result) {
throw new Exception;
throw new Exception();
}

return new InfoResponse($result);
Expand Down
4 changes: 2 additions & 2 deletions src/Helper/PermanentPayment.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public static function createPermanentPayment(
);

if (!$result) {
throw new TpException;
throw new TpException();
}

return new PermanentPaymentResponse($result);
Expand All @@ -58,7 +58,7 @@ public static function getPermanentPayment(
);

if (!$result) {
throw new TpException;
throw new TpException();
}

return new PermanentPaymentResponse($result);
Expand Down
2 changes: 1 addition & 1 deletion src/Helper/ReturnHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public static function returnPayment(
);

if (!$result) {
throw new Exception;
throw new Exception();
}

return new PaymentReturnResponse($result);
Expand Down
4 changes: 2 additions & 2 deletions src/ReturnedPayment.php
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ public function verifySignature(?string $signature = null): bool
$this->getRequestMerchantId() !== $this->getMerchantConfig()->merchantId
|| $this->getRequestAccountId() !== $this->getMerchantConfig()->accountId
) {
throw new InvalidSignatureException;
throw new InvalidSignatureException();
}

if ($signature === null) {
Expand Down Expand Up @@ -258,7 +258,7 @@ public function verifySignature(?string $signature = null): bool
if ($sig === $signature) {
return true;
}
throw new InvalidSignatureException;
throw new InvalidSignatureException();
}

public function getRequestMerchantId(): ?int
Expand Down
File renamed without changes.
10 changes: 10 additions & 0 deletions tests/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Folders - recursive
*.expected
*.actual

# Folders
/tmp

# Files
/*.log
/*.html
3 changes: 1 addition & 2 deletions tests/bootstrap.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php
declare(strict_types = 1);
<?php declare(strict_types = 1);

require __DIR__ . '/../vendor/autoload.php';

Expand Down
4 changes: 2 additions & 2 deletions tests/cases/Helper/DataApi.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ final class DataApiTest extends TestCase

protected function setUp(): void
{
$this->merchantConfig = new MerchantConfig;
$this->merchantConfig = new MerchantConfig();
}

public function testGetPaymentMethods(): void
Expand Down Expand Up @@ -48,5 +48,5 @@ final class DataApiTest extends TestCase

}

$test = new DataApiTest;
$test = new DataApiTest();
$test->run();

0 comments on commit fafece6

Please sign in to comment.