mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-01-11 09:48:40 +00:00
cs and phpstan fixes
This commit is contained in:
parent
988468bc82
commit
5aa0276f11
|
|
@ -54,7 +54,7 @@ final class BasicOcr
|
|||
*
|
||||
* @param string $dataPath Impage path to read
|
||||
* @param string $labelPath Label path to read
|
||||
* @param string $limit Limit (0 = unlimited)
|
||||
* @param int $limit Limit (0 = unlimited)
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
|
|
@ -73,7 +73,7 @@ final class BasicOcr
|
|||
* Reat image from path
|
||||
*
|
||||
* @param string $path Image to read
|
||||
* @param string $limit Limit
|
||||
* @param int $limit Limit
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
|
|
@ -136,7 +136,7 @@ final class BasicOcr
|
|||
* Read labels from from path
|
||||
*
|
||||
* @param string $path Labels path
|
||||
* @param string $limit Limit
|
||||
* @param int $limit Limit
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
|
|
@ -244,8 +244,8 @@ final class BasicOcr
|
|||
* Categorize an unknown image
|
||||
*
|
||||
* @param string $path Path to the image to categorize/evaluate/match against the training data
|
||||
* @param string $comparison Amount of comparisons
|
||||
* @param string $limit Limit (0 = unlimited)
|
||||
* @param int $comparison Amount of comparisons
|
||||
* @param int $limit Limit (0 = unlimited)
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ class GeneralResourceOwner implements ResourceOwnerInterface
|
|||
$this->resourceOwnerId = $resourceOwnerId;
|
||||
}
|
||||
|
||||
public function getId()
|
||||
public function getId() : string
|
||||
{
|
||||
return $this->response[$this->resourceOwnerId];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,7 +26,21 @@ namespace phpOMS\Auth\OAuth2\Provider;
|
|||
*/
|
||||
interface ResourceOwnerInterface
|
||||
{
|
||||
public function getId();
|
||||
/**
|
||||
* Get id
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getId() : string;
|
||||
|
||||
/**
|
||||
* Serialize as array
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function toArray() : array;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -94,9 +94,9 @@ final class FileCache extends ConnectionAbstract
|
|||
/**
|
||||
* Connect to cache
|
||||
*
|
||||
* @param array{0:string} $data Cache data (path to cache directory)
|
||||
* @param null|array{0:string} $data Cache data (path to cache directory)
|
||||
*/
|
||||
public function connect(array $data) : void
|
||||
public function connect(array $data = null) : void
|
||||
{
|
||||
$this->dbdata = $data;
|
||||
|
||||
|
|
|
|||
|
|
@ -57,13 +57,13 @@ final class MemCached extends ConnectionAbstract
|
|||
/**
|
||||
* Connect to cache
|
||||
*
|
||||
* @param array{host:string, port:int} $data Cache data
|
||||
* @param null|array{host:string, port:int} $data Cache data
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function connect(array $data) : void
|
||||
public function connect(array $data = null) : void
|
||||
{
|
||||
$this->dbdata = isset($data) ? $data : $this->dbdata;
|
||||
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ final class NullCache extends ConnectionAbstract
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function connect(array $data) : void
|
||||
public function connect(array $data = null) : void
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -58,13 +58,13 @@ final class RedisCache extends ConnectionAbstract
|
|||
/**
|
||||
* Connect to cache
|
||||
*
|
||||
* @param array{db:int, host:string, port:int} $data Cache data
|
||||
* @param null|array{db:int, host:string, port:int} $data Cache data
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function connect(array $data) : void
|
||||
public function connect(array $data = null) : void
|
||||
{
|
||||
$this->dbdata = isset($data) ? $data : $this->dbdata;
|
||||
|
||||
|
|
|
|||
|
|
@ -29,13 +29,13 @@ interface DataStorageConnectionInterface
|
|||
*
|
||||
* Overwrites current connection if existing
|
||||
*
|
||||
* @param string[] $data the basic datastorage information for establishing a connection
|
||||
* @param null|array $data the basic datastorage information for establishing a connection
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function connect(array $data) : void;
|
||||
public function connect(array $data = null) : void;
|
||||
|
||||
/**
|
||||
* Get the datastorage type.
|
||||
|
|
|
|||
|
|
@ -25,6 +25,8 @@ use phpOMS\DataStorage\Database\Schema\Grammar\Grammar as SchemaGrammar;
|
|||
* Handles the database connection.
|
||||
* Implementing wrapper functions for multiple databases is planned (far away).
|
||||
*
|
||||
* @property \PDO $con
|
||||
*
|
||||
* @package phpOMS\DataStorage\Database\Connection
|
||||
* @license OMS License 1.0
|
||||
* @link https://orange-management.org
|
||||
|
|
@ -42,10 +44,10 @@ abstract class ConnectionAbstract implements ConnectionInterface
|
|||
*
|
||||
* This can be used externally to define queries and execute them.
|
||||
*
|
||||
* @var null|\PDO
|
||||
* @var \PDO
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected ?\PDO $con;
|
||||
protected \PDO $con;
|
||||
|
||||
/**
|
||||
* Database data.
|
||||
|
|
@ -183,7 +185,7 @@ abstract class ConnectionAbstract implements ConnectionInterface
|
|||
*/
|
||||
public function close() : void
|
||||
{
|
||||
$this->con = null;
|
||||
$this->con = new NullPDO();
|
||||
$this->status = DatabaseStatus::CLOSED;
|
||||
}
|
||||
|
||||
|
|
@ -194,6 +196,9 @@ abstract class ConnectionAbstract implements ConnectionInterface
|
|||
*
|
||||
* @return mixed Returns the value of the connection
|
||||
*
|
||||
* @todo Orange-Management/phpOMS#218
|
||||
* As soon as readonly member variables are possible the magic methods should be removed.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function __get($name)
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ final class MysqlConnection extends ConnectionAbstract
|
|||
|
||||
$this->status = DatabaseStatus::OK;
|
||||
} catch (\PDOException $e) {
|
||||
$this->con = null;
|
||||
$this->con = new NullPDO();
|
||||
$this->status = DatabaseStatus::MISSING_DATABASE;
|
||||
} finally {
|
||||
$this->dbdata['password'] = '****';
|
||||
|
|
|
|||
36
DataStorage/Database/Connection/NullPDO.php
Normal file
36
DataStorage/Database/Connection/NullPDO.php
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 7.4
|
||||
*
|
||||
* @package phpOMS\DataStorage\Database\Connection
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link https://orange-management.org
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace phpOMS\DataStorage\Database\Connection;
|
||||
|
||||
/**
|
||||
* Null implementation of PDO.
|
||||
*
|
||||
* @package phpOMS\DataStorage\Database\Connection
|
||||
* @license OMS License 1.0
|
||||
* @link https://orange-management.org
|
||||
* @since 1.0.0
|
||||
*/
|
||||
final class NullPDO extends \PDO
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -82,7 +82,7 @@ final class PostgresConnection extends ConnectionAbstract
|
|||
|
||||
$this->status = DatabaseStatus::OK;
|
||||
} catch (\PDOException $e) {
|
||||
$this->con = null;
|
||||
$this->con = new NullPDO();
|
||||
$this->status = DatabaseStatus::MISSING_DATABASE;
|
||||
throw new InvalidConnectionConfigException((string) \json_encode($this->dbdata));
|
||||
} finally {
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ final class SQLiteConnection extends ConnectionAbstract
|
|||
|
||||
$this->status = DatabaseStatus::OK;
|
||||
} catch (\PDOException $e) {
|
||||
$this->con = null;
|
||||
$this->con = new NullPDO();
|
||||
$this->status = DatabaseStatus::MISSING_DATABASE;
|
||||
} finally {
|
||||
$this->dbdata['password'] = '****';
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ final class SqlServerConnection extends ConnectionAbstract
|
|||
|
||||
$this->status = DatabaseStatus::OK;
|
||||
} catch (\PDOException $e) {
|
||||
$this->con = null;
|
||||
$this->con = new NullPDO();
|
||||
$this->status = DatabaseStatus::MISSING_DATABASE;
|
||||
throw new InvalidConnectionConfigException((string) \json_encode($this->dbdata));
|
||||
} finally {
|
||||
|
|
|
|||
|
|
@ -161,7 +161,7 @@ class DataMapperAbstract implements DataMapperInterface
|
|||
*
|
||||
* Relation is defined in current mapper
|
||||
*
|
||||
* @var array<string, array{mapper:string, self:string, by?:string}>
|
||||
* @var array<string, array{mapper:string, external:string, by?:string, column?:string, conditional?:bool}>
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static array $ownsOne = [];
|
||||
|
|
@ -169,7 +169,7 @@ class DataMapperAbstract implements DataMapperInterface
|
|||
/**
|
||||
* Belongs to.
|
||||
*
|
||||
* @var array<string, array{mapper:string, self:string}>
|
||||
* @var array<string, array{mapper:string, external:string}>
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static array $belongsTo = [];
|
||||
|
|
@ -794,6 +794,7 @@ class DataMapperAbstract implements DataMapperInterface
|
|||
continue;
|
||||
}
|
||||
|
||||
/** @var \ReflectionClass $relReflectionClass */
|
||||
$primaryKey = $mapper::getObjectId($value, $relReflectionClass);
|
||||
|
||||
// already in db
|
||||
|
|
@ -1022,7 +1023,6 @@ class DataMapperAbstract implements DataMapperInterface
|
|||
*/
|
||||
private static function createRelationTable(string $propertyName, array $objsIds, $objId) : void
|
||||
{
|
||||
/** @var string $table */
|
||||
if (empty($objsIds) || !isset(static::$hasMany[$propertyName]['external'])) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -1031,7 +1031,7 @@ class DataMapperAbstract implements DataMapperInterface
|
|||
$relQuery->into(static::$hasMany[$propertyName]['table'])
|
||||
->insert(static::$hasMany[$propertyName]['external'], static::$hasMany[$propertyName]['self']);
|
||||
|
||||
foreach ($objsIds as $key => $src) {
|
||||
foreach ($objsIds as $src) {
|
||||
if (\is_object($src)) {
|
||||
$mapper = (\stripos($mapper = \get_class($src), '\Null') !== false
|
||||
? \str_replace('\Null', '\\', $mapper)
|
||||
|
|
@ -1144,6 +1144,7 @@ class DataMapperAbstract implements DataMapperInterface
|
|||
continue;
|
||||
}
|
||||
|
||||
/** @var \ReflectionClass @relReflectionClass */
|
||||
$primaryKey = $mapper::getObjectId($value, $relReflectionClass);
|
||||
|
||||
// already in db
|
||||
|
|
@ -2058,7 +2059,7 @@ class DataMapperAbstract implements DataMapperInterface
|
|||
* @param int $depth Relation depth
|
||||
* @param mixed $default Default value
|
||||
*
|
||||
* @return void
|
||||
* @return array
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
|
|
@ -2138,7 +2139,7 @@ class DataMapperAbstract implements DataMapperInterface
|
|||
* @param int $depth Relation depth
|
||||
* @param mixed $default Default value
|
||||
*
|
||||
* @return void
|
||||
* @return array
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
|
|
@ -2292,7 +2293,10 @@ class DataMapperAbstract implements DataMapperInterface
|
|||
continue;
|
||||
}
|
||||
|
||||
$value = $result[$alias];
|
||||
$value = $result[$alias];
|
||||
$hasPath = false;
|
||||
$aValue = null;
|
||||
$arrayPath = '/';
|
||||
|
||||
if (\stripos($member, '/') !== false) {
|
||||
$hasPath = true;
|
||||
|
|
@ -2974,8 +2978,9 @@ class DataMapperAbstract implements DataMapperInterface
|
|||
$keys = $comparison === 'in' ? $keys : \reset($keys);
|
||||
|
||||
$query ??= self::getQuery(null, [], $relations, $depth);
|
||||
$hasBy = $ref === null ? false : isset(static::$columns[self::getColumnByMember($ref)]);
|
||||
|
||||
if ($ref === null || ($hasBy = isset(static::$columns[self::getColumnByMember($ref)]))) {
|
||||
if ($ref === null || $hasBy) {
|
||||
$ref = $ref === null || !$hasBy ? static::$primaryField : static::$columns[self::getColumnByMember($ref)]['name'];
|
||||
|
||||
if ($keys !== null && $keys !== false) {
|
||||
|
|
|
|||
|
|
@ -163,6 +163,8 @@ final class L11nManager
|
|||
try {
|
||||
/** @var ModuleAbstract $class */
|
||||
$class = '\Modules\\' . $module . '\\Controller\\' . ($app ?? $this->appName) . 'Controller';
|
||||
|
||||
/** @var string $class */
|
||||
if (!Autoloader::exists($class)) {
|
||||
return 'ERROR';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -738,7 +738,7 @@ class Matrix implements \ArrayAccess, \Iterator
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function valid()
|
||||
public function valid() : bool
|
||||
{
|
||||
return $this->offsetExists($this->position);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -76,25 +76,24 @@ final class Prime
|
|||
*/
|
||||
public static function rabinTest(int $n, int $k = 10000) : bool
|
||||
{
|
||||
if ($n == 2) {
|
||||
if ($n === 2) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if ($n < 2 || $n % 2 == 0) {
|
||||
if ($n < 2 || $n % 2 === 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$d = $n - 1;
|
||||
$s = 0;
|
||||
|
||||
while ($d % 2 == 0) {
|
||||
while ($d % 2 === 0) {
|
||||
$d /= 2;
|
||||
++$s;
|
||||
}
|
||||
|
||||
for ($i = 0; $i < $k; ++$i) {
|
||||
$a = \mt_rand(2, $n - 1);
|
||||
|
||||
$x = \bcpowmod((string) $a, (string) $d, (string) $n);
|
||||
|
||||
if ($x == 1 || $x == $n - 1) {
|
||||
|
|
@ -102,9 +101,17 @@ final class Prime
|
|||
}
|
||||
|
||||
for ($j = 1; $j < $s; ++$j) {
|
||||
$x = \bcmod(\bcmul($x, $x), (string) $n);
|
||||
if ($x === null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($x == 1) {
|
||||
$mul = \bcmul($x, $x);
|
||||
if ($mul === null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$x = \bcmod($mul, (string) $n);
|
||||
if ($x == 1 || $x === null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -47,14 +47,6 @@ final class ConsoleRequest extends RequestAbstract
|
|||
*/
|
||||
protected string $method;
|
||||
|
||||
/**
|
||||
* Request hash.
|
||||
*
|
||||
* @var string[]
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected array $hash = [];
|
||||
|
||||
/**
|
||||
* OS type.
|
||||
*
|
||||
|
|
@ -120,18 +112,6 @@ final class ConsoleRequest extends RequestAbstract
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get request hash.
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getHash() : array
|
||||
{
|
||||
return $this->hash;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set request method.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -64,14 +64,6 @@ final class HttpRequest extends RequestAbstract
|
|||
*/
|
||||
private array $info;
|
||||
|
||||
/**
|
||||
* Request hash.
|
||||
*
|
||||
* @var string[]
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected array $hash = [];
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
|
|
@ -318,18 +310,6 @@ final class HttpRequest extends RequestAbstract
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get request hash.
|
||||
*
|
||||
* @return string[]
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getHash() : array
|
||||
{
|
||||
return $this->hash;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set request method.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -66,6 +66,15 @@ abstract class RequestAbstract implements MessageInterface
|
|||
*/
|
||||
protected HeaderAbstract $header;
|
||||
|
||||
|
||||
/**
|
||||
* Request hash.
|
||||
*
|
||||
* @var string[]
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected array $hash = [];
|
||||
|
||||
/**
|
||||
* Get data.
|
||||
*
|
||||
|
|
@ -223,6 +232,18 @@ abstract class RequestAbstract implements MessageInterface
|
|||
return $this->header;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get request hash.
|
||||
*
|
||||
* @return string[]
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getHash() : array
|
||||
{
|
||||
return $this->hash;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the origin request source (IPv4/IPv6)
|
||||
*
|
||||
|
|
|
|||
|
|
@ -42,6 +42,14 @@ class Directory extends FileAbstract implements DirectoryInterface, FtpContainer
|
|||
*/
|
||||
private array $nodes = [];
|
||||
|
||||
/**
|
||||
* Filter for directory listing
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private string $filter = '*';
|
||||
|
||||
/**
|
||||
* Create ftp connection.
|
||||
*
|
||||
|
|
@ -477,6 +485,10 @@ class Directory extends FileAbstract implements DirectoryInterface, FtpContainer
|
|||
}
|
||||
|
||||
$list = \scandir($from);
|
||||
if ($list === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach ($list as $item) {
|
||||
if ($item === '.' || $item === '..') {
|
||||
continue;
|
||||
|
|
|
|||
|
|
@ -39,8 +39,8 @@ class File extends FileAbstract implements FileInterface
|
|||
/**
|
||||
* Create ftp connection
|
||||
*
|
||||
* @param string $path Ftp path including username and password
|
||||
* @param null|resource $con Connection
|
||||
* @param HttpUri $uri Ftp uri/path including username and password
|
||||
* @param null|resource $con Connection
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
|
|
@ -162,15 +162,18 @@ class File extends FileAbstract implements FileInterface
|
|||
throw new PathException($path);
|
||||
}
|
||||
|
||||
$temp = \fopen('php://temp', 'r+');
|
||||
$content = '';
|
||||
|
||||
if (\ftp_fget($con, $temp, $path, \FTP_BINARY, 0)) {
|
||||
\rewind($temp);
|
||||
$content = \stream_get_contents($temp);
|
||||
$fp = \fopen('php://temp', 'r+');
|
||||
if ($fp === false) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return $content;
|
||||
$content = '';
|
||||
if (\ftp_fget($con, $fp, $path, \FTP_BINARY, 0)) {
|
||||
\rewind($fp);
|
||||
$content = \stream_get_contents($fp);
|
||||
}
|
||||
|
||||
return $content === false ? '' : $content;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -591,6 +594,13 @@ class File extends FileAbstract implements FileInterface
|
|||
return \dirname($this->path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get directory of the file
|
||||
*
|
||||
* @return ContainerInterface
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getDirectory() : ContainerInterface
|
||||
{
|
||||
$uri = clone $this->uri;
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ abstract class FileAbstract implements ContainerInterface
|
|||
/**
|
||||
* Ftp uri
|
||||
*
|
||||
* @var resource
|
||||
* @var HttpUri
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected HttpUri $uri;
|
||||
|
|
@ -213,7 +213,7 @@ abstract class FileAbstract implements ContainerInterface
|
|||
$mtime = \ftp_mdtm($this->con, $this->path);
|
||||
$ctime = \ftp_mdtm($this->con, $this->path);
|
||||
|
||||
$this->createdAt->setTimestamp($mtime === false ? 0 : $mtime);
|
||||
$this->createdAt = (new \DateTimeImmutable())->setTimestamp($mtime === false ? 0 : $mtime);
|
||||
$this->changedAt->setTimestamp($ctime === false ? 0 : $ctime);
|
||||
|
||||
$owner = \fileowner($this->path);
|
||||
|
|
|
|||
|
|
@ -29,8 +29,23 @@ use phpOMS\System\File\StorageAbstract;
|
|||
*/
|
||||
class FtpStorage extends StorageAbstract
|
||||
{
|
||||
/**
|
||||
* Connection
|
||||
*
|
||||
* @var resource
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private static $con = null;
|
||||
|
||||
/**
|
||||
* Set connection
|
||||
*
|
||||
* @param resource $con Connection
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public static function with($con) : void
|
||||
{
|
||||
self::$con = $con;
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ final class Directory extends FileAbstract implements DirectoryInterface, LocalC
|
|||
/**
|
||||
* Directory nodes (files and directories).
|
||||
*
|
||||
* @var FileAbstract[]
|
||||
* @var ContainerInterface[]
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private array $nodes = [];
|
||||
|
|
@ -400,6 +400,7 @@ final class Directory extends FileAbstract implements DirectoryInterface, LocalC
|
|||
new \RecursiveDirectoryIterator($from, \RecursiveDirectoryIterator::SKIP_DOTS),
|
||||
\RecursiveIteratorIterator::SELF_FIRST) as $item
|
||||
) {
|
||||
/** @var \RecursiveDirectoryIterator $iterator */
|
||||
$subPath = $iterator->getSubPathname();
|
||||
|
||||
if ($item->isDir()) {
|
||||
|
|
@ -563,7 +564,7 @@ final class Directory extends FileAbstract implements DirectoryInterface, LocalC
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function valid()
|
||||
public function valid() : bool
|
||||
{
|
||||
$key = \key($this->nodes);
|
||||
|
||||
|
|
|
|||
|
|
@ -515,6 +515,13 @@ final class File extends FileAbstract implements FileInterface, LocalContainerIn
|
|||
return new Directory(self::parent($this->path));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get directory of the file
|
||||
*
|
||||
* @return ContainerInterface
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getDirectory() : ContainerInterface
|
||||
{
|
||||
return new Directory(self::dirpath($this->path));
|
||||
|
|
|
|||
|
|
@ -49,9 +49,9 @@ final class File
|
|||
{
|
||||
if ($bytes < 1000) {
|
||||
return $bytes . 'b';
|
||||
} elseif ($bytes > 999 && $bytes < 1000000) {
|
||||
} elseif ($bytes < 1000000) {
|
||||
return \rtrim(\rtrim(\number_format($bytes / 1000, 1, $decimal, $thousands), '0'), $decimal) . 'kb';
|
||||
} elseif ($bytes > 999999 && $bytes < 1000000000) {
|
||||
} elseif ($bytes < 1000000000) {
|
||||
return \rtrim(\rtrim(\number_format($bytes / 1000000, 1, $decimal, $thousands), '0'), $decimal) . 'mb';
|
||||
}
|
||||
|
||||
|
|
@ -73,7 +73,7 @@ final class File
|
|||
{
|
||||
if ($kilobytes < 1000) {
|
||||
return \rtrim(\rtrim(\number_format($kilobytes, 1, $decimal, $thousands), '0'), $decimal) . 'kb';
|
||||
} elseif ($kilobytes > 999 && $kilobytes < 1000000) {
|
||||
} elseif ($kilobytes < 1000000) {
|
||||
return \rtrim(\rtrim(\number_format($kilobytes / 1000, 1, $decimal, $thousands), '0'), $decimal) . 'mb';
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -210,7 +210,7 @@ abstract class ViewAbstract implements RenderableInterface
|
|||
/**
|
||||
* Get view/template response.
|
||||
*
|
||||
* @param array ...$data Data to pass to renderer
|
||||
* @param mixed ...$data Data to pass to renderer
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ class BaseModelMapper extends DataMapperAbstract
|
|||
/**
|
||||
* Belongs to.
|
||||
*
|
||||
* @var array<string, array{mapper:string, self:string}>
|
||||
* @var array<string, array{mapper:string, external:string}>
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static array $belongsTo = [
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user