Account for reflection filename being false (in the case of classes/functions defined by builtins)

This commit is contained in:
Dylan K. Taylor 2020-04-15 10:15:38 +01:00
parent cf538d83bf
commit 2281fe4e67

View File

@ -138,7 +138,12 @@ class Utils{
//non-class function //non-class function
return $func->getName(); return $func->getName();
} }
return "closure@" . self::cleanPath($func->getFileName()) . "#L" . $func->getStartLine(); $filename = $func->getFileName();
return "closure@" . ($filename !== false ?
self::cleanPath($filename) . "#L" . $func->getStartLine() :
"internal"
);
} }
/** /**
@ -149,7 +154,12 @@ class Utils{
public static function getNiceClassName(object $obj) : string{ public static function getNiceClassName(object $obj) : string{
$reflect = new \ReflectionClass($obj); $reflect = new \ReflectionClass($obj);
if($reflect->isAnonymous()){ if($reflect->isAnonymous()){
return "anonymous@" . self::cleanPath($reflect->getFileName()) . "#L" . $reflect->getStartLine(); $filename = $reflect->getFileName();
return "anonymous@" . ($filename !== false ?
self::cleanPath($filename) . "#L" . $reflect->getStartLine() :
"internal"
);
} }
return $reflect->getName(); return $reflect->getName();