diff --git a/System/File/ContainerInterface.php b/System/File/ContainerInterface.php index b4adb5853..6f89879a2 100755 --- a/System/File/ContainerInterface.php +++ b/System/File/ContainerInterface.php @@ -151,11 +151,11 @@ interface ContainerInterface /** * Get the owner id of the resource. * - * @return int + * @return string * * @since 1.0.0 */ - public function getOwner() : int; + public function getOwner() : string; /** * Get the permissions id of the resource. diff --git a/System/File/Ftp/Directory.php b/System/File/Ftp/Directory.php index 9db5fdc87..2b42f9dff 100755 --- a/System/File/Ftp/Directory.php +++ b/System/File/Ftp/Directory.php @@ -66,7 +66,10 @@ class Directory extends FileAbstract implements DirectoryInterface return null; } - \ftp_login($con, $http->user, $http->pass); + $status = \ftp_login($con, $http->user, $http->pass); + if ($status === false) { + return null; + } if ($http->getPath() !== '') { @\ftp_chdir($con, $http->getPath()); @@ -347,6 +350,16 @@ class Directory extends FileAbstract implements DirectoryInterface return self::parseRawList($con, self::parent($path))[$path]['user']; } + /** + * {@inheritdoc} + */ + public function getOwner() : string + { + $this->owner = self::parseRawList($this->con, self::parent($this->path))[$this->path]['user']; + + return $this->owner; + } + /** * Get detailed file/dir list. * @@ -407,6 +420,16 @@ class Directory extends FileAbstract implements DirectoryInterface return self::parseRawList($con, self::parent($path))[$path]['permission']; } + /** + * {@inheritdoc} + */ + public function getPermission() : int + { + $this->permission = self::parseRawList($this->con, self::parent($this->path))[$this->path]['permission']; + + return $this->permission; + } + /** * {@inheritdoc} */ diff --git a/System/File/Ftp/File.php b/System/File/Ftp/File.php index 65e675e4f..b9625e165 100755 --- a/System/File/Ftp/File.php +++ b/System/File/Ftp/File.php @@ -86,7 +86,10 @@ class File extends FileAbstract implements FileInterface return null; } - \ftp_login($con, $http->user, $http->pass); + $status = \ftp_login($con, $http->user, $http->pass); + if ($status === false) { + return null; + } if ($http->getPath() !== '') { @\ftp_chdir($con, $http->getPath()); @@ -294,6 +297,16 @@ class File extends FileAbstract implements FileInterface return Directory::parseRawList($con, self::dirpath($path))[$path]['user']; } + /** + * {@inheritdoc} + */ + public function getOwner() : string + { + $this->owner = Directory::parseRawList($this->con, self::dirpath($this->path))[$this->path]['user']; + + return $this->owner; + } + /** * {@inheritdoc} */ @@ -306,6 +319,16 @@ class File extends FileAbstract implements FileInterface return Directory::parseRawList($con, self::dirpath($path))[$path]['permission']; } + /** + * {@inheritdoc} + */ + public function getPermission() : int + { + $this->permission = Directory::parseRawList($this->con, self::dirpath($this->path))[$this->path]['permission']; + + return $this->permission; + } + /** * Gets the directory name of a file. * diff --git a/System/File/Ftp/FileAbstract.php b/System/File/Ftp/FileAbstract.php index 23f5625d9..5c413fab4 100755 --- a/System/File/Ftp/FileAbstract.php +++ b/System/File/Ftp/FileAbstract.php @@ -95,10 +95,10 @@ abstract class FileAbstract implements FtpContainerInterface /** * Owner. * - * @var int + * @var string * @since 1.0.0 */ - protected int $owner = 0; + protected string $owner = ''; /** * Permission. @@ -191,7 +191,7 @@ abstract class FileAbstract implements FtpContainerInterface /** * {@inheritdoc} */ - public function getOwner() : int + public function getOwner() : string { return $this->owner; } @@ -219,7 +219,7 @@ abstract class FileAbstract implements FtpContainerInterface $this->createdAt = (new \DateTimeImmutable())->setTimestamp($mtime === false ? 0 : $mtime); $this->changedAt->setTimestamp($ctime === false ? 0 : $ctime); - $this->owner = 0; + $this->owner = ''; $this->permission = 0; $this->isInitialized = true; diff --git a/System/File/Local/FileAbstract.php b/System/File/Local/FileAbstract.php index dbda205d2..e2db4976a 100755 --- a/System/File/Local/FileAbstract.php +++ b/System/File/Local/FileAbstract.php @@ -79,10 +79,10 @@ abstract class FileAbstract implements LocalContainerInterface /** * Owner. * - * @var int + * @var string * @since 1.0.0 */ - protected int $owner = 0; + protected string $owner = ''; /** * Permission. @@ -220,7 +220,7 @@ abstract class FileAbstract implements LocalContainerInterface /** * {@inheritdoc} */ - public function getOwner() : int + public function getOwner() : string { return $this->owner; } @@ -246,7 +246,7 @@ abstract class FileAbstract implements LocalContainerInterface $owner = \fileowner($this->path); - $this->owner = $owner === false ? 0 : $owner; + $this->owner = $owner === false ? '' : (string) $owner; $this->permission = (int) \substr(\sprintf('%o', \fileperms($this->path)), -4); $this->isInitialized = true; diff --git a/Views/ViewAbstract.php b/Views/ViewAbstract.php index 5f3dc7202..14a1e4aba 100755 --- a/Views/ViewAbstract.php +++ b/Views/ViewAbstract.php @@ -277,22 +277,25 @@ abstract class ViewAbstract implements RenderableInterface */ protected function renderTemplate(string $template, mixed ...$data) : string { - $ob = ''; + $obLevel = 0; + $ob = ''; try { - if ($this->isBuffered) { - \ob_start(); - } - $path = $template; if (!\is_file($path)) { return ''; } + if ($this->isBuffered) { + ++$obLevel; + \ob_start(); + } + /** @noinspection PhpIncludeInspection */ $includeData = include $path; if ($this->isBuffered) { + --$obLevel; $ob = (string) \ob_get_clean(); } @@ -300,7 +303,7 @@ abstract class ViewAbstract implements RenderableInterface $ob = (string) \json_encode($includeData); } } catch (\Throwable $e) { - if ($this->isBuffered) { + if ($obLevel > 0 && $this->isBuffered) { $ob .= (string) \ob_get_clean(); } } diff --git a/tests/System/File/Ftp/FileTest.php b/tests/System/File/Ftp/FileTest.php index 1a3e82462..610ef6563 100755 --- a/tests/System/File/Ftp/FileTest.php +++ b/tests/System/File/Ftp/FileTest.php @@ -88,7 +88,7 @@ final class FileTest extends \PHPUnit\Framework\TestCase */ public function testInvalidConnection() : void { - self::assertFalse(File::ftpConnect(new HttpUri('ftp://karaka.app:21'))); + self::assertEquals(null, File::ftpConnect(new HttpUri('ftp://karaka.app:21'))); } /**