Skip to content

Commit 8959733

Browse files
authored
Minimal PHP version is 7.4 (#31)
1 parent e199d72 commit 8959733

16 files changed

Lines changed: 167 additions & 158 deletions

.github/workflows/main.yml

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,9 @@ jobs:
3535
JBZOO_COMPOSER_UPDATE_FLAGS: ${{ matrix.composer_flags }}
3636
strategy:
3737
matrix:
38-
php-version: [ 7.2, 7.3, 7.4, 8.0 ]
39-
experimental: [ false ]
38+
php-version: [ 7.4, 8.0, 8.1 ]
4039
coverage: [ xdebug, none ]
4140
composer_flags: [ "--prefer-lowest", "" ]
42-
include:
43-
- php-version: "8.1"
44-
experimental: true
4541
steps:
4642
- name: Checkout code
4743
uses: actions/checkout@v2
@@ -56,18 +52,15 @@ jobs:
5652
tools: composer
5753

5854
- name: Build the Project
59-
continue-on-error: ${{ matrix.experimental }}
6055
run: make update --no-print-directory
6156

6257
- name: 🧪 PHPUnit Tests
63-
continue-on-error: ${{ matrix.experimental }}
6458
run: make test --no-print-directory
6559

6660
- name: Uploading coverage to coveralls
67-
if: ${{ matrix.coverage == 'xdebug' }}
6861
env:
6962
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
70-
run: make report-coveralls --no-print-directory
63+
run: make report-coveralls --no-print-directory || true
7164

7265
- name: Upload Artifacts
7366
uses: actions/upload-artifact@v2
@@ -81,7 +74,7 @@ jobs:
8174
runs-on: ubuntu-latest
8275
strategy:
8376
matrix:
84-
php-version: [ 7.2, 7.3, 7.4 ]
77+
php-version: [ 7.4, 8.0, 8.1 ]
8578
steps:
8679
- name: Checkout code
8780
uses: actions/checkout@v2
@@ -112,7 +105,7 @@ jobs:
112105
runs-on: ubuntu-latest
113106
strategy:
114107
matrix:
115-
php-version: [ 7.2, 7.3, 7.4, 8.0 ]
108+
php-version: [ 7.4, 8.0, 8.1 ]
116109
steps:
117110
- name: Checkout code
118111
uses: actions/checkout@v2
@@ -126,11 +119,9 @@ jobs:
126119
tools: composer
127120

128121
- name: Build the Project
129-
continue-on-error: ${{ matrix.experimental }}
130122
run: make update --no-print-directory
131123

132124
- name: 📝 Build Reports
133-
continue-on-error: ${{ matrix.experimental }}
134125
run: make report-all --no-print-directory
135126

136127
- name: Upload Artifacts

composer.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,15 @@
2626
],
2727

2828
"require" : {
29-
"php" : ">=7.2",
29+
"php" : ">=7.4",
3030
"ext-posix" : "*",
3131
"ext-filter" : "*",
3232
"ext-dom" : "*"
3333
},
3434

3535
"require-dev" : {
36-
"jbzoo/toolbox-dev" : "^3.1.0",
37-
"symfony/process" : ">=4.4"
36+
"jbzoo/toolbox-dev" : "^4.0.1",
37+
"symfony/process" : ">=4.4,<6.0"
3838
},
3939

