php5 compatibility

This commit is contained in:
Raffael Sahli 2018-09-21 14:47:42 +02:00
commit 9a6fbed231

View file

@ -112,21 +112,22 @@ class NativeShare extends AbstractShare {
return new NativeFileInfo($this, $path, self::mb_basename($path), $this->getStat($path)); return new NativeFileInfo($this, $path, self::mb_basename($path), $this->getStat($path));
} }
/** /**
* Multibyte unicode safe version of basename() * Multibyte unicode safe version of basename()
* *
* @link http://php.net/manual/en/function.basename.php#121405 * @param string $path
*/ * @link http://php.net/manual/en/function.basename.php#121405
protected static function mb_basename($path): string * @return string
{ */
if (preg_match('@^.*[\\\\/]([^\\\\/]+)$@s', $path, $matches)) { protected static function mb_basename($path) {
return $matches[1]; if (preg_match('@^.*[\\\\/]([^\\\\/]+)$@s', $path, $matches)) {
} else if (preg_match('@^([^\\\\/]+)$@s', $path, $matches)) { return $matches[1];
return $matches[1]; } elseif (preg_match('@^([^\\\\/]+)$@s', $path, $matches)) {
} return $matches[1];
}
return ''; return '';
} }
private function getStat($path) { private function getStat($path) {
return $this->getState()->stat($this->buildUrl($path)); return $this->getState()->stat($this->buildUrl($path));