From 651ef500a3be530f5bf1f72990c711706eab3ca7 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Mon, 13 Jan 2020 10:55:54 +0000 Subject: [PATCH] Make pocketmine\PATH and pocketmine\RESOURCE_PATH always available these are non-dependent on environment, so they can be determined with no external input. This fixes 2 PHPStan issues, fixes some code that couldn't run outside of PM, and makes it easier to write code that depends on PM. --- composer.json | 1 + phpstan.neon.dist | 13 ------------- src/pocketmine/CoreConstants.php | 33 ++++++++++++++++++++++++++++++++ src/pocketmine/PocketMine.php | 10 +--------- 4 files changed, 35 insertions(+), 22 deletions(-) create mode 100644 src/pocketmine/CoreConstants.php diff --git a/composer.json b/composer.json index d9216be1a..dce1d5d53 100644 --- a/composer.json +++ b/composer.json @@ -38,6 +38,7 @@ "": ["src"] }, "files": [ + "src/pocketmine/CoreConstants.php", "src/pocketmine/GlobalConstants.php", "src/pocketmine/VersionInfo.php" ] diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 29ec94a42..67fb6ba11 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -87,11 +87,6 @@ parameters: count: 1 path: src/pocketmine/level/generator/normal/Normal.php - - - message: "#^Used constant pocketmine\\\\RESOURCE_PATH not found\\.$#" - count: 1 - path: src/pocketmine/network/mcpe/protocol/StartGamePacket.php - - message: "#^Constructor of class pocketmine\\\\scheduler\\\\TaskScheduler has an unused parameter \\$logger\\.$#" count: 1 @@ -109,18 +104,10 @@ parameters: message: "#^Constant pocketmine\\\\GIT_COMMIT not found\\.$#" path: src - - - message: "#^Constant pocketmine\\\\PATH not found\\.$#" - path: src - - message: "#^Constant pocketmine\\\\PLUGIN_PATH not found\\.$#" path: src - - - message: "#^Constant pocketmine\\\\RESOURCE_PATH not found\\.$#" - path: src - - message: "#^Constant pocketmine\\\\START_TIME not found\\.$#" path: src diff --git a/src/pocketmine/CoreConstants.php b/src/pocketmine/CoreConstants.php new file mode 100644 index 000000000..53de7326e --- /dev/null +++ b/src/pocketmine/CoreConstants.php @@ -0,0 +1,33 @@ +