diff --git a/Account/Account.php b/Account/Account.php index 1cd90fdaa..e0d24248f 100644 --- a/Account/Account.php +++ b/Account/Account.php @@ -560,7 +560,7 @@ class Account implements ArrayableInterface, \JsonSerializable */ public function generatePassword(string $password) /* : void */ { - $this->password = password_hash($password, PASSWORD_DEFAULT); + $this->password = \password_hash($password, \PASSWORD_DEFAULT); } /** diff --git a/DataStorage/Database/Connection/MysqlConnection.php b/DataStorage/Database/Connection/MysqlConnection.php index 2f2a6597d..ec1f23cd7 100644 --- a/DataStorage/Database/Connection/MysqlConnection.php +++ b/DataStorage/Database/Connection/MysqlConnection.php @@ -60,32 +60,11 @@ class MysqlConnection extends ConnectionAbstract { $this->dbdata = isset($dbdata) ? $dbdata : $this->dbdata; - if (!isset($this->dbdata['db'])) { - throw new InvalidConnectionConfigException('db'); - } - - if (!isset($this->dbdata['host'])) { - throw new InvalidConnectionConfigException('host'); - } - - if (!isset($this->dbdata['port'])) { - throw new InvalidConnectionConfigException('port'); - } - - if (!isset($this->dbdata['database'])) { - throw new InvalidConnectionConfigException('database'); - } - - if (!isset($this->dbdata['login'])) { - throw new InvalidConnectionConfigException('login'); - } - - if (!isset($this->dbdata['password'])) { - throw new InvalidConnectionConfigException('password'); + if (!isset($this->dbdata['db'], $this->dbdata['host'], $this->dbdata['port'], $this->dbdata['database'], $this->dbdata['login'], $this->dbdata['password'])) { + throw new InvalidConnectionConfigException(json_encode($this->dbdata)); } $this->close(); - $this->prefix = $dbdata['prefix'] ?? ''; try { diff --git a/DataStorage/Database/DataMapperAbstract.php b/DataStorage/Database/DataMapperAbstract.php index 594330679..b31884969 100644 --- a/DataStorage/Database/DataMapperAbstract.php +++ b/DataStorage/Database/DataMapperAbstract.php @@ -149,7 +149,7 @@ class DataMapperAbstract implements DataMapperInterface /** * Highest mapper to know when to clear initialized objects * - * @var DataMapperAbstract + * @var string * @since 1.0.0 */ protected static $parentMapper = null; diff --git a/DataStorage/Database/Query/Grammar/Grammar.php b/DataStorage/Database/Query/Grammar/Grammar.php index 6b3cf5538..2d4c0f9ed 100644 --- a/DataStorage/Database/Query/Grammar/Grammar.php +++ b/DataStorage/Database/Query/Grammar/Grammar.php @@ -133,7 +133,6 @@ class Grammar extends GrammarAbstract break; case QueryType::RAW: return [$query->raw]; - break; default: throw new \InvalidArgumentException('Unknown query type.'); } diff --git a/Message/RequestAbstract.php b/Message/RequestAbstract.php index 7760bd951..2197b9862 100644 --- a/Message/RequestAbstract.php +++ b/Message/RequestAbstract.php @@ -265,7 +265,7 @@ abstract class RequestAbstract implements MessageInterface /** * {@inheritdoc} */ - public abstract function getOrigin() : string; + abstract public function getOrigin() : string; /** * {@inheritdoc} diff --git a/System/File/Local/Directory.php b/System/File/Local/Directory.php index 6675925f5..b7f2e7d28 100644 --- a/System/File/Local/Directory.php +++ b/System/File/Local/Directory.php @@ -156,27 +156,23 @@ class Directory extends FileAbstract implements DirectoryInterface */ public static function size(string $dir, bool $recursive = true) : int { - if (!file_exists($dir)) { + if (!file_exists($dir) || !is_readable($dir)) { throw new PathException($dir); } $countSize = 0; - $count = 0; + $dir_array = scandir($dir); - if (is_readable($dir)) { - $dir_array = scandir($dir); + foreach ($dir_array as $key => $filename) { + if ($filename === ".." || $filename === ".") { + continue; + } - foreach ($dir_array as $key => $filename) { - if ($filename != ".." && $filename != ".") { - if (is_dir($dir . "/" . $filename) && $recursive) { - $countSize += self::size($dir . "/" . $filename, $recursive); - } else { - if (is_file($dir . "/" . $filename)) { - $countSize += filesize($dir . "/" . $filename); - $count++; - } - } - } + $path = $dir . "/" . $filename; + if (is_dir($path) && $recursive) { + $countSize += self::size($path, $recursive); + } elseif (is_file($path)) { + $countSize += filesize($path); } } @@ -312,14 +308,12 @@ class Directory extends FileAbstract implements DirectoryInterface throw new PathException($from); } - if (!$overwrite && file_exists($to)) { - return false; - } - if (!file_exists($to)) { self::create($to, 0644, true); } elseif ($overwrite && file_exists($to)) { self::delete($to); + } else { + return false; } foreach ($iterator = new \RecursiveIteratorIterator( diff --git a/System/File/StorageAbstract.php b/System/File/StorageAbstract.php index 254a5e30d..0fffb96ac 100644 --- a/System/File/StorageAbstract.php +++ b/System/File/StorageAbstract.php @@ -72,120 +72,120 @@ abstract class StorageAbstract /** * {@inheritdoc} */ - public abstract static function created(string $path) : \DateTime; + abstract public static function created(string $path) : \DateTime; /** * {@inheritdoc} */ - public abstract static function changed(string $path) : \DateTime; + abstract public static function changed(string $path) : \DateTime; /** * {@inheritdoc} */ - public abstract static function owner(string $path) : int; + abstract public static function owner(string $path) : int; /** * {@inheritdoc} */ - public abstract static function permission(string $path) : int; + abstract public static function permission(string $path) : int; /** * {@inheritdoc} */ - public abstract static function parent(string $path) : string; + abstract public static function parent(string $path) : string; /** * {@inheritdoc} */ - public abstract static function create(string $path) : bool; + abstract public static function create(string $path) : bool; /** * {@inheritdoc} */ - public abstract static function delete(string $path) : bool; + abstract public static function delete(string $path) : bool; /** * {@inheritdoc} */ - public abstract static function copy(string $from, string $to, bool $overwrite = false) : bool; + abstract public static function copy(string $from, string $to, bool $overwrite = false) : bool; /** * {@inheritdoc} */ - public abstract static function move(string $from, string $to, bool $overwrite = false) : bool; + abstract public static function move(string $from, string $to, bool $overwrite = false) : bool; /** * {@inheritdoc} */ - public abstract static function size(string $path, bool $recursive = true) : int; + abstract public static function size(string $path, bool $recursive = true) : int; /** * {@inheritdoc} */ - public abstract static function exists(string $path) : bool; + abstract public static function exists(string $path) : bool; /** * {@inheritdoc} */ - public abstract static function name(string $path) : string; + abstract public static function name(string $path) : string; /** * {@inheritdoc} */ - public abstract static function basename(string $path) : string; + abstract public static function basename(string $path) : string; /** * {@inheritdoc} */ - public abstract static function dirname(string $path) : string; + abstract public static function dirname(string $path) : string; /** * {@inheritdoc} */ - public abstract static function dirpath(string $path) : string; + abstract public static function dirpath(string $path) : string; /** * {@inheritdoc} */ - public abstract static function list(string $path, string $filter = '*') : array; + abstract public static function list(string $path, string $filter = '*') : array; /** * {@inheritdoc} */ - public abstract static function count(string $path, bool $recursive = true, array $ignore = []) : int; + abstract public static function count(string $path, bool $recursive = true, array $ignore = []) : int; /** * {@inheritdoc} */ - public abstract static function put(string $path, string $content, int $mode = 0) : bool; + abstract public static function put(string $path, string $content, int $mode = 0) : bool; /** * {@inheritdoc} */ - public abstract static function get(string $path) : string; + abstract public static function get(string $path) : string; /** * {@inheritdoc} */ - public abstract static function sanitize(string $path, string $replace = '') : string; + abstract public static function sanitize(string $path, string $replace = '') : string; /** * {@inheritdoc} */ - public abstract static function set(string $path, string $content) : bool; + abstract public static function set(string $path, string $content) : bool; /** * {@inheritdoc} */ - public abstract static function append(string $path, string $content) : bool; + abstract public static function append(string $path, string $content) : bool; /** * {@inheritdoc} */ - public abstract static function prepend(string $path, string $content) : bool; + abstract public static function prepend(string $path, string $content) : bool; /** * {@inheritdoc} */ - public abstract static function extension(string $path) : string; + abstract public static function extension(string $path) : string; } diff --git a/Utils/ArrayUtils.php b/Utils/ArrayUtils.php index cec20cd9d..7995b7a29 100644 --- a/Utils/ArrayUtils.php +++ b/Utils/ArrayUtils.php @@ -97,16 +97,14 @@ class ArrayUtils if ($overwrite) { $current = $value; + } elseif (is_array($current) && !is_array($value)) { + $current[] = $value; + } elseif (is_array($current) && is_array($value)) { + $current += $value; + } elseif (is_scalar($current) && $current !== null) { + $current = [$current, $value]; } else { - if (is_array($current) && !is_array($value)) { - $current[] = $value; - } elseif (is_array($current) && is_array($value)) { - $current += $value; - } elseif (is_scalar($current) && $current !== null) { - $current = [$current, $value]; - } else { - $current = $value; - } + $current = $value; } return $data; @@ -156,7 +154,7 @@ class ArrayUtils $found = self::inArrayRecursive($needle, $item); if ($found) { - break; + return true; } } }