stupidJsonDecodeFunc = (new \ReflectionMethod(InGamePacketHandler::class, 'stupid_json_decode'))->getClosure(); } /** * @return mixed[][] * @phpstan-return list */ public function stupidJsonDecodeProvider() : array{ return [ ["[\n \"a\",\"b,c,d,e\\\" \",,0,1,2, false, 0.001]", ['a', 'b,c,d,e" ', '', 0, 1, 2, false, 0.001]], ["0", 0], ["false", false], ["NULL", null], ['["\",,\"word","a\",,\"word2",]', ['",,"word', 'a",,"word2', '']], ['["\",,\"word","a\",,\"word2",""]', ['",,"word', 'a",,"word2', '']], ['["Hello,, PocketMine"]', ['Hello,, PocketMine']], ['[,]', ['', '']], ['[]', []] ]; } /** * @dataProvider stupidJsonDecodeProvider * * @param string $brokenJson * @param mixed $expect * * @throws \ReflectionException */ public function testStupidJsonDecode(string $brokenJson, $expect) : void{ $decoded = ($this->stupidJsonDecodeFunc)($brokenJson, true); self::assertEquals($expect, $decoded); } }