diff --git a/DataStorage/Cache/Connection/FileCache.php b/DataStorage/Cache/Connection/FileCache.php index b1aefd447..e924953d2 100644 --- a/DataStorage/Cache/Connection/FileCache.php +++ b/DataStorage/Cache/Connection/FileCache.php @@ -70,7 +70,7 @@ class FileCache extends ConnectionAbstract } $this->status = CacheStatus::ACTIVE; - $this->con = realpath($path); + $this->con = \realpath($path); } /** @@ -90,7 +90,7 @@ class FileCache extends ConnectionAbstract return false; } - array_map('unlink', glob($this->con . '/*')); + \array_map('unlink', \glob($this->con . '/*')); return true; } @@ -128,7 +128,7 @@ class FileCache extends ConnectionAbstract $path = Directory::sanitize($key, self::SANITIZE); - File::put($this->con . '/' . trim($path, '/') . '.cache', $this->build($value, $expire)); + File::put($this->con . '/' . \trim($path, '/') . '.cache', $this->build($value, $expire)); } /** @@ -180,15 +180,15 @@ class FileCache extends ConnectionAbstract */ private function dataType($value) : int { - if (is_int($value)) { + if (\is_int($value)) { return CacheValueType::_INT; - } elseif (is_float($value)) { + } elseif (\is_float($value)) { return CacheValueType::_FLOAT; - } elseif (is_string($value)) { + } elseif (\is_string($value)) { return CacheValueType::_STRING; - } elseif (is_bool($value)) { + } elseif (\is_bool($value)) { return CacheValueType::_BOOL; - } elseif (is_array($value)) { + } elseif (\is_array($value)) { return CacheValueType::_ARRAY; } elseif ($value === null) { return CacheValueType::_NULL; @@ -220,9 +220,9 @@ class FileCache extends ConnectionAbstract } elseif ($type === CacheValueType::_ARRAY) { return \json_encode($value); } elseif ($type === CacheValueType::_SERIALIZABLE) { - return get_class($value) . self::DELIM . $value->serialize(); + return \get_class($value) . self::DELIM . $value->serialize(); } elseif ($type === CacheValueType::_JSONSERIALIZABLE) { - return get_class($value) . self::DELIM . $value->jsonSerialize(); + return \get_class($value) . self::DELIM . $value->jsonSerialize(); } elseif ($type === CacheValueType::_NULL) { return ''; } @@ -263,7 +263,7 @@ class FileCache extends ConnectionAbstract } $created = Directory::created($path)->getTimestamp(); - $now = time(); + $now = \time(); if ($expire >= 0 && $created + $expire < $now) { return null; @@ -377,7 +377,7 @@ class FileCache extends ConnectionAbstract } $dir = new Directory($this->con); - $now = time(); + $now = \time(); foreach ($dir as $file) { if ($file instanceof File) { @@ -425,6 +425,6 @@ class FileCache extends ConnectionAbstract private function getPath($key) : string { $path = Directory::sanitize($key, self::SANITIZE); - return $this->con . '/' . trim($path, '/') . '.cache'; + return $this->con . '/' . \trim($path, '/') . '.cache'; } } diff --git a/DataStorage/Database/DataMapperAbstract.php b/DataStorage/Database/DataMapperAbstract.php index 7fdc775b9..bf0331ea1 100644 --- a/DataStorage/Database/DataMapperAbstract.php +++ b/DataStorage/Database/DataMapperAbstract.php @@ -895,7 +895,7 @@ class DataMapperAbstract implements DataMapperInterface return $value->serialize(); } elseif ($value instanceof \JsonSerializable) { return \json_encode($value->jsonSerialize()); - } elseif (is_object($value) && method_exists($value, 'getId')) { + } elseif (is_object($value) && \method_exists($value, 'getId')) { return $value->getId(); } @@ -1918,7 +1918,7 @@ class DataMapperAbstract implements DataMapperInterface $obj[$value] = self::populate(self::getRaw($value), $toFill); - if (method_exists($obj[$value], 'initialize')) { + if (\method_exists($obj[$value], 'initialize')) { $obj[$value]->initialize(); } diff --git a/DataStorage/Database/Query/Builder.php b/DataStorage/Database/Query/Builder.php index ad37a3625..404e75e57 100644 --- a/DataStorage/Database/Query/Builder.php +++ b/DataStorage/Database/Query/Builder.php @@ -260,7 +260,7 @@ final class Builder extends BuilderAbstract $this->type = QueryType::SELECT; foreach ($columns as $key => $column) { - if (is_string($column) || $column instanceof \Closure) { + if (\is_string($column) || $column instanceof \Closure) { $this->selects[] = $column; } else { throw new \InvalidArgumentException(); @@ -301,9 +301,9 @@ final class Builder extends BuilderAbstract */ public function bind($binds) : Builder { - if (is_array($binds)) { + if (\is_array($binds)) { $this->binds += $binds; - } elseif (is_string($binds) || $binds instanceof \Closure) { + } elseif (\is_string($binds) || $binds instanceof \Closure) { $this->binds[] = $binds; } else { throw new \InvalidArgumentException(); @@ -366,7 +366,7 @@ final class Builder extends BuilderAbstract } $this->type = QueryType::RAW; - $this->raw = rtrim($raw, ';'); + $this->raw = \rtrim($raw, ';'); return $this; } @@ -387,14 +387,14 @@ final class Builder extends BuilderAbstract return true; } - $test = strtolower($raw); + $test = \strtolower($raw); - if (strpos($test, 'insert') !== false - || strpos($test, 'update') !== false - || strpos($test, 'drop') !== false - || strpos($test, 'delete') !== false - || strpos($test, 'create') !== false - || strpos($test, 'alter') !== false + if (\strpos($test, 'insert') !== false + || \strpos($test, 'update') !== false + || \strpos($test, 'drop') !== false + || \strpos($test, 'delete') !== false + || \strpos($test, 'create') !== false + || \strpos($test, 'alter') !== false ) { return false; } @@ -444,7 +444,7 @@ final class Builder extends BuilderAbstract public function from(...$tables) : Builder { foreach ($tables as $key => $table) { - if (is_string($table) || $table instanceof \Closure) { + if (\is_string($table) || $table instanceof \Closure) { $this->from[] = $table; } else { throw new \InvalidArgumentException(); @@ -486,11 +486,11 @@ final class Builder extends BuilderAbstract */ public function where($columns, $operator = null, $values = null, $boolean = 'and') : Builder { - if ($operator !== null && !is_array($operator) && !\in_array(strtolower($operator), self::OPERATORS)) { + if ($operator !== null && !\is_array($operator) && !\in_array(strtolower($operator), self::OPERATORS)) { throw new \InvalidArgumentException('Unknown operator.'); } - if (!is_array($columns)) { + if (!\is_array($columns)) { $columns = [$columns]; $operator = [$operator]; $values = [$values]; @@ -545,11 +545,11 @@ final class Builder extends BuilderAbstract */ public function getTableOfSystem($expression, string $systemIdentifier) : ?string { - if (($pos = strpos($expression, $systemIdentifier . '.' . $systemIdentifier)) === false) { + if (($pos = \strpos($expression, $systemIdentifier . '.' . $systemIdentifier)) === false) { return null; } - return explode('.', $expression)[0]; + return \explode('.', $expression)[0]; } /** @@ -648,7 +648,7 @@ final class Builder extends BuilderAbstract public function groupBy(...$columns) : Builder { foreach ($columns as $key => $column) { - if (is_string($column) || $column instanceof \Closure) { + if (\is_string($column) || $column instanceof \Closure) { $this->groups[] = $column; } else { throw new \InvalidArgumentException(); @@ -702,8 +702,8 @@ final class Builder extends BuilderAbstract */ public function orderBy($columns, $order = 'DESC') : Builder { - if (is_string($columns) || $columns instanceof \Closure) { - if (!is_string($order)) { + if (\is_string($columns) || $columns instanceof \Closure) { + if (!\is_string($order)) { throw new \InvalidArgumentException(); } @@ -712,9 +712,9 @@ final class Builder extends BuilderAbstract } $this->orders[$order][] = $columns; - } elseif (is_array($columns)) { + } elseif (\is_array($columns)) { foreach ($columns as $key => $column) { - $this->orders[is_string($order) ? $order : $order[$key]][] = $column; + $this->orders[\is_string($order) ? $order : $order[$key]][] = $column; } } else { throw new \InvalidArgumentException(); @@ -766,7 +766,7 @@ final class Builder extends BuilderAbstract */ public function union($query) : Builder { - if (!is_array($query)) { + if (!\is_array($query)) { $this->unions[] = $query; } else { $this->unions += $query; @@ -1022,7 +1022,7 @@ final class Builder extends BuilderAbstract $this->type = QueryType::UPDATE; foreach ($tables as $key => $table) { - if (is_string($table) || $table instanceof \Closure) { + if (\is_string($table) || $table instanceof \Closure) { $this->updates[] = $table; } else { throw new \InvalidArgumentException(); @@ -1216,7 +1216,7 @@ final class Builder extends BuilderAbstract { if (is_int($value)) { return \PDO::PARAM_INT; - } elseif (is_string($value) || is_float($value)) { + } elseif (\is_string($value) || is_float($value)) { return \PDO::PARAM_STR; } @@ -1236,7 +1236,7 @@ final class Builder extends BuilderAbstract */ public static function getPublicColumnName($column) : string { - if (is_string($column)) { + if (\is_string($column)) { return $column; } elseif ($column instanceof Column) { return $column->getPublicName(); diff --git a/DataStorage/Database/Query/Grammar/Grammar.php b/DataStorage/Database/Query/Grammar/Grammar.php index e462a20de..ed8e1f3f7 100644 --- a/DataStorage/Database/Query/Grammar/Grammar.php +++ b/DataStorage/Database/Query/Grammar/Grammar.php @@ -281,7 +281,7 @@ class Grammar extends GrammarAbstract $expression = ''; if (!$first) { - $expression = ' ' . strtoupper($element['boolean']) . ' '; + $expression = ' ' . \strtoupper($element['boolean']) . ' '; } if (is_string($element['column'])) { @@ -297,9 +297,9 @@ class Grammar extends GrammarAbstract // todo: handle IN(...) as operator if (isset($element['value'])) { - $expression .= ' ' . strtoupper($element['operator']) . ' ' . $this->compileValue($query, $element['value'], $query->getPrefix()); + $expression .= ' ' . \strtoupper($element['operator']) . ' ' . $this->compileValue($query, $element['value'], $query->getPrefix()); } else { - $operator = strtoupper($element['operator']) === '=' ? 'IS' : 'IS NOT'; + $operator = \strtoupper($element['operator']) === '=' ? 'IS' : 'IS NOT'; $expression .= ' ' . $operator . ' ' . $this->compileValue($query, $element['value'], $query->getPrefix()); } @@ -342,7 +342,7 @@ class Grammar extends GrammarAbstract $values .= $this->compileValue($query, $val, $prefix) . ', '; } - return '(' . rtrim($values, ', ') . ')'; + return '(' . \rtrim($values, ', ') . ')'; } elseif ($value instanceof \DateTime) { return $query->quote($value->format('Y-m-d H:i:s')); } elseif ($value === null) { @@ -411,7 +411,7 @@ class Grammar extends GrammarAbstract $expression .= $this->compileSystem($group, $query->getPrefix()) . ', '; } - $expression = rtrim($expression, ', '); + $expression = \rtrim($expression, ', '); return 'GROUP BY ' . $expression; } @@ -435,7 +435,7 @@ class Grammar extends GrammarAbstract $expression .= $this->compileSystem($column, $query->getPrefix()) . ', '; } - $expression = rtrim($expression, ', '); + $expression = \rtrim($expression, ', '); $expression .= ' ' . $key . ', '; } @@ -443,7 +443,7 @@ class Grammar extends GrammarAbstract return ''; } - $expression = rtrim($expression, ', '); + $expression = \rtrim($expression, ', '); return 'ORDER BY ' . $expression; } @@ -495,7 +495,7 @@ class Grammar extends GrammarAbstract return ''; } - return '(' . rtrim($cols, ', ') . ')'; + return '(' . \rtrim($cols, ', ') . ')'; } /** @@ -520,7 +520,7 @@ class Grammar extends GrammarAbstract return ''; } - return 'VALUES ' . rtrim($vals, ', '); + return 'VALUES ' . \rtrim($vals, ', '); } /** @@ -548,6 +548,6 @@ class Grammar extends GrammarAbstract return ''; } - return 'SET ' . rtrim($vals, ', '); + return 'SET ' . \rtrim($vals, ', '); } } diff --git a/Localization/Localization.php b/Localization/Localization.php index 83fbc5382..9be968ddc 100644 --- a/Localization/Localization.php +++ b/Localization/Localization.php @@ -232,7 +232,7 @@ final class Localization */ public function setLanguage(string $language) : void { - $language = strtolower($language); + $language = \strtolower($language); if (!ISO639x1Enum::isValidValue($language)) { throw new InvalidEnumValue($language); diff --git a/Localization/Money.php b/Localization/Money.php index d3534fc8e..ff658ce5c 100644 --- a/Localization/Money.php +++ b/Localization/Money.php @@ -115,9 +115,9 @@ final class Money implements \Serializable $right = $split[1]; } - $right = substr($right, 0, self::MAX_DECIMALS); + $right = \substr($right, 0, self::MAX_DECIMALS); - return ((int) $left) * 10 ** self::MAX_DECIMALS + (int) str_pad($right, self::MAX_DECIMALS, '0'); + return ((int) $left) * 10 ** self::MAX_DECIMALS + (int) \str_pad($right, self::MAX_DECIMALS, '0'); } /** @@ -185,10 +185,10 @@ final class Money implements \Serializable { $value = (string) round($this->value, -self::MAX_DECIMALS + $decimals); - $left = substr($value, 0, -self::MAX_DECIMALS); - $right = substr($value, -self::MAX_DECIMALS); + $left = \substr($value, 0, -self::MAX_DECIMALS); + $right = \substr($value, -self::MAX_DECIMALS); - return ($decimals > 0) ? number_format((float) $left, 0, $this->decimal, $this->thousands) . $this->decimal . substr($right, 0, $decimals) : (string) $left; + return ($decimals > 0) ? number_format((float) $left, 0, $this->decimal, $this->thousands) . $this->decimal . \substr($right, 0, $decimals) : (string) $left; } /** @@ -292,7 +292,7 @@ final class Money implements \Serializable */ public function abs() : Money { - $this->value = abs($this->value); + $this->value = \abs($this->value); return $this; }