From 31465525e33f8991e56584d8420da9b7764f51df Mon Sep 17 00:00:00 2001 From: Rush2929 <76860328+Rush2929@users.noreply.github.com> Date: Tue, 13 Dec 2022 02:12:33 +0900 Subject: [PATCH] Fixed PHP-CS-Fixer not import global constants. (#5449) --- .php-cs-fixer.php | 3 +++ build/generate-registry-annotations.php | 1 + build/server-phar.php | 1 + src/network/mcpe/encryption/EncryptionUtils.php | 1 + src/network/mcpe/raklib/RakLibInterface.php | 1 + src/network/query/DedicatedQueryNetworkInterface.php | 1 + src/network/upnp/UPnP.php | 6 ++++++ src/plugin/PluginBase.php | 1 + src/utils/BroadcastLoggerForwarder.php | 1 + src/utils/Config.php | 1 + tools/compact-regions.php | 4 ++++ tools/decode-crashdump.php | 2 ++ tools/ping-server.php | 4 ++++ 13 files changed, 27 insertions(+) diff --git a/.php-cs-fixer.php b/.php-cs-fixer.php index a501b110d..32af1ef48 100644 --- a/.php-cs-fixer.php +++ b/.php-cs-fixer.php @@ -66,6 +66,9 @@ BODY, ], 'indentation_type' => true, 'logical_operators' => true, + 'native_constant_invocation' => [ + 'scope' => 'namespaced' + ], 'native_function_invocation' => [ 'scope' => 'namespaced', 'include' => ['@all'], diff --git a/build/generate-registry-annotations.php b/build/generate-registry-annotations.php index 1198db207..f17e39170 100644 --- a/build/generate-registry-annotations.php +++ b/build/generate-registry-annotations.php @@ -39,6 +39,7 @@ use function sprintf; use function str_replace; use function substr; use const SORT_STRING; +use const STDERR; if(count($argv) !== 2){ fwrite(STDERR, "Provide a path to process\n"); diff --git a/build/server-phar.php b/build/server-phar.php index cc404b682..0665c89d5 100644 --- a/build/server-phar.php +++ b/build/server-phar.php @@ -40,6 +40,7 @@ use function rtrim; use function sprintf; use function str_replace; use function unlink; +use const DIRECTORY_SEPARATOR; use const PHP_EOL; require dirname(__DIR__) . '/vendor/autoload.php'; diff --git a/src/network/mcpe/encryption/EncryptionUtils.php b/src/network/mcpe/encryption/EncryptionUtils.php index cb56562db..920c54a7e 100644 --- a/src/network/mcpe/encryption/EncryptionUtils.php +++ b/src/network/mcpe/encryption/EncryptionUtils.php @@ -34,6 +34,7 @@ use function openssl_digest; use function openssl_error_string; use function openssl_pkey_derive; use function str_pad; +use const STR_PAD_LEFT; final class EncryptionUtils{ diff --git a/src/network/mcpe/raklib/RakLibInterface.php b/src/network/mcpe/raklib/RakLibInterface.php index 33a50ac56..bf1f75c26 100644 --- a/src/network/mcpe/raklib/RakLibInterface.php +++ b/src/network/mcpe/raklib/RakLibInterface.php @@ -52,6 +52,7 @@ use function mt_rand; use function random_bytes; use function rtrim; use function substr; +use const PHP_INT_MAX; class RakLibInterface implements ServerEventListener, AdvancedNetworkInterface{ /** diff --git a/src/network/query/DedicatedQueryNetworkInterface.php b/src/network/query/DedicatedQueryNetworkInterface.php index c2d27029c..2917ba0ee 100644 --- a/src/network/query/DedicatedQueryNetworkInterface.php +++ b/src/network/query/DedicatedQueryNetworkInterface.php @@ -40,6 +40,7 @@ use function strlen; use function time; use function trim; use const AF_INET; +use const AF_INET6; use const IPPROTO_IPV6; use const IPV6_V6ONLY; use const PHP_INT_MAX; diff --git a/src/network/upnp/UPnP.php b/src/network/upnp/UPnP.php index e1d059339..2d48a2db8 100644 --- a/src/network/upnp/UPnP.php +++ b/src/network/upnp/UPnP.php @@ -73,6 +73,12 @@ use function sprintf; use function strlen; use function trim; use const AF_INET; +use const PREG_BACKTRACK_LIMIT_ERROR; +use const PREG_BAD_UTF8_ERROR; +use const PREG_BAD_UTF8_OFFSET_ERROR; +use const PREG_INTERNAL_ERROR; +use const PREG_JIT_STACKLIMIT_ERROR; +use const PREG_RECURSION_LIMIT_ERROR; use const SO_RCVTIMEO; use const SOCK_DGRAM; use const SOCKET_ETIMEDOUT; diff --git a/src/plugin/PluginBase.php b/src/plugin/PluginBase.php index 175ac0741..a4c0f6ba4 100644 --- a/src/plugin/PluginBase.php +++ b/src/plugin/PluginBase.php @@ -45,6 +45,7 @@ use function stream_copy_to_stream; use function strpos; use function strtolower; use function trim; +use const DIRECTORY_SEPARATOR; abstract class PluginBase implements Plugin, CommandExecutor{ private bool $isEnabled = false; diff --git a/src/utils/BroadcastLoggerForwarder.php b/src/utils/BroadcastLoggerForwarder.php index a015615b5..1900421fc 100644 --- a/src/utils/BroadcastLoggerForwarder.php +++ b/src/utils/BroadcastLoggerForwarder.php @@ -29,6 +29,7 @@ use pocketmine\lang\Translatable; use pocketmine\permission\PermissibleBase; use pocketmine\permission\PermissibleDelegateTrait; use pocketmine\Server; +use const PHP_INT_MAX; /** * Forwards any messages it receives via sendMessage() to the given logger. Used for forwarding chat messages and diff --git a/src/utils/Config.php b/src/utils/Config.php index 4bfed71b5..617feeacf 100644 --- a/src/utils/Config.php +++ b/src/utils/Config.php @@ -55,6 +55,7 @@ use const CASE_LOWER; use const JSON_BIGINT_AS_STRING; use const JSON_PRETTY_PRINT; use const JSON_THROW_ON_ERROR; +use const YAML_UTF8_ENCODING; /** * Config Class for simple config manipulation of multiple formats. diff --git a/tools/compact-regions.php b/tools/compact-regions.php index beb764060..6959c82fe 100644 --- a/tools/compact-regions.php +++ b/tools/compact-regions.php @@ -43,6 +43,10 @@ use function rename; use function round; use function scandir; use function unlink; +use const PATHINFO_EXTENSION; +use const PHP_BINARY; +use const SCANDIR_SORT_NONE; +use const SORT_NUMERIC; require dirname(__DIR__) . '/vendor/autoload.php'; diff --git a/tools/decode-crashdump.php b/tools/decode-crashdump.php index b73cc201f..26a5d144f 100644 --- a/tools/decode-crashdump.php +++ b/tools/decode-crashdump.php @@ -37,6 +37,8 @@ use function realpath; use function trim; use function zlib_decode; use const FILE_IGNORE_NEW_LINES; +use const JSON_PRETTY_PRINT; +use const JSON_UNESCAPED_SLASHES; use const PHP_EOL; use const STDERR; diff --git a/tools/ping-server.php b/tools/ping-server.php index 83a997bbd..1784d0988 100644 --- a/tools/ping-server.php +++ b/tools/ping-server.php @@ -49,9 +49,13 @@ use function socket_strerror; use function strlen; use function time; use function trim; +use const AF_INET; use const MSG_DONTROUTE; use const PHP_BINARY; use const PHP_INT_MAX; +use const SOCK_DGRAM; +use const SOL_UDP; +use const STDIN; require_once 'vendor/autoload.php';