Merge branch 'stable' into next-minor

This commit is contained in:
Dylan K. Taylor 2020-05-06 20:25:11 +01:00
commit 717b866605
7 changed files with 71 additions and 37 deletions

View File

@ -38,7 +38,7 @@
"ocramius/package-versions": "^1.5"
},
"require-dev": {
"phpstan/phpstan": "^0.12.19",
"phpstan/phpstan": "^0.12.22",
"irstea/phpunit-shim": "^8.5",
"phpstan/phpstan-phpunit": "^0.12.6",
"phpstan/phpstan-strict-rules": "^0.12.2"

12
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "d717744d5a481a98d003220e3e6d932b",
"content-hash": "d3e3f1bbaf2a7dd3b214287ba2acdff8",
"packages": [
{
"name": "adhocore/json-comment",
@ -529,16 +529,16 @@
},
{
"name": "phpstan/phpstan",
"version": "0.12.19",
"version": "0.12.23",
"source": {
"type": "git",
"url": "https://github.com/phpstan/phpstan.git",
"reference": "054f6d76b12ba9a6c13a5a8d5fcdf51219615f4d"
"reference": "71e529efced79e055fa8318b692e7f7d03ea4e75"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/054f6d76b12ba9a6c13a5a8d5fcdf51219615f4d",
"reference": "054f6d76b12ba9a6c13a5a8d5fcdf51219615f4d",
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/71e529efced79e055fa8318b692e7f7d03ea4e75",
"reference": "71e529efced79e055fa8318b692e7f7d03ea4e75",
"shasum": ""
},
"require": {
@ -581,7 +581,7 @@
"type": "tidelift"
}
],
"time": "2020-04-19T20:35:10+00:00"
"time": "2020-05-05T12:55:44+00:00"
},
{
"name": "phpstan/phpstan-phpunit",

View File

@ -297,11 +297,11 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
public const DATA_FLAG_OVER_SCAFFOLDING = 69;
public const DATA_FLAG_FALL_THROUGH_SCAFFOLDING = 70;
public const DATA_FLAG_BLOCKING = 71; //shield
public const DATA_FLAG_DISABLE_BLOCKING = 72;
//73 is set when a player is attacked while using shield, unclear on purpose
//74 related to shield usage, needs further investigation
public const DATA_FLAG_TRANSITION_BLOCKING = 72;
public const DATA_FLAG_BLOCKED_USING_SHIELD = 73;
public const DATA_FLAG_BLOCKED_USING_DAMAGED_SHIELD = 74;
public const DATA_FLAG_SLEEPING = 75;
//76 related to sleeping, unclear usage
public const DATA_FLAG_WANTS_TO_WAKE = 76;
public const DATA_FLAG_TRADE_INTEREST = 77;
public const DATA_FLAG_DOOR_BREAKER = 78; //...
public const DATA_FLAG_BREAKING_OBSTRUCTION = 79;
@ -311,8 +311,12 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
public const DATA_FLAG_ROARING = 83;
public const DATA_FLAG_DELAYED_ATTACKING = 84;
public const DATA_FLAG_AVOIDING_MOBS = 85;
//86 used by RangedAttackGoal
//87 used by NearestAttackableTargetGoal
public const DATA_FLAG_FACING_TARGET_TO_RANGE_ATTACK = 86;
public const DATA_FLAG_HIDDEN_WHEN_INVISIBLE = 87; //??????????????????
public const DATA_FLAG_IS_IN_UI = 88;
public const DATA_FLAG_STALKING = 89;
public const DATA_FLAG_EMOTING = 90;
public const DATA_FLAG_CELEBRATING = 91;
public const DATA_PLAYER_FLAG_SLEEP = 1;
public const DATA_PLAYER_FLAG_DEAD = 2; //TODO: CHECK

View File

@ -614,7 +614,11 @@ class Utils{
* @return string[] an array of tagName => tag value. If the tag has no value, an empty string is used as the value.
*/
public static function parseDocComment(string $docComment) : array{
preg_match_all('/(*ANYCRLF)^[\t ]*\* @([a-zA-Z]+)(?:[\t ]+(.+))?[\t ]*$/m', $docComment, $matches);
$rawDocComment = substr($docComment, 3, -2); //remove the opening and closing markers
if($rawDocComment === false){ //usually empty doc comment, but this is safer and statically analysable
return [];
}
preg_match_all('/(*ANYCRLF)^[\t ]*(?:\* )?@([a-zA-Z]+)(?:[\t ]+(.+?))?[\t ]*$/m', $rawDocComment, $matches);
$result = array_combine($matches[1], $matches[2]);
if($result === false) throw new AssumptionFailedError("array_combine() doesn't return false with two equal-sized arrays");

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
DIR="$(cd -P "$( dirname "${BASH_SOURCE[0]}" )" && pwd)"
cd "$DIR"

View File

@ -16,22 +16,22 @@ parameters:
path: ../../../src/pocketmine/command/CommandReader.php
-
message: "#^Default value of the parameter \\#4 \\$min \\(\\-30000000\\) of method pocketmine\\\\command\\\\defaults\\\\VanillaCommand\\:\\:getRelativeDouble\\(\\) is incompatible with type float\\.$#"
message: "#^Default value of the parameter \\#4 \\$min \\(int\\) of method pocketmine\\\\command\\\\defaults\\\\VanillaCommand\\:\\:getRelativeDouble\\(\\) is incompatible with type float\\.$#"
count: 1
path: ../../../src/pocketmine/command/defaults/VanillaCommand.php
-
message: "#^Default value of the parameter \\#5 \\$max \\(30000000\\) of method pocketmine\\\\command\\\\defaults\\\\VanillaCommand\\:\\:getRelativeDouble\\(\\) is incompatible with type float\\.$#"
message: "#^Default value of the parameter \\#5 \\$max \\(int\\) of method pocketmine\\\\command\\\\defaults\\\\VanillaCommand\\:\\:getRelativeDouble\\(\\) is incompatible with type float\\.$#"
count: 1
path: ../../../src/pocketmine/command/defaults/VanillaCommand.php
-
message: "#^Default value of the parameter \\#3 \\$min \\(\\-30000000\\) of method pocketmine\\\\command\\\\defaults\\\\VanillaCommand\\:\\:getDouble\\(\\) is incompatible with type float\\.$#"
message: "#^Default value of the parameter \\#3 \\$min \\(int\\) of method pocketmine\\\\command\\\\defaults\\\\VanillaCommand\\:\\:getDouble\\(\\) is incompatible with type float\\.$#"
count: 1
path: ../../../src/pocketmine/command/defaults/VanillaCommand.php
-
message: "#^Default value of the parameter \\#4 \\$max \\(30000000\\) of method pocketmine\\\\command\\\\defaults\\\\VanillaCommand\\:\\:getDouble\\(\\) is incompatible with type float\\.$#"
message: "#^Default value of the parameter \\#4 \\$max \\(int\\) of method pocketmine\\\\command\\\\defaults\\\\VanillaCommand\\:\\:getDouble\\(\\) is incompatible with type float\\.$#"
count: 1
path: ../../../src/pocketmine/command/defaults/VanillaCommand.php
@ -46,82 +46,82 @@ parameters:
path: ../../../src/pocketmine/level/format/io/region/RegionLoader.php
-
message: "#^Default value of the parameter \\#4 \\$expansion \\(1\\) of method pocketmine\\\\level\\\\generator\\\\noise\\\\Perlin\\:\\:__construct\\(\\) is incompatible with type float\\.$#"
message: "#^Default value of the parameter \\#4 \\$expansion \\(int\\) of method pocketmine\\\\level\\\\generator\\\\noise\\\\Perlin\\:\\:__construct\\(\\) is incompatible with type float\\.$#"
count: 1
path: ../../../src/pocketmine/level/generator/noise/Perlin.php
-
message: "#^Default value of the parameter \\#4 \\$expansion \\(1\\) of method pocketmine\\\\level\\\\generator\\\\noise\\\\Simplex\\:\\:__construct\\(\\) is incompatible with type float\\.$#"
message: "#^Default value of the parameter \\#4 \\$expansion \\(int\\) of method pocketmine\\\\level\\\\generator\\\\noise\\\\Simplex\\:\\:__construct\\(\\) is incompatible with type float\\.$#"
count: 1
path: ../../../src/pocketmine/level/generator/noise/Simplex.php
-
message: "#^Default value of the parameter \\#2 \\$pitch \\(0\\) of method pocketmine\\\\level\\\\sound\\\\AnvilBreakSound\\:\\:__construct\\(\\) is incompatible with type float\\.$#"
message: "#^Default value of the parameter \\#2 \\$pitch \\(int\\) of method pocketmine\\\\level\\\\sound\\\\AnvilBreakSound\\:\\:__construct\\(\\) is incompatible with type float\\.$#"
count: 1
path: ../../../src/pocketmine/level/sound/AnvilBreakSound.php
-
message: "#^Default value of the parameter \\#2 \\$pitch \\(0\\) of method pocketmine\\\\level\\\\sound\\\\AnvilFallSound\\:\\:__construct\\(\\) is incompatible with type float\\.$#"
message: "#^Default value of the parameter \\#2 \\$pitch \\(int\\) of method pocketmine\\\\level\\\\sound\\\\AnvilFallSound\\:\\:__construct\\(\\) is incompatible with type float\\.$#"
count: 1
path: ../../../src/pocketmine/level/sound/AnvilFallSound.php
-
message: "#^Default value of the parameter \\#2 \\$pitch \\(0\\) of method pocketmine\\\\level\\\\sound\\\\AnvilUseSound\\:\\:__construct\\(\\) is incompatible with type float\\.$#"
message: "#^Default value of the parameter \\#2 \\$pitch \\(int\\) of method pocketmine\\\\level\\\\sound\\\\AnvilUseSound\\:\\:__construct\\(\\) is incompatible with type float\\.$#"
count: 1
path: ../../../src/pocketmine/level/sound/AnvilUseSound.php
-
message: "#^Default value of the parameter \\#2 \\$pitch \\(0\\) of method pocketmine\\\\level\\\\sound\\\\BlazeShootSound\\:\\:__construct\\(\\) is incompatible with type float\\.$#"
message: "#^Default value of the parameter \\#2 \\$pitch \\(int\\) of method pocketmine\\\\level\\\\sound\\\\BlazeShootSound\\:\\:__construct\\(\\) is incompatible with type float\\.$#"
count: 1
path: ../../../src/pocketmine/level/sound/BlazeShootSound.php
-
message: "#^Default value of the parameter \\#2 \\$pitch \\(0\\) of method pocketmine\\\\level\\\\sound\\\\ClickSound\\:\\:__construct\\(\\) is incompatible with type float\\.$#"
message: "#^Default value of the parameter \\#2 \\$pitch \\(int\\) of method pocketmine\\\\level\\\\sound\\\\ClickSound\\:\\:__construct\\(\\) is incompatible with type float\\.$#"
count: 1
path: ../../../src/pocketmine/level/sound/ClickSound.php
-
message: "#^Default value of the parameter \\#2 \\$pitch \\(0\\) of method pocketmine\\\\level\\\\sound\\\\DoorBumpSound\\:\\:__construct\\(\\) is incompatible with type float\\.$#"
message: "#^Default value of the parameter \\#2 \\$pitch \\(int\\) of method pocketmine\\\\level\\\\sound\\\\DoorBumpSound\\:\\:__construct\\(\\) is incompatible with type float\\.$#"
count: 1
path: ../../../src/pocketmine/level/sound/DoorBumpSound.php
-
message: "#^Default value of the parameter \\#2 \\$pitch \\(0\\) of method pocketmine\\\\level\\\\sound\\\\DoorCrashSound\\:\\:__construct\\(\\) is incompatible with type float\\.$#"
message: "#^Default value of the parameter \\#2 \\$pitch \\(int\\) of method pocketmine\\\\level\\\\sound\\\\DoorCrashSound\\:\\:__construct\\(\\) is incompatible with type float\\.$#"
count: 1
path: ../../../src/pocketmine/level/sound/DoorCrashSound.php
-
message: "#^Default value of the parameter \\#2 \\$pitch \\(0\\) of method pocketmine\\\\level\\\\sound\\\\DoorSound\\:\\:__construct\\(\\) is incompatible with type float\\.$#"
message: "#^Default value of the parameter \\#2 \\$pitch \\(int\\) of method pocketmine\\\\level\\\\sound\\\\DoorSound\\:\\:__construct\\(\\) is incompatible with type float\\.$#"
count: 1
path: ../../../src/pocketmine/level/sound/DoorSound.php
-
message: "#^Default value of the parameter \\#2 \\$pitch \\(0\\) of method pocketmine\\\\level\\\\sound\\\\FizzSound\\:\\:__construct\\(\\) is incompatible with type float\\.$#"
message: "#^Default value of the parameter \\#2 \\$pitch \\(int\\) of method pocketmine\\\\level\\\\sound\\\\FizzSound\\:\\:__construct\\(\\) is incompatible with type float\\.$#"
count: 1
path: ../../../src/pocketmine/level/sound/FizzSound.php
-
message: "#^Default value of the parameter \\#3 \\$pitch \\(0\\) of method pocketmine\\\\level\\\\sound\\\\GenericSound\\:\\:__construct\\(\\) is incompatible with type float\\.$#"
message: "#^Default value of the parameter \\#3 \\$pitch \\(int\\) of method pocketmine\\\\level\\\\sound\\\\GenericSound\\:\\:__construct\\(\\) is incompatible with type float\\.$#"
count: 1
path: ../../../src/pocketmine/level/sound/GenericSound.php
-
message: "#^Default value of the parameter \\#2 \\$pitch \\(0\\) of method pocketmine\\\\level\\\\sound\\\\GhastShootSound\\:\\:__construct\\(\\) is incompatible with type float\\.$#"
message: "#^Default value of the parameter \\#2 \\$pitch \\(int\\) of method pocketmine\\\\level\\\\sound\\\\GhastShootSound\\:\\:__construct\\(\\) is incompatible with type float\\.$#"
count: 1
path: ../../../src/pocketmine/level/sound/GhastShootSound.php
-
message: "#^Default value of the parameter \\#2 \\$pitch \\(0\\) of method pocketmine\\\\level\\\\sound\\\\GhastSound\\:\\:__construct\\(\\) is incompatible with type float\\.$#"
message: "#^Default value of the parameter \\#2 \\$pitch \\(int\\) of method pocketmine\\\\level\\\\sound\\\\GhastSound\\:\\:__construct\\(\\) is incompatible with type float\\.$#"
count: 1
path: ../../../src/pocketmine/level/sound/GhastSound.php
-
message: "#^Default value of the parameter \\#2 \\$pitch \\(0\\) of method pocketmine\\\\level\\\\sound\\\\LaunchSound\\:\\:__construct\\(\\) is incompatible with type float\\.$#"
message: "#^Default value of the parameter \\#2 \\$pitch \\(int\\) of method pocketmine\\\\level\\\\sound\\\\LaunchSound\\:\\:__construct\\(\\) is incompatible with type float\\.$#"
count: 1
path: ../../../src/pocketmine/level/sound/LaunchSound.php
-
message: "#^Default value of the parameter \\#2 \\$pitch \\(0\\) of method pocketmine\\\\level\\\\sound\\\\PopSound\\:\\:__construct\\(\\) is incompatible with type float\\.$#"
message: "#^Default value of the parameter \\#2 \\$pitch \\(int\\) of method pocketmine\\\\level\\\\sound\\\\PopSound\\:\\:__construct\\(\\) is incompatible with type float\\.$#"
count: 1
path: ../../../src/pocketmine/level/sound/PopSound.php
@ -131,9 +131,9 @@ parameters:
path: ../../../src/pocketmine/network/mcpe/protocol/DataPacket.php
-
message: "#^Strict comparison using \\!\\=\\= between string and false will always evaluate to true\\.$#"
message: "#^Strict comparison using \\=\\=\\= between string and false will always evaluate to false\\.$#"
count: 1
path: ../../../src/pocketmine/utils/Timezone.php
path: ../../../src/pocketmine/utils/Utils.php
-
message: "#^Call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertNotNull\\(\\) with int and string will always evaluate to true\\.$#"

View File

@ -63,6 +63,32 @@ class UtilsTest extends TestCase{
self::assertEquals("HIGHEST", $tags["priority"]);
}
/**
* @return string[][]
* @phpstan-return list<array{string}>
*/
public function parseDocCommentOneLineProvider() : array{
return [
["/** @ignoreCancelled true dummy */"],
["/**@ignoreCancelled true dummy*/"],
["/** @ignoreCancelled true dummy */"]
];
}
/**
* @dataProvider parseDocCommentOneLineProvider
*/
public function testParseOneLineDocComment(string $comment) : void{
$tags = Utils::parseDocComment($comment);
self::assertArrayHasKey("ignoreCancelled", $tags);
self::assertEquals("true dummy", $tags["ignoreCancelled"]);
}
public function testParseEmptyDocComment() : void{
$tags = Utils::parseDocComment("");
self::assertCount(0, $tags);
}
public function testNamespacedNiceClosureName() : void{
//be careful with this test. The closure has to be declared on the same line as the assertion.
self::assertSame('closure@' . Utils::cleanPath(__FILE__) . '#L' . __LINE__, Utils::getNiceClosureName(function() : void{}));