Skip to content

Commit 50a2efa

Browse files
authored
Merge pull request #3 from pluswerk/feature/v83
Add support for php 8.0 to 8.3, dropps support of php 7
2 parents cb21ff3 + 6dbefea commit 50a2efa

7 files changed

Lines changed: 95 additions & 50 deletions

File tree

.github/workflows/tasks.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
strategy:
1010
fail-fast: false
1111
matrix:
12-
php: [ '7.2', '7.3', '7.4', '8.0', '8.1' ]
12+
php: [ '8.0', '8.1', '8.2', '8.3' ]
1313
steps:
1414
- name: Setup PHP with PECL extension
1515
uses: shivammathur/setup-php@v2

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
vendor
22
composer.lock
3+
var/

composer.json

Lines changed: 31 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,34 @@
11
{
2-
"name" : "pluswerk/uptime-robot",
3-
"description" : "Simple wrapper to call uptime-robot heartbeat unified",
4-
"type" : "library",
5-
"license": "LGPL-3.0-or-later",
6-
"authors" : [
7-
{
8-
"name": "Stefan Lamm",
9-
"email": "stefan.lamm@pluswerk.ag",
10-
"homepage": "https://pluswerk.ag"
11-
}
12-
],
13-
"autoload" : {
14-
"psr-4" : {
15-
"Pluswerk\\UptimeRobot\\" : "src/"
16-
}
17-
},
18-
"require" : {
19-
"php" : "^7.2 || ~8.0 || ~8.1",
20-
"psr/log": "^1 || ^2 || ^3"
21-
},
22-
"require-dev": {
23-
"pluswerk/grumphp-config": "^4.0 || ^5.0"
24-
},
25-
"config": {
26-
"allow-plugins": {
27-
"phpro/grumphp": true,
28-
"pluswerk/grumphp-config": true
29-
}
30-
},
31-
"extra": {
32-
"pluswerk/grumphp-config": {
33-
"auto-setting": true
34-
},
35-
"grumphp": {
36-
"config-default-path": "vendor/pluswerk/grumphp-config/grumphp.yml"
37-
}
2+
"name": "pluswerk/uptime-robot",
3+
"description": "Simple wrapper to call uptime-robot heartbeat unified",
4+
"license": "LGPL-3.0-or-later",
5+
"type": "library",
6+
"authors": [
7+
{
8+
"name": "Stefan Lamm",
9+
"email": "stefan.lamm@pluswerk.ag",
10+
"homepage": "https://pluswerk.ag"
3811
}
12+
],
13+
"require": {
14+
"php": "~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0",
15+
"psr/log": "^1 || ^2 || ^3"
16+
},
17+
"require-dev": {
18+
"pluswerk/grumphp-config": "^6.0 || ^7.0"
19+
},
20+
"autoload": {
21+
"psr-4": {
22+
"Pluswerk\\UptimeRobot\\": "src/"
23+
}
24+
},
25+
"config": {
26+
"allow-plugins": {
27+
"ergebnis/composer-normalize": true,
28+
"phpro/grumphp": true,
29+
"phpstan/extension-installer": true,
30+
"pluswerk/grumphp-config": true
31+
}
32+
},
33+
"extra": {}
3934
}

grumphp.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
imports:
2+
- { resource: vendor/pluswerk/grumphp-config/grumphp.yml }
3+
parameters:
4+
convention.process_timeout: 240
5+
convention.security_checker_blocking: true
6+
convention.jsonlint_ignore_pattern: { }
7+
convention.xmllint_ignore_pattern: { }
8+
convention.yamllint_ignore_pattern: { }
9+
convention.phpcslint_ignore_pattern: { }
10+
convention.phpcslint_exclude: { }
11+
convention.xlifflint_ignore_pattern: { }
12+
convention.rector_ignore_pattern: { }
13+
convention.rector_enabled: true
14+
convention.rector_config: rector.php
15+
convention.rector_clear-cache: false
16+
convention.phpstan_level: null

phpstan-baseline.neon

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,3 @@ parameters:
44
message: "#^Parameter \\#2 \\$associative of function get_headers expects bool, int\\|false given\\.$#"
55
count: 1
66
path: src/HeartBeat.php
7-
-
8-
message: "#^Parameter \\#2 \\$format of function get_headers expects int, int\\|false given\\.$#"
9-
count: 1
10-
path: src/HeartBeat.php

rector.php

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use PLUS\GrumPHPConfig\RectorSettings;
6+
use Rector\Config\RectorConfig;
7+
use Rector\Caching\ValueObject\Storage\FileCacheStorage;
8+
9+
return static function (RectorConfig $rectorConfig): void {
10+
$rectorConfig->parallel();
11+
$rectorConfig->importNames();
12+
$rectorConfig->importShortClasses();
13+
$rectorConfig->cacheClass(FileCacheStorage::class);
14+
$rectorConfig->cacheDirectory('./var/cache/rector');
15+
16+
$rectorConfig->paths(
17+
array_filter(explode("\n", (string)shell_exec("git ls-files | xargs ls -d 2>/dev/null | grep -E '\.(php)$'")))
18+
);
19+
20+
// define sets of rules
21+
$rectorConfig->sets(
22+
[
23+
...RectorSettings::sets(true),
24+
...RectorSettings::setsTypo3(false),
25+
]
26+
);
27+
28+
// remove some rules
29+
// ignore some files
30+
$rectorConfig->skip(
31+
[
32+
...RectorSettings::skip(),
33+
...RectorSettings::skipTypo3(),
34+
35+
/**
36+
* rector should not touch these files
37+
*/
38+
//__DIR__ . '/src/Example',
39+
//__DIR__ . '/src/Example.php',
40+
]
41+
);
42+
};

src/HeartBeat.php

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,10 @@
88

99
class HeartBeat
1010
{
11-
/** @var int */
12-
private $lastThrottledExecution = 0;
13-
/** @var LoggerInterface|null */
14-
private $logger = null;
11+
private int $lastThrottledExecution = 0;
1512

16-
public function __construct(LoggerInterface $logger = null)
13+
public function __construct(private ?LoggerInterface $logger = null)
1714
{
18-
$this->logger = $logger;
1915
}
2016

2117
public function alive(string $url): void
@@ -30,9 +26,8 @@ public function alive(string $url): void
3026

3127
$headers = @get_headers($url, PHP_MAJOR_VERSION >= 8 ? false : 0, $context);
3228
if (false === $headers) {
33-
if ($this->logger) {
34-
$this->logger->warning('HeartBeat error occurred sending alive');
35-
}
29+
$this->logger?->warning('HeartBeat error occurred sending alive');
30+
3631
return;
3732
}
3833

0 commit comments

Comments
 (0)