Merge pull request #14590 from Art4/phpstan-level-2-in-addons

Fix PHPStan errors level 2 in addons
This commit is contained in:
Hypolite Petovan 2024-12-16 09:14:29 -05:00 committed by GitHub
commit 012cce1ac7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 32 additions and 3 deletions

View file

@ -6,13 +6,14 @@ parameters:
level: 2 level: 2
paths: paths:
# - addon/ - addon/
- src/ - src/
excludePaths: excludePaths:
analyse: analyse:
- addon/*/lang/* - addon/*/lang/*
- addon/*/vendor/* - addon/*/vendor/*
- addon/convert/UnitConvertor.php
- addon/pumpio/oauth/* - addon/pumpio/oauth/*
scanDirectories: scanDirectories:
@ -39,3 +40,27 @@ parameters:
# Ignore missing IMAP\Connection class in PHP <= 8.0 # Ignore missing IMAP\Connection class in PHP <= 8.0
message: '(^Parameter .+ has invalid type IMAP\\Connection\.$)' message: '(^Parameter .+ has invalid type IMAP\\Connection\.$)'
path: src path: src
-
# Ignore missing SMTP class in PHPMailer 5.2.21
# see https://github.com/PHPMailer/PHPMailer/blob/v5.2.21/class.smtp.php
message: '(^.+ an unknown class SMTP\.$)'
path: addon/mailstream/phpmailer
-
# Ignore missing SMTP class in PHPMailer 5.2.21
# see https://github.com/PHPMailer/PHPMailer/blob/v5.2.21/class.smtp.php
message: '(^Property .+ has unknown class SMTP as its type\.$)'
path: addon/mailstream/phpmailer
-
# Ignore missing SMTP class in PHPMailer 5.2.21
# see https://github.com/PHPMailer/PHPMailer/blob/v5.2.21/class.smtp.php
message: '(^Method .+ has invalid return type SMTP\.$)'
path: addon/mailstream/phpmailer
-
# Ignore missing SMTP class in PHPMailer 5.2.21
# see https://github.com/PHPMailer/PHPMailer/blob/v5.2.21/class.smtp.php
message: '(^Instantiated class SMTP not found\.$)'
path: addon/mailstream/phpmailer

View file

@ -530,8 +530,12 @@ class Strings
{ {
$shorthand = trim($shorthand); $shorthand = trim($shorthand);
if (is_numeric($shorthand)) { if (ctype_digit($shorthand)) {
return $shorthand; return (int) $shorthand;
}
if ($shorthand === '') {
return 0;
} }
$last = strtolower($shorthand[strlen($shorthand) - 1]); $last = strtolower($shorthand[strlen($shorthand) - 1]);