mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-06 10:01:53 +00:00
Merge branch '3.5'
This commit is contained in:
commit
519f6e2668
@ -84,6 +84,7 @@ use function strlen;
|
|||||||
use function strpos;
|
use function strpos;
|
||||||
use function strtolower;
|
use function strtolower;
|
||||||
use function strval;
|
use function strval;
|
||||||
|
use function substr;
|
||||||
use function sys_get_temp_dir;
|
use function sys_get_temp_dir;
|
||||||
use function trim;
|
use function trim;
|
||||||
use function xdebug_get_function_stack;
|
use function xdebug_get_function_stack;
|
||||||
@ -127,7 +128,7 @@ class Utils{
|
|||||||
*/
|
*/
|
||||||
public static function getNiceClosureName(\Closure $closure) : string{
|
public static function getNiceClosureName(\Closure $closure) : string{
|
||||||
$func = new \ReflectionFunction($closure);
|
$func = new \ReflectionFunction($closure);
|
||||||
if($func->getName() !== "{closure}"){
|
if(substr($func->getName(), -strlen('{closure}')) !== '{closure}'){
|
||||||
//closure wraps a named function, can be done with reflection or fromCallable()
|
//closure wraps a named function, can be done with reflection or fromCallable()
|
||||||
//isClosure() is useless here because it just tells us if $func is reflecting a Closure object
|
//isClosure() is useless here because it just tells us if $func is reflecting a Closure object
|
||||||
|
|
||||||
|
@ -24,9 +24,20 @@ declare(strict_types=1);
|
|||||||
namespace pocketmine\utils;
|
namespace pocketmine\utils;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
use function define;
|
||||||
|
use function defined;
|
||||||
|
|
||||||
class UtilsTest extends TestCase{
|
class UtilsTest extends TestCase{
|
||||||
|
|
||||||
|
public function setUp(){
|
||||||
|
if(!defined('pocketmine\PATH')){
|
||||||
|
define('pocketmine\PATH', 'dummy');
|
||||||
|
}
|
||||||
|
if(!defined('pocketmine\PLUGIN_PATH')){
|
||||||
|
define('pocketmine\PLUGIN_PATH', 'dummy');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function parseDocCommentNewlineProvider() : array{
|
public function parseDocCommentNewlineProvider() : array{
|
||||||
return [
|
return [
|
||||||
["\t/**\r\n\t * @param PlayerJoinEvent \$event\r\n\t * @priority HIGHEST\r\n\t * @notHandler\r\n\t */"],
|
["\t/**\r\n\t * @param PlayerJoinEvent \$event\r\n\t * @priority HIGHEST\r\n\t * @notHandler\r\n\t */"],
|
||||||
@ -47,4 +58,9 @@ class UtilsTest extends TestCase{
|
|||||||
self::assertArrayHasKey("priority", $tags);
|
self::assertArrayHasKey("priority", $tags);
|
||||||
self::assertEquals("HIGHEST", $tags["priority"]);
|
self::assertEquals("HIGHEST", $tags["priority"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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(){}));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user