Skip to content
This repository was archived by the owner on Mar 30, 2024. It is now read-only.

Commit cadb274

Browse files
committed
PHP 8 and Phan checks
1 parent 41041c8 commit cadb274

10 files changed

+53
-12
lines changed

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
.DS_Store
2-
/data/*
2+
/data/*
3+
/vendor/*

.phan/config.php

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?php
2+
/*
3+
Run check via Docker-Installed Phan:
4+
5+
# function defined in shell
6+
phan() {
7+
docker run -v $PWD:/mnt/src --rm -u "1000:1000" phanphp/phan:latest $@; return $?;
8+
}
9+
10+
# start in document root of project
11+
$ phan -o report.txt
12+
13+
!! Make sure to have folder vendor in directory !!
14+
$ docker build .
15+
$ docker create -ti --name dummy <image> bash
16+
$ docker cp dummy:/code/vendor/ ./vendor
17+
*/
18+
return [
19+
'target_php_version' => '8.0',
20+
'directory_list' => [
21+
'./bot/',
22+
'./vendor/'
23+
],
24+
'exclude_analysis_directory_list' => [
25+
'./vendor/'
26+
],
27+
'backward_compatibility_checks' => true,
28+
'plugins' => [
29+
'AlwaysReturnPlugin',
30+
'DollarDollarPlugin',
31+
'DuplicateArrayKeyPlugin',
32+
'DuplicateExpressionPlugin',
33+
'PregRegexCheckerPlugin',
34+
'PrintfCheckerPlugin',
35+
'SleepCheckerPlugin',
36+
'UnreachableCodePlugin',
37+
'UseReturnValuePlugin',
38+
'EmptyStatementListPlugin',
39+
'LoopVariableReusePlugin',
40+
],
41+
'suppress_issue_types' => [
42+
'PhanTypeArraySuspiciousNullable'
43+
]
44+
];

Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM kimbtechnologies/php_nginx:latest
1+
FROM kimbtechnologies/php_nginx:8-latest
22

33
# copy into webroot
44
COPY ./other/hook.php /php-code/hook.php

VERSION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
latest
2-
0.1.1
2+
0.1.2
33
0.1
44
0

bot/Commands/Message/GenericmessageCommand.php

-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ public function execute(): ServerResponse
101101
return $this->replyToChat($th->getReplyText(), $opts);
102102
default:
103103
return $this->replyToChat('Unknown message handler – this should not have happened!');
104-
break;
105104
}
106105

107106
$session->setTemp('messageHandler', false);

bot/Commands/StartCommand.php

-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121

2222
use Longman\TelegramBot\Commands\SystemCommand;
2323
use Longman\TelegramBot\Entities\ServerResponse;
24-
use Longman\TelegramBot\Exception\TelegramException;
2524

2625
class StartCommand extends SystemCommand
2726
{

bot/Commands/TaskCommand.php

-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121

2222
use Longman\TelegramBot\Commands\SystemCommand;
2323
use Longman\TelegramBot\Entities\ServerResponse;
24-
use Longman\TelegramBot\Exception\TelegramException;
2524

2625

2726
class TaskCommand extends SystemCommand

bot/Commands/TttCommand.php

-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121

2222
use Longman\TelegramBot\Commands\SystemCommand;
2323
use Longman\TelegramBot\Entities\ServerResponse;
24-
use Longman\TelegramBot\Exception\TelegramException;
2524

2625
class TttCommand extends SystemCommand
2726
{

bot/classes/JSONReader.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public function __construct( $filename, $lockex = false, $otherpath = ''){
6060
$this->filehandler = fopen( $this->filepath . '.lock', 'c+' );
6161
if( !flock( $this->filehandler, $lockex ? LOCK_EX : LOCK_SH ) ){
6262
// error
63-
throw new Exception('Unable to lock file!');
63+
throw new \Exception('Unable to lock file!');
6464
}
6565

6666
//open file
@@ -78,7 +78,7 @@ public function __construct( $filename, $lockex = false, $otherpath = ''){
7878
}
7979
else{
8080
//error
81-
throw new Exception('Unable to find file or folder!');
81+
throw new \Exception('Unable to find file or folder!');
8282
}
8383

8484
// no data => empty array
@@ -92,7 +92,7 @@ public function __construct( $filename, $lockex = false, $otherpath = ''){
9292
$this->data = json_decode( $this->data, true);
9393
//error, if no json etc.
9494
if( !is_array( $this->data ) ){
95-
throw new Exception('Zombiefile!');
95+
throw new \Exception('Zombiefile!');
9696
}
9797

9898
//Check if file is writeable?
@@ -194,7 +194,7 @@ public function getValue( array $index, bool $exception = false ){
194194
else{
195195
//Exception?
196196
if( $exception ){
197-
throw new Exception( "Unknown Index" );
197+
throw new \Exception( "Unknown Index" );
198198
}
199199
//Fehler
200200
return false;

bot/classes/SettingsHelper.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public static function syncStep(Session $session, string $text) {
3232
break;
3333

3434
case "Server URI:\t\t":
35-
if( !@filter_var($text, FILTER_VALIDATE_URL, FILTER_FLAG_HOST_REQUIRED | FILTER_FLAG_SCHEME_REQUIRED)
35+
if( !@filter_var($text, FILTER_VALIDATE_URL)
3636
|| substr($text, 0, 4) !== 'http'
3737
|| strpos($text, 'localhost') !== false
3838
|| strpos($text, ':9000') !== false

0 commit comments

Comments
 (0)