Skip to content

Commit

Permalink
Minimal PHP version is 7.4 (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
SmetDenis authored Jun 6, 2022
1 parent 4b710eb commit 3228eba
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 61 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
JBZOO_COMPOSER_UPDATE_FLAGS: ${{ matrix.composer_flags }}
strategy:
matrix:
php-version: [ 7.2, 7.3, 7.4, 8.0 ]
php-version: [ 7.4, 8.0, 8.1 ]
composer_flags: [ "--prefer-lowest", "" ]
steps:
- name: Checkout code
Expand All @@ -58,8 +58,8 @@ jobs:

- name: Uploading coverage to coveralls
env:
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: make report-coveralls --no-print-directory
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: make report-coveralls --no-print-directory || true

- name: Upload Artifacts
uses: actions/upload-artifact@v2
Expand All @@ -74,7 +74,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
php-version: [ 7.2, 7.3, 7.4, 8.0 ]
php-version: [ 7.4, 8.0, 8.1 ]
steps:
- name: Checkout code
uses: actions/checkout@v2
Expand Down Expand Up @@ -107,7 +107,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
php-version: [ 7.2, 7.3, 7.4, 8.0 ]
php-version: [ 7.4, 8.0, 8.1 ]
steps:
- name: Checkout code
uses: actions/checkout@v2
Expand Down
9 changes: 6 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@
],

"require" : {
"php" : ">=7.2"
"php" : ">=7.4"
},

"require-dev" : {
"jbzoo/toolbox-dev" : "^3.1.0"
"jbzoo/toolbox-dev" : "^4.0.1"
},

"replace" : {
Expand All @@ -47,7 +47,10 @@
},

"config" : {
"optimize-autoloader" : true
"optimize-autoloader" : true,
"allow-plugins" : {
"composer/package-versions-deprecated" : true
}
},

"extra" : {
Expand Down
27 changes: 14 additions & 13 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
@copyright Copyright (C) JBZoo.com, All rights reserved.
@link https://github.com/JBZoo/Retry
-->
<phpunit bootstrap="tests/autoload.php"
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
bootstrap="tests/autoload.php"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
Expand All @@ -23,26 +24,26 @@
stopOnIncomplete="false"
stopOnSkipped="false"
stopOnRisky="false"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
>
<coverage processUncoveredFiles="true">
<include>
<directory suffix=".php">src</directory>
</include>
<report>
<clover outputFile="build/coverage_xml/main.xml"/>
<php outputFile="build/coverage_cov/main.cov"/>
<text outputFile="php://stdout" showUncoveredFiles="true" showOnlySummary="false"/>
</report>
</coverage>

<testsuites>
<testsuite name="All">
<directory suffix="Test.php">tests</directory>
</testsuite>
</testsuites>

<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">src</directory>
</whitelist>
</filter>

<logging>
<log type="coverage-html" target="build/coverage_html" lowUpperBound="75" highLowerBound="95"/>
<log type="coverage-clover" target="build/coverage_xml/main.xml"/>
<log type="coverage-php" target="build/coverage_cov/main.cov"/>
<log type="junit" target="build/coverage_junit/main.xml"/>
<log type="coverage-text" target="php://stdout" showUncoveredFiles="true" showOnlySummary="false"/>
<junit outputFile="build/coverage_junit/main.xml"/>
</logging>

</phpunit>
21 changes: 11 additions & 10 deletions src/Retry.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

use Closure;
use Exception;
use JBZoo\Retry\Strategies\AbstractStrategy;
use JBZoo\Retry\Strategies\ConstantStrategy;
use JBZoo\Retry\Strategies\ExponentialStrategy;
use JBZoo\Retry\Strategies\LinearStrategy;
Expand Down Expand Up @@ -46,10 +47,10 @@ class Retry
* @var int
* @deprecated See README.md "Changing defaults"
*/
public static $defaultMaxAttempts = self::DEFAULT_MAX_ATTEMPTS;
public static int $defaultMaxAttempts = self::DEFAULT_MAX_ATTEMPTS;

/**
* @var string
* @var string|AbstractStrategy
* @deprecated See README.md "Changing defaults"
*/
public static $defaultStrategy = self::DEFAULT_STRATEGY;
Expand All @@ -58,7 +59,7 @@ class Retry
* @var bool
* @deprecated See README.md "Changing defaults"
*/
public static $defaultJitterEnabled = self::DEFAULT_JITTER_STATE;
public static bool $defaultJitterEnabled = self::DEFAULT_JITTER_STATE;

/**
* This callable should take an 'attempt' integer, and return a wait time in milliseconds
Expand All @@ -69,7 +70,7 @@ class Retry
/**
* @var array
*/
protected $strategies = [
protected array $strategies = [
self::STRATEGY_CONSTANT => ConstantStrategy::class,
self::STRATEGY_LINEAR => LinearStrategy::class,
self::STRATEGY_POLYNOMIAL => PolynomialStrategy::class,
Expand All @@ -79,28 +80,28 @@ class Retry
/**
* @var int
*/
protected $maxAttempts;
protected int $maxAttempts;

/**
* The max wait time you want to allow, regardless of what the strategy says
* @var int|null In milliseconds
*/
protected $waitCap;
protected ?int $waitCap;

/**
* @var bool
*/
protected $useJitter = false;
protected bool $useJitter = false;

/**
* @var int
*/
protected $jitterPercent = self::DEFAULT_JITTER_PERCENT;
protected int $jitterPercent = self::DEFAULT_JITTER_PERCENT;

/**
* @var int
*/
protected $jitterMinTime = 0;
protected int $jitterMinTime = 0;

/**
* @var array|non-empty-array<int,\Exception>|non-empty-array<int,\Throwable>
Expand Down Expand Up @@ -213,7 +214,7 @@ public function getJitterPercent(): int
*/
public function setJitterMinCap(int $jitterMinTime): self
{
$this->jitterMinTime = $jitterMinTime < 0 ? 0 : $jitterMinTime;
$this->jitterMinTime = \max($jitterMinTime, 0);
return $this;
}

Expand Down
1 change: 0 additions & 1 deletion tests/RetryCodestyleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,4 @@
*/
class RetryCodestyleTest extends AbstractCodestyleTest
{

}
16 changes: 0 additions & 16 deletions tests/RetryCopyrightTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,4 @@ class RetryCopyrightTest extends AbstractCopyrightTest
* @var string
*/
protected $packageName = 'Retry';

protected $validHeaderPHP = [
'/**',
' * _VENDOR_ - _PACKAGE_',
' *',
' * _DESCRIPTION_PHP_',
' *',
' * @package _PACKAGE_',
' * @license _LICENSE_',
' * @copyright _COPYRIGHTS_',
' * @link _LINK_',
' */',
'',
'declare(strict_types=1);',
''
];
}
14 changes: 1 addition & 13 deletions tests/RetryReadmeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,5 @@ class RetryReadmeTest extends AbstractReadmeTest
/**
* @var string
*/
protected $packageName = 'Retry';

/**
* @inheritDoc
*/
protected function setUp(): void
{
parent::setUp();

$this->params['codefactor'] = true;
$this->params['strict_types'] = true;
$this->params['travis'] = false;
}
protected string $packageName = 'Retry';
}

0 comments on commit 3228eba

Please sign in to comment.