From a3202661b52c5221dd908dc6f05394de09f968d8 Mon Sep 17 00:00:00 2001 From: paranoiq Date: Tue, 26 Jul 2022 16:26:34 +0200 Subject: [PATCH] Fixed CS etc --- build/custom.dic | 2 ++ build/phpstan.neon | 4 ++-- src/Io/ContentType/ContentTypeDetector.php | 9 +++++---- src/Time/DateOrTime.php | 2 +- src/common/Obj.php | 13 ++----------- src/common/Re.php | 17 +++++++++-------- 6 files changed, 21 insertions(+), 26 deletions(-) diff --git a/build/custom.dic b/build/custom.dic index b5b95cd1..0e333e20 100644 --- a/build/custom.dic +++ b/build/custom.dic @@ -48,6 +48,7 @@ wildcard armscii ascii catalan +codepoint csp csrf cygwin @@ -74,6 +75,7 @@ tcp tftp ucs uhc +unicode unix uri ux diff --git a/build/phpstan.neon b/build/phpstan.neon index 7cf48058..8560ddd8 100644 --- a/build/phpstan.neon +++ b/build/phpstan.neon @@ -51,5 +51,5 @@ parameters: # PHP 7 -> 8 - '~expects (Curl(Multi)?Handle|resource), Curl(Multi)?Handle\|resource given~' - # PHP 7.1 compatibility (cannot declare interface method with default value) - - '~Call to an undefined method Dogma\\Time\\DateOr(Date)?Time::format\(\)~' + # PHP 8.0 -> 8.1 + - '~finfo\|resource\|null~' \ No newline at end of file diff --git a/src/Io/ContentType/ContentTypeDetector.php b/src/Io/ContentType/ContentTypeDetector.php index 89b8acc3..2d18ff72 100644 --- a/src/Io/ContentType/ContentTypeDetector.php +++ b/src/Io/ContentType/ContentTypeDetector.php @@ -12,13 +12,14 @@ use Dogma\Io\Path; use Dogma\Language\Encoding; use Dogma\StrictBehaviorMixin; -use const FILEINFO_MIME_ENCODING; -use const FILEINFO_MIME_TYPE; +use finfo; use function error_clear_last; use function error_get_last; use function finfo_buffer; use function finfo_file; use function finfo_open; +use const FILEINFO_MIME_ENCODING; +use const FILEINFO_MIME_TYPE; class ContentTypeDetector { @@ -27,10 +28,10 @@ class ContentTypeDetector /** @var string|null */ private $magicFile; - /** @var resource|null */ + /** @var resource|finfo|null */ private $typeHandler; - /** @var resource|null */ + /** @var resource|finfo|null */ private $encodingHandler; public function __construct(?string $magicFile = null) diff --git a/src/Time/DateOrTime.php b/src/Time/DateOrTime.php index 2edb3a2f..7a1c9c8d 100644 --- a/src/Time/DateOrTime.php +++ b/src/Time/DateOrTime.php @@ -16,7 +16,7 @@ interface DateOrTime extends Equalable, Comparable { - //public function format(string $format = ''): string; // PHP 7.2+ + public function format(string $format = ''): string; public function fillValues(DateTimeValues $values): void; diff --git a/src/common/Obj.php b/src/common/Obj.php index 4d5afa73..68fbf6aa 100644 --- a/src/common/Obj.php +++ b/src/common/Obj.php @@ -11,11 +11,10 @@ namespace Dogma; -use function function_exists; -use function hexdec; use function is_object; use function md5; use function spl_object_hash; +use function spl_object_id; use function substr; class Obj @@ -37,15 +36,7 @@ public static function dumpHash($object): string public static function objectId($object): int { if (is_object($object)) { - // PHP >= 7.2 - if (function_exists('spl_object_id')) { - return spl_object_id($object); - } else { - $hash = spl_object_hash($object); - $hash = substr($hash, 8, 8) . substr($hash, 24, 8); - - return (int) hexdec($hash); - } + return spl_object_id($object); } else { return (int) $object; } diff --git a/src/common/Re.php b/src/common/Re.php index 1860148f..080e07da 100644 --- a/src/common/Re.php +++ b/src/common/Re.php @@ -9,13 +9,6 @@ namespace Dogma; -use const PREG_GREP_INVERT; -use const PREG_OFFSET_CAPTURE; -use const PREG_PATTERN_ORDER; -use const PREG_SET_ORDER; -use const PREG_SPLIT_DELIM_CAPTURE; -use const PREG_SPLIT_NO_EMPTY; -use const PREG_SPLIT_OFFSET_CAPTURE; use function array_keys; use function array_values; use function count; @@ -31,6 +24,14 @@ use function preg_replace_callback; use function preg_split; use function strlen; +use const PREG_GREP_INVERT; +use const PREG_OFFSET_CAPTURE; +use const PREG_PATTERN_ORDER; +use const PREG_SET_ORDER; +use const PREG_SPLIT_DELIM_CAPTURE; +use const PREG_SPLIT_NO_EMPTY; +use const PREG_SPLIT_OFFSET_CAPTURE; +use const PREG_UNMATCHED_AS_NULL; /** * Strings manipulation with regular expressions @@ -47,7 +48,7 @@ class Re public const CAPTURE_DELIMITER = PREG_SPLIT_DELIM_CAPTURE; public const FILTER_EMPTY = PREG_SPLIT_NO_EMPTY; - //public const UNMATCHED_AS_NULL = PREG_UNMATCHED_AS_NULL; // PHP 7.2 + public const UNMATCHED_AS_NULL = PREG_UNMATCHED_AS_NULL; public const INVERT = PREG_GREP_INVERT;