Merge commit 'a34f3261c'

# Conflicts:
#	resources/vanilla
#	src/event/entity/EntityExplodeEvent.php
#	src/pocketmine/event/block/SignChangeEvent.php
#	src/utils/Utils.php
This commit is contained in:
Dylan K. Taylor
2020-07-04 22:39:40 +01:00
6 changed files with 30 additions and 0 deletions

View File

@@ -501,6 +501,21 @@ class Utils{
}
}
/**
* @phpstan-template TMemberType
* @phpstan-param array<mixed, TMemberType> $array
* @phpstan-param \Closure(TMemberType) : void $validator
*/
public static function validateArrayValueType(array $array, \Closure $validator) : void{
foreach($array as $k => $v){
try{
$validator($v);
}catch(\TypeError $e){
throw new \TypeError("Incorrect type of element at \"$k\": " . $e->getMessage(), 0, $e);
}
}
}
public static function checkUTF8(string $string) : void{
if(!mb_check_encoding($string, 'UTF-8')){
throw new \InvalidArgumentException("Text must be valid UTF-8");