4040
"suggest" : {
@@ -62,8 +62,8 @@
6262

6363
"config" : {
6464
"optimize-autoloader" : true,
65-
"allow-plugins": {
66-
"composer/package-versions-deprecated": false
65+
"allow-plugins" : {
66+
"composer/package-versions-deprecated" : false
6767
}
6868
},
6969

phpunit.xml.dist

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
@copyright Copyright (C) JBZoo.com, All rights reserved.
1212
@link https://github.com/JBZoo/Utils
1313
-->
14-
<phpunit bootstrap="tests/autoload.php"
14+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
15+
bootstrap="tests/autoload.php"
1516
convertErrorsToExceptions="true"
1617
convertNoticesToExceptions="true"
1718
convertWarningsToExceptions="true"
@@ -23,24 +24,26 @@
2324
stopOnIncomplete="false"
2425
stopOnSkipped="false"
2526
stopOnRisky="false"
27+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
2628
>
29+
<coverage processUncoveredFiles="true">
30+
<include>
31+
<directory suffix=".php">src</directory>
32+
</include>
33+
<report>
34+
<clover outputFile="build/coverage_xml/main.xml"/>
35+
<php outputFile="build/coverage_cov/main.cov"/>
36+
<text outputFile="php://stdout" showUncoveredFiles="false" showOnlySummary="true"/>
37+
</report>
38+
</coverage>
39+
2740
<testsuites>
2841
<testsuite name="PHPUnit">
2942
<directory suffix="Test.php">tests</directory>
3043
</testsuite>
3144
</testsuites>
3245

33-
<filter>
34-
<whitelist processUncoveredFilesFromWhitelist="true">
35-
<directory suffix=".php">src</directory>
36-
</whitelist>
37-
</filter>
38-
3946
<logging>
40-
<log type="coverage-clover" target="build/coverage_xml/main.xml"/>
41-
<log type="coverage-php" target="build/coverage_cov/main.cov"/>
42-
<log type="junit" target="build/coverage_junit/main.xml"/>
43-
<log type="coverage-text" target="php://stdout" showUncoveredFiles="false" showOnlySummary="true"/>
47+
<junit outputFile="build/coverage_junit/main.xml"/>
4448
</logging>
45-
4649
</phpunit>

src/Email.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public static function checkDns(string $email): bool
8080

8181
$domain = self::extractDomain($email);
8282

83-
return !(\checkdnsrr($domain, 'MX') === false);
83+
return \checkdnsrr($domain);
8484
}
8585

8686
/**

src/IP.php

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -78,22 +78,14 @@ public static function v4InRange(string $ipAddress, string $range): bool
7878

7979
// $netMask is a CIDR size block
8080
// fix the range argument
81-
$blocks = \explode('.', $range);
82-
83-
$expectedNumOfParts = 4;
84-
/** @phan-suppress-next-line PhanPossiblyInfiniteLoop */
85-
while (\count($blocks) < $expectedNumOfParts) {
86-
$blocks[] = '0';
87-
}
88-
89-
[$blockA, $blockB, $blockC, $blockD] = $blocks;
81+
$blocks = \explode('.', $range, 4);
9082

9183
$range = \sprintf(
9284
'%u.%u.%u.%u',
93-
(int)(empty($blockA) ? '0' : $blockA),
94-
(int)(empty($blockB) ? '0' : $blockB),
95-
(int)(empty($blockC) ? '0' : $blockC),
96-
(int)(empty($blockD) ? '0' : $blockD)
85+
(int)($blocks[0] ?? 0),
86+
(int)($blocks[1] ?? 0),
87+
(int)($blocks[2] ?? 0),
88+
(int)($blocks[3] ?? 0)
9789
);
9890

9991
$rangeDec = \ip2long($range);

src/Image.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,8 +239,8 @@ public static function imageCopyMergeAlpha(
239239

240240
// Get image width and height and percentage
241241
$opacity /= 100;
242-
$width = (int)\imagesx($srcImg);
243-
$height = (int)\imagesy($srcImg);
242+
$width = \imagesx($srcImg) ?: 0;
243+
$height = \imagesy($srcImg) ?: 0;
244244

245245
// Turn alpha blending off
246246
self::addAlpha($srcImg, false);

src/Str.php

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ final class Str
3232
*
3333
* @var string
3434
*/
35-
public static $encoding = 'UTF-8';
35+
public static string $encoding = 'UTF-8';
3636

3737
/**
3838
* Strip all whitespaces from the given string.
@@ -340,19 +340,6 @@ public static function slug(string $text = '', bool $isCache = false): string
340340
return $cache[$text];
341341
}
342342

343-
/**
344-
* Check is mbstring overload standard functions
345-
* @return bool
346-
*/
347-
public static function isOverload(): bool
348-
{
349-
if (\defined('MB_OVERLOAD_STRING') && self::isMBString()) {
350-
return (bool)(Filter::int(Sys::iniGet('mbstring.func_overload')) & \MB_OVERLOAD_STRING);
351-
}
352-
353-
return false;
354-
}
355-
356343
/**
357344
* Check is mbstring loaded
358345
*

src/Url.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ final class Url
6363
*/
6464
public static function addArg(array $newParams, ?string $uri = null): string
6565
{
66-
$uri = $uri ?? ($_SERVER['REQUEST_URI'] ?? '');
66+
$uri ??= ($_SERVER['REQUEST_URI'] ?? '');
6767

6868
// Parse the URI into it's components
6969
$parsedUri = data((array)\parse_url((string)$uri));

src/Xml.php

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,11 @@ public static function escape($rawXmlContent): string
4242
$rawXmlContent
4343
);
4444

45-
$rawXmlContent = \str_replace(
45+
return \str_replace(
4646
['&', '<', '>', '"', "'"],
4747
['&amp;', '&lt;', '&gt;', '&quot;', '&apos;'],
4848
$rawXmlContent
4949
);
50-
51-
return $rawXmlContent;
5250
}
5351

5452
/**
@@ -121,13 +119,10 @@ public static function array2Dom(
121119
$document = self::createFromString();
122120
}
123121

124-
$domElement = $domElement ?? $document;
122+
$domElement ??= $document;
125123

126124
if (\array_key_exists('_text', $xmlAsArray) && $xmlAsArray['_text'] !== null) {
127-
$newNode = $document->createTextNode($xmlAsArray['_text']);
128-
if ($newNode !== false) {
129-
$domElement->appendChild($newNode);
130-
}
125+
$domElement->appendChild(new \DOMText($xmlAsArray['_text']));
131126
}
132127

133128
if (\array_key_exists('_cdata', $xmlAsArray) && $xmlAsArray['_cdata'] !== null) {

src/defines.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@
1515

1616
declare(strict_types=1);
1717

18-
$_SERVER['REQUEST_TIME_FLOAT'] = $_SERVER['REQUEST_TIME_FLOAT'] ?? microtime(true);
19-
$_SERVER['REQUEST_TIME'] = $_SERVER['REQUEST_TIME'] ?? $_SERVER['REQUEST_TIME_FLOAT'];
18+
$_SERVER['REQUEST_TIME_FLOAT'] ??= microtime(true);
19+
$_SERVER['REQUEST_TIME'] ??= $_SERVER['REQUEST_TIME_FLOAT'];

0 commit comments

Comments
 (0)