mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-06 20:07:09 +00:00
Drop respect/validation
it's not worth this turning into compatibility baggage just so that we can parse plugin_list.yml, especially when we have new ways to handle data parsing coming in the pipeline. For something as small as plugin_list.yml, it's easier (and in this case better too) to just validate it manually (respect/validation was anyway too strict considering it's YAML we're dealing with).
This commit is contained in:
parent
48f809d3fa
commit
8db5732b44
@ -49,7 +49,6 @@
|
|||||||
"pocketmine/snooze": "^0.3.0",
|
"pocketmine/snooze": "^0.3.0",
|
||||||
"pocketmine/spl": "dev-master",
|
"pocketmine/spl": "dev-master",
|
||||||
"ramsey/uuid": "^4.1",
|
"ramsey/uuid": "^4.1",
|
||||||
"respect/validation": "^2.0",
|
|
||||||
"webmozart/path-util": "^2.3"
|
"webmozart/path-util": "^2.3"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
|
206
composer.lock
generated
206
composer.lock
generated
@ -4,7 +4,7 @@
|
|||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"content-hash": "c7a00c5a35d43f307fdba7a588029131",
|
"content-hash": "39ec9b1c108888c32a660f3bc2c400c4",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "adhocore/json-comment",
|
"name": "adhocore/json-comment",
|
||||||
@ -1011,130 +1011,6 @@
|
|||||||
],
|
],
|
||||||
"time": "2021-09-25T23:10:38+00:00"
|
"time": "2021-09-25T23:10:38+00:00"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"name": "respect/stringifier",
|
|
||||||
"version": "0.2.0",
|
|
||||||
"source": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/Respect/Stringifier.git",
|
|
||||||
"reference": "e55af3c8aeaeaa2abb5fa47a58a8e9688cc23b59"
|
|
||||||
},
|
|
||||||
"dist": {
|
|
||||||
"type": "zip",
|
|
||||||
"url": "https://api.github.com/repos/Respect/Stringifier/zipball/e55af3c8aeaeaa2abb5fa47a58a8e9688cc23b59",
|
|
||||||
"reference": "e55af3c8aeaeaa2abb5fa47a58a8e9688cc23b59",
|
|
||||||
"shasum": ""
|
|
||||||
},
|
|
||||||
"require": {
|
|
||||||
"php": ">=7.1"
|
|
||||||
},
|
|
||||||
"require-dev": {
|
|
||||||
"friendsofphp/php-cs-fixer": "^2.8",
|
|
||||||
"malukenho/docheader": "^0.1.7",
|
|
||||||
"phpunit/phpunit": "^6.4"
|
|
||||||
},
|
|
||||||
"type": "library",
|
|
||||||
"autoload": {
|
|
||||||
"psr-4": {
|
|
||||||
"Respect\\Stringifier\\": "src/"
|
|
||||||
},
|
|
||||||
"files": [
|
|
||||||
"src/stringify.php"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"notification-url": "https://packagist.org/downloads/",
|
|
||||||
"license": [
|
|
||||||
"MIT"
|
|
||||||
],
|
|
||||||
"authors": [
|
|
||||||
{
|
|
||||||
"name": "Respect/Stringifier Contributors",
|
|
||||||
"homepage": "https://github.com/Respect/Stringifier/graphs/contributors"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"description": "Converts any value to a string",
|
|
||||||
"homepage": "http://respect.github.io/Stringifier/",
|
|
||||||
"keywords": [
|
|
||||||
"respect",
|
|
||||||
"stringifier",
|
|
||||||
"stringify"
|
|
||||||
],
|
|
||||||
"support": {
|
|
||||||
"issues": "https://github.com/Respect/Stringifier/issues",
|
|
||||||
"source": "https://github.com/Respect/Stringifier/tree/0.2.0"
|
|
||||||
},
|
|
||||||
"time": "2017-12-29T19:39:25+00:00"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "respect/validation",
|
|
||||||
"version": "2.2.3",
|
|
||||||
"source": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/Respect/Validation.git",
|
|
||||||
"reference": "4c21a7ffc9a4915673cb2c2843963919e664e627"
|
|
||||||
},
|
|
||||||
"dist": {
|
|
||||||
"type": "zip",
|
|
||||||
"url": "https://api.github.com/repos/Respect/Validation/zipball/4c21a7ffc9a4915673cb2c2843963919e664e627",
|
|
||||||
"reference": "4c21a7ffc9a4915673cb2c2843963919e664e627",
|
|
||||||
"shasum": ""
|
|
||||||
},
|
|
||||||
"require": {
|
|
||||||
"php": "^7.3 || ^8.0",
|
|
||||||
"respect/stringifier": "^0.2.0",
|
|
||||||
"symfony/polyfill-mbstring": "^1.2"
|
|
||||||
},
|
|
||||||
"require-dev": {
|
|
||||||
"egulias/email-validator": "^3.0",
|
|
||||||
"malukenho/docheader": "^0.1",
|
|
||||||
"mikey179/vfsstream": "^1.6",
|
|
||||||
"phpstan/phpstan": "^0.12",
|
|
||||||
"phpstan/phpstan-deprecation-rules": "^0.12",
|
|
||||||
"phpstan/phpstan-phpunit": "^0.12",
|
|
||||||
"phpunit/phpunit": "^9.3",
|
|
||||||
"psr/http-message": "^1.0",
|
|
||||||
"respect/coding-standard": "^3.0",
|
|
||||||
"squizlabs/php_codesniffer": "^3.5",
|
|
||||||
"symfony/validator": "^3.0||^4.0",
|
|
||||||
"zendframework/zend-validator": "^2.1"
|
|
||||||
},
|
|
||||||
"suggest": {
|
|
||||||
"egulias/email-validator": "Strict (RFC compliant) email validation",
|
|
||||||
"ext-bcmath": "Arbitrary Precision Mathematics",
|
|
||||||
"ext-fileinfo": "File Information",
|
|
||||||
"ext-mbstring": "Multibyte String Functions",
|
|
||||||
"symfony/validator": "Use Symfony validator through Respect\\Validation",
|
|
||||||
"zendframework/zend-validator": "Use Zend Framework validator through Respect\\Validation"
|
|
||||||
},
|
|
||||||
"type": "library",
|
|
||||||
"autoload": {
|
|
||||||
"psr-4": {
|
|
||||||
"Respect\\Validation\\": "library/"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"notification-url": "https://packagist.org/downloads/",
|
|
||||||
"license": [
|
|
||||||
"MIT"
|
|
||||||
],
|
|
||||||
"authors": [
|
|
||||||
{
|
|
||||||
"name": "Respect/Validation Contributors",
|
|
||||||
"homepage": "https://github.com/Respect/Validation/graphs/contributors"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"description": "The most awesome validation engine ever created for PHP",
|
|
||||||
"homepage": "http://respect.github.io/Validation/",
|
|
||||||
"keywords": [
|
|
||||||
"respect",
|
|
||||||
"validation",
|
|
||||||
"validator"
|
|
||||||
],
|
|
||||||
"support": {
|
|
||||||
"issues": "https://github.com/Respect/Validation/issues",
|
|
||||||
"source": "https://github.com/Respect/Validation/tree/2.2.3"
|
|
||||||
},
|
|
||||||
"time": "2021-03-19T14:12:45+00:00"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"name": "symfony/polyfill-ctype",
|
"name": "symfony/polyfill-ctype",
|
||||||
"version": "v1.23.0",
|
"version": "v1.23.0",
|
||||||
@ -1214,86 +1090,6 @@
|
|||||||
],
|
],
|
||||||
"time": "2021-02-19T12:13:01+00:00"
|
"time": "2021-02-19T12:13:01+00:00"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"name": "symfony/polyfill-mbstring",
|
|
||||||
"version": "v1.23.1",
|
|
||||||
"source": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/symfony/polyfill-mbstring.git",
|
|
||||||
"reference": "9174a3d80210dca8daa7f31fec659150bbeabfc6"
|
|
||||||
},
|
|
||||||
"dist": {
|
|
||||||
"type": "zip",
|
|
||||||
"url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/9174a3d80210dca8daa7f31fec659150bbeabfc6",
|
|
||||||
"reference": "9174a3d80210dca8daa7f31fec659150bbeabfc6",
|
|
||||||
"shasum": ""
|
|
||||||
},
|
|
||||||
"require": {
|
|
||||||
"php": ">=7.1"
|
|
||||||
},
|
|
||||||
"suggest": {
|
|
||||||
"ext-mbstring": "For best performance"
|
|
||||||
},
|
|
||||||
"type": "library",
|
|
||||||
"extra": {
|
|
||||||
"branch-alias": {
|
|
||||||
"dev-main": "1.23-dev"
|
|
||||||
},
|
|
||||||
"thanks": {
|
|
||||||
"name": "symfony/polyfill",
|
|
||||||
"url": "https://github.com/symfony/polyfill"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"autoload": {
|
|
||||||
"psr-4": {
|
|
||||||
"Symfony\\Polyfill\\Mbstring\\": ""
|
|
||||||
},
|
|
||||||
"files": [
|
|
||||||
"bootstrap.php"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"notification-url": "https://packagist.org/downloads/",
|
|
||||||
"license": [
|
|
||||||
"MIT"
|
|
||||||
],
|
|
||||||
"authors": [
|
|
||||||
{
|
|
||||||
"name": "Nicolas Grekas",
|
|
||||||
"email": "p@tchwork.com"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Symfony Community",
|
|
||||||
"homepage": "https://symfony.com/contributors"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"description": "Symfony polyfill for the Mbstring extension",
|
|
||||||
"homepage": "https://symfony.com",
|
|
||||||
"keywords": [
|
|
||||||
"compatibility",
|
|
||||||
"mbstring",
|
|
||||||
"polyfill",
|
|
||||||
"portable",
|
|
||||||
"shim"
|
|
||||||
],
|
|
||||||
"support": {
|
|
||||||
"source": "https://github.com/symfony/polyfill-mbstring/tree/v1.23.1"
|
|
||||||
},
|
|
||||||
"funding": [
|
|
||||||
{
|
|
||||||
"url": "https://symfony.com/sponsor",
|
|
||||||
"type": "custom"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"url": "https://github.com/fabpot",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
|
|
||||||
"type": "tidelift"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"time": "2021-05-27T12:26:48+00:00"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"name": "symfony/polyfill-php80",
|
"name": "symfony/polyfill-php80",
|
||||||
"version": "v1.23.1",
|
"version": "v1.23.1",
|
||||||
|
@ -23,15 +23,11 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace pocketmine\plugin;
|
namespace pocketmine\plugin;
|
||||||
|
|
||||||
use Respect\Validation\Exceptions\NestedValidationException;
|
|
||||||
use Respect\Validation\Rules\AllOf;
|
|
||||||
use Respect\Validation\Rules\ArrayType;
|
|
||||||
use Respect\Validation\Rules\Each;
|
|
||||||
use Respect\Validation\Rules\In;
|
|
||||||
use Respect\Validation\Rules\Key;
|
|
||||||
use Respect\Validation\Rules\StringType;
|
|
||||||
use Respect\Validation\Validator;
|
|
||||||
use function array_flip;
|
use function array_flip;
|
||||||
|
use function is_array;
|
||||||
|
use function is_float;
|
||||||
|
use function is_int;
|
||||||
|
use function is_string;
|
||||||
|
|
||||||
class PluginGraylist{
|
class PluginGraylist{
|
||||||
|
|
||||||
@ -70,17 +66,27 @@ class PluginGraylist{
|
|||||||
* @param mixed[] $array
|
* @param mixed[] $array
|
||||||
*/
|
*/
|
||||||
public static function fromArray(array $array) : PluginGraylist{
|
public static function fromArray(array $array) : PluginGraylist{
|
||||||
$validator = new Validator(
|
if(!isset($array["mode"]) || ($array["mode"] !== "whitelist" && $array["mode"] !== "blacklist")){
|
||||||
new Key("mode", new In(['whitelist', 'blacklist'], true), true),
|
throw new \InvalidArgumentException("\"mode\" must be set");
|
||||||
new Key("plugins", new AllOf(new ArrayType(), new Each(new StringType())), true)
|
|
||||||
);
|
|
||||||
$validator->setName('plugin_list.yml');
|
|
||||||
try{
|
|
||||||
$validator->assert($array);
|
|
||||||
}catch(NestedValidationException $e){
|
|
||||||
throw new \InvalidArgumentException($e->getFullMessage(), 0, $e);
|
|
||||||
}
|
}
|
||||||
return new PluginGraylist($array["plugins"], $array["mode"] === 'whitelist');
|
$isWhitelist = match($array["mode"]){
|
||||||
|
"whitelist" => true,
|
||||||
|
"blacklist" => false,
|
||||||
|
default => throw new \InvalidArgumentException("\"mode\" must be either \"whitelist\" or \"blacklist\"")
|
||||||
|
};
|
||||||
|
$plugins = [];
|
||||||
|
if(isset($array["plugins"])){
|
||||||
|
if(!is_array($array["plugins"])){
|
||||||
|
throw new \InvalidArgumentException("\"plugins\" must be an array");
|
||||||
|
}
|
||||||
|
foreach($array["plugins"] as $k => $v){
|
||||||
|
if(!is_string($v) && !is_int($v) && !is_float($v)){
|
||||||
|
throw new \InvalidArgumentException("\"plugins\" contains invalid element at position $k");
|
||||||
|
}
|
||||||
|
$plugins[] = (string) $v;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new PluginGraylist($plugins, $isWhitelist);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -135,11 +135,6 @@ parameters:
|
|||||||
count: 1
|
count: 1
|
||||||
path: ../../../src/plugin/PluginDescription.php
|
path: ../../../src/plugin/PluginDescription.php
|
||||||
|
|
||||||
-
|
|
||||||
message: "#^Parameter \\#1 \\$plugins of class pocketmine\\\\plugin\\\\PluginGraylist constructor expects array\\<string\\>, mixed given\\.$#"
|
|
||||||
count: 1
|
|
||||||
path: ../../../src/plugin/PluginGraylist.php
|
|
||||||
|
|
||||||
-
|
-
|
||||||
message: "#^Parameter \\#2 \\$code of class pocketmine\\\\resourcepacks\\\\ResourcePackException constructor expects int, mixed given\\.$#"
|
message: "#^Parameter \\#2 \\$code of class pocketmine\\\\resourcepacks\\\\ResourcePackException constructor expects int, mixed given\\.$#"
|
||||||
count: 1
|
count: 1
|
||||||
|
Loading…
x
Reference in New Issue
Block a user