Skip to content

Commit

Permalink
Add support for php 8.0 to 8.3, dropps support of php 7
Browse files Browse the repository at this point in the history
  • Loading branch information
weakbit committed Jun 6, 2024
1 parent cb21ff3 commit 192de18
Show file tree
Hide file tree
Showing 7 changed files with 95 additions and 50 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tasks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
strategy:
fail-fast: false
matrix:
php: [ '7.2', '7.3', '7.4', '8.0', '8.1' ]
php: [ '8.0', '8.1', '8.2', '8.3' ]
steps:
- name: Setup PHP with PECL extension
uses: shivammathur/setup-php@v2
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
vendor
composer.lock
var/
67 changes: 31 additions & 36 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,39 +1,34 @@
{
"name" : "pluswerk/uptime-robot",
"description" : "Simple wrapper to call uptime-robot heartbeat unified",
"type" : "library",
"license": "LGPL-3.0-or-later",
"authors" : [
{
"name": "Stefan Lamm",
"email": "stefan.lamm@pluswerk.ag",
"homepage": "https://pluswerk.ag"
}
],
"autoload" : {
"psr-4" : {
"Pluswerk\\UptimeRobot\\" : "src/"
}
},
"require" : {
"php" : "^7.2 || ~8.0 || ~8.1",
"psr/log": "^1 || ^2 || ^3"
},
"require-dev": {
"pluswerk/grumphp-config": "^4.0 || ^5.0"
},
"config": {
"allow-plugins": {
"phpro/grumphp": true,
"pluswerk/grumphp-config": true
}
},
"extra": {
"pluswerk/grumphp-config": {
"auto-setting": true
},
"grumphp": {
"config-default-path": "vendor/pluswerk/grumphp-config/grumphp.yml"
}
"name": "pluswerk/uptime-robot",
"description": "Simple wrapper to call uptime-robot heartbeat unified",
"license": "LGPL-3.0-or-later",
"type": "library",
"authors": [
{
"name": "Stefan Lamm",
"email": "stefan.lamm@pluswerk.ag",
"homepage": "https://pluswerk.ag"
}
],
"require": {
"php": "^8.0",
"psr/log": "^1 || ^2 || ^3"
},
"require-dev": {
"pluswerk/grumphp-config": "^6.0 || ^7.0"
},
"autoload": {
"psr-4": {
"Pluswerk\\UptimeRobot\\": "src/"
}
},
"config": {
"allow-plugins": {
"ergebnis/composer-normalize": true,
"phpro/grumphp": true,
"phpstan/extension-installer": true,
"pluswerk/grumphp-config": true
}
},
"extra": {}
}
16 changes: 16 additions & 0 deletions grumphp.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
imports:
- { resource: vendor/pluswerk/grumphp-config/grumphp.yml }
parameters:
convention.process_timeout: 240
convention.security_checker_blocking: true
convention.jsonlint_ignore_pattern: { }
convention.xmllint_ignore_pattern: { }
convention.yamllint_ignore_pattern: { }
convention.phpcslint_ignore_pattern: { }
convention.phpcslint_exclude: { }
convention.xlifflint_ignore_pattern: { }
convention.rector_ignore_pattern: { }
convention.rector_enabled: true
convention.rector_config: rector.php
convention.rector_clear-cache: false
convention.phpstan_level: null
4 changes: 0 additions & 4 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,3 @@ parameters:
message: "#^Parameter \\#2 \\$associative of function get_headers expects bool, int\\|false given\\.$#"
count: 1
path: src/HeartBeat.php
-
message: "#^Parameter \\#2 \\$format of function get_headers expects int, int\\|false given\\.$#"
count: 1
path: src/HeartBeat.php
42 changes: 42 additions & 0 deletions rector.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

declare(strict_types=1);

use PLUS\GrumPHPConfig\RectorSettings;
use Rector\Config\RectorConfig;
use Rector\Caching\ValueObject\Storage\FileCacheStorage;

return static function (RectorConfig $rectorConfig): void {
$rectorConfig->parallel();
$rectorConfig->importNames();
$rectorConfig->importShortClasses();
$rectorConfig->cacheClass(FileCacheStorage::class);
$rectorConfig->cacheDirectory('./var/cache/rector');

$rectorConfig->paths(
array_filter(explode("\n", (string)shell_exec("git ls-files | xargs ls -d 2>/dev/null | grep -E '\.(php)$'")))
);

// define sets of rules
$rectorConfig->sets(
[
...RectorSettings::sets(true),
...RectorSettings::setsTypo3(false),
]
);

// remove some rules
// ignore some files
$rectorConfig->skip(
[
...RectorSettings::skip(),
...RectorSettings::skipTypo3(),

/**
* rector should not touch these files
*/
//__DIR__ . '/src/Example',
//__DIR__ . '/src/Example.php',
]
);
};
13 changes: 4 additions & 9 deletions src/HeartBeat.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,10 @@

class HeartBeat
{
/** @var int */
private $lastThrottledExecution = 0;
/** @var LoggerInterface|null */
private $logger = null;
private int $lastThrottledExecution = 0;

public function __construct(LoggerInterface $logger = null)
public function __construct(private ?LoggerInterface $logger = null)
{
$this->logger = $logger;
}

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

$headers = @get_headers($url, PHP_MAJOR_VERSION >= 8 ? false : 0, $context);
if (false === $headers) {
if ($this->logger) {
$this->logger->warning('HeartBeat error occurred sending alive');
}
$this->logger?->warning('HeartBeat error occurred sending alive');

return;
}

Expand Down

0 comments on commit 192de18

Please sign in to comment.