From 1192b8bdf1cbdb9506198150ea6f89604c0b2364 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Thu, 9 Jan 2020 20:09:33 +0000 Subject: [PATCH 1/4] bootstrap: add PhpDoc to critical_error to make phpstan happy it wants phpdoc or typehints, and we can't provide typehints because bootstrap needs to be compatible with old PHP versions. --- src/pocketmine/PocketMine.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/pocketmine/PocketMine.php b/src/pocketmine/PocketMine.php index f04b6ceee..c1ab0aafc 100644 --- a/src/pocketmine/PocketMine.php +++ b/src/pocketmine/PocketMine.php @@ -36,6 +36,10 @@ namespace pocketmine { const MIN_PHP_VERSION = "7.2.0"; + /** + * @param string $message + * @return void + */ function critical_error($message){ echo "[ERROR] $message" . PHP_EOL; } From c85f4256c76e0b6502f687ffbda2c9dcfbfc4a56 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Thu, 9 Jan 2020 20:10:15 +0000 Subject: [PATCH 2/4] phpstan: enable MissingFunctionParameterTypehintRule --- tests/phpstan/configs/gradual-level6.neon | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/phpstan/configs/gradual-level6.neon b/tests/phpstan/configs/gradual-level6.neon index 36538e143..5e444dc7f 100644 --- a/tests/phpstan/configs/gradual-level6.neon +++ b/tests/phpstan/configs/gradual-level6.neon @@ -5,7 +5,7 @@ parameters: checkMissingTypehints: true rules: - #- PHPStan\Rules\Functions\MissingFunctionParameterTypehintRule + - PHPStan\Rules\Functions\MissingFunctionParameterTypehintRule #- PHPStan\Rules\Functions\MissingFunctionReturnTypehintRule #- PHPStan\Rules\Methods\MissingMethodParameterTypehintRule #- PHPStan\Rules\Methods\MissingMethodReturnTypehintRule From 64b5db4bf2b6f3b5fd33c5be82443b0ac03f9dc9 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Thu, 9 Jan 2020 20:13:53 +0000 Subject: [PATCH 3/4] bootstrap: add some @return annotations for phpstan --- src/pocketmine/PocketMine.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/pocketmine/PocketMine.php b/src/pocketmine/PocketMine.php index c1ab0aafc..650d5942f 100644 --- a/src/pocketmine/PocketMine.php +++ b/src/pocketmine/PocketMine.php @@ -121,6 +121,10 @@ namespace pocketmine { return $messages; } + /** + * @param \Logger $logger + * @return void + */ function emit_performance_warnings(\Logger $logger){ if(extension_loaded("xdebug")){ $logger->warning("Xdebug extension is enabled. This has a major impact on performance."); @@ -136,6 +140,9 @@ namespace pocketmine { } } + /** + * @return void + */ function set_ini_entries(){ ini_set("allow_url_fopen", '1'); ini_set("display_errors", '1'); @@ -144,6 +151,9 @@ namespace pocketmine { ini_set('assert.exception', '1'); } + /** + * @return void + */ function server(){ if(count($messages = check_platform_dependencies()) > 0){ echo PHP_EOL; From 039478223e7e0cf758a322a281d725103c51294f Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Thu, 9 Jan 2020 20:14:15 +0000 Subject: [PATCH 4/4] phpstan: enable MissingFunctionReturnTypehintRule --- tests/phpstan/configs/gradual-level6.neon | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/phpstan/configs/gradual-level6.neon b/tests/phpstan/configs/gradual-level6.neon index 5e444dc7f..f96da02ef 100644 --- a/tests/phpstan/configs/gradual-level6.neon +++ b/tests/phpstan/configs/gradual-level6.neon @@ -6,7 +6,7 @@ parameters: rules: - PHPStan\Rules\Functions\MissingFunctionParameterTypehintRule - #- PHPStan\Rules\Functions\MissingFunctionReturnTypehintRule + - PHPStan\Rules\Functions\MissingFunctionReturnTypehintRule #- PHPStan\Rules\Methods\MissingMethodParameterTypehintRule #- PHPStan\Rules\Methods\MissingMethodReturnTypehintRule - PHPStan\Rules\Properties\MissingPropertyTypehintRule