mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-01-18 12:48:41 +00:00
More global namespace uses
This commit is contained in:
parent
138b631a65
commit
e28353a86b
|
|
@ -40,7 +40,7 @@ final class Lorenzkurve
|
|||
$i = 1;
|
||||
$n = \count($data);
|
||||
|
||||
sort($data);
|
||||
\sort($data);
|
||||
|
||||
foreach ($data as $key => $value) {
|
||||
$sum1 += $i * $value;
|
||||
|
|
|
|||
|
|
@ -130,7 +130,7 @@ final class CookieJar
|
|||
}
|
||||
|
||||
if (!headers_sent()) {
|
||||
setcookie($id, '', time() - 3600);
|
||||
\setcookie($id, '', time() - 3600);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
@ -177,7 +177,7 @@ final class CookieJar
|
|||
}
|
||||
|
||||
foreach ($this->cookies as $key => $cookie) {
|
||||
setcookie($key, $cookie['value'], $cookie['expiry'], $cookie['path'], $cookie['domain'], $cookie['secure'], $cookie['httponly']);
|
||||
\setcookie($key, $cookie['value'], $cookie['expiry'], $cookie['path'], $cookie['domain'], $cookie['secure'], $cookie['httponly']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -376,7 +376,7 @@ class DataMapperAbstract implements DataMapperInterface
|
|||
self::extend(__CLASS__);
|
||||
|
||||
$objId = self::createModelArray($obj);
|
||||
settype($objId, static::$columns[static::$primaryField]['type']);
|
||||
\settype($objId, static::$columns[static::$primaryField]['type']);
|
||||
$obj[static::$columns[static::$primaryField]['internal']] = $objId;
|
||||
|
||||
if ($relations === RelationType::ALL) {
|
||||
|
|
@ -556,7 +556,7 @@ class DataMapperAbstract implements DataMapperInterface
|
|||
$refProp->setAccessible(true);
|
||||
}
|
||||
|
||||
settype($objId, static::$columns[static::$primaryField]['type']);
|
||||
\settype($objId, static::$columns[static::$primaryField]['type']);
|
||||
$refProp->setValue($obj, $objId);
|
||||
|
||||
if (!$isPublic) {
|
||||
|
|
@ -1812,7 +1812,7 @@ class DataMapperAbstract implements DataMapperInterface
|
|||
if (\in_array(static::$columns[$column]['type'], ['string', 'int', 'float', 'bool'])) {
|
||||
// todo: what is this or condition for? seems to be wrong if obj null then it doesn't work anyways
|
||||
if ($value !== null || $refProp->getValue($obj) !== null) {
|
||||
settype($value, static::$columns[$column]['type']);
|
||||
\settype($value, static::$columns[$column]['type']);
|
||||
}
|
||||
|
||||
if ($hasPath) {
|
||||
|
|
@ -1871,7 +1871,7 @@ class DataMapperAbstract implements DataMapperInterface
|
|||
}
|
||||
|
||||
if (\in_array(static::$columns[$column]['type'], ['string', 'int', 'float', 'bool'])) {
|
||||
settype($value, static::$columns[$column]['type']);
|
||||
\settype($value, static::$columns[$column]['type']);
|
||||
} elseif (static::$columns[$column]['type'] === 'DateTime') {
|
||||
$value = new \DateTime($value ?? '');
|
||||
} elseif (static::$columns[$column]['type'] === 'Json') {
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ class HttpSession implements SessionInterface
|
|||
|
||||
$this->inactivityInterval = $inactivityInterval;
|
||||
|
||||
if (session_status() !== PHP_SESSION_ACTIVE && !headers_sent()) {
|
||||
if (\session_status() !== PHP_SESSION_ACTIVE && !\headers_sent()) {
|
||||
\session_set_cookie_params($liftetime, '/', '', false, true);
|
||||
\session_start();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -159,7 +159,7 @@ final class Localization
|
|||
foreach ($files as $file) {
|
||||
if (\stripos($file, $langCode) === 0) {
|
||||
$this->importLocale(
|
||||
json_decode(
|
||||
\json_decode(
|
||||
\file_get_contents(__DIR__ . '/../Localization/Defaults/Definitions/' . $file),
|
||||
true
|
||||
)
|
||||
|
|
@ -169,7 +169,7 @@ final class Localization
|
|||
}
|
||||
|
||||
$this->importLocale(
|
||||
json_decode(
|
||||
\json_decode(
|
||||
\file_get_contents(__DIR__ . '/../Localization/Defaults/Definitions/en_US.json'),
|
||||
true
|
||||
)
|
||||
|
|
|
|||
|
|
@ -511,7 +511,7 @@ final class FileLogger implements LoggerInterface
|
|||
|
||||
$logs[$id] = $line;
|
||||
$limit--;
|
||||
ksort($logs);
|
||||
\ksort($logs);
|
||||
$line = \fgetcsv($this->fp, 0, ';');
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ final class MonotoneChain
|
|||
public static function createConvexHull(array $points) : array
|
||||
{
|
||||
if (($n = \count($points)) > 1) {
|
||||
uasort($points, [self::class, 'sort']);
|
||||
\uasort($points, [self::class, 'sort']);
|
||||
|
||||
$k = 0;
|
||||
$result = [];
|
||||
|
|
@ -70,9 +70,9 @@ final class MonotoneChain
|
|||
$result[$k++] = $points[$i];
|
||||
}
|
||||
|
||||
ksort($result);
|
||||
\ksort($result);
|
||||
|
||||
return array_slice($result, 0, $k - 1);
|
||||
return \array_slice($result, 0, $k - 1);
|
||||
}
|
||||
|
||||
return $points;
|
||||
|
|
@ -104,7 +104,7 @@ final class MonotoneChain
|
|||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private static function sort(array $a, array $b) : float
|
||||
private static function \sort(array $a, array $b) : float
|
||||
{
|
||||
return $a['x'] === $b['x'] ? $a['y'] - $b['y'] : $a['x'] - $b['x'];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -772,7 +772,7 @@ class Matrix implements \ArrayAccess, \Iterator
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function rewind()
|
||||
public function \rewind()
|
||||
{
|
||||
$this->position = 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -199,7 +199,7 @@ final class Average
|
|||
$count = array_count_values($values);
|
||||
$best = \max($count);
|
||||
|
||||
return (float) (array_keys($count, $best)[0] ?? 0.0);
|
||||
return (float) (\array_keys($count, $best)[0] ?? 0.0);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -215,7 +215,7 @@ final class Average
|
|||
*/
|
||||
public static function median(array $values) : float
|
||||
{
|
||||
sort($values);
|
||||
\sort($values);
|
||||
$count = \count($values);
|
||||
$middleval = (int) floor(($count - 1) / 2);
|
||||
|
||||
|
|
@ -271,7 +271,7 @@ final class Average
|
|||
*/
|
||||
public static function harmonicMean(array $values, int $offset = 0) : float
|
||||
{
|
||||
sort($values);
|
||||
\sort($values);
|
||||
|
||||
if ($offset > 0) {
|
||||
$values = array_slice($values, $offset, -$offset);
|
||||
|
|
@ -334,7 +334,7 @@ final class Average
|
|||
*/
|
||||
public static function angleMean2(array $angles, int $offset = 0) : float
|
||||
{
|
||||
sort($angles);
|
||||
\sort($angles);
|
||||
|
||||
if ($offset > 0) {
|
||||
$angles = array_slice($angles, $offset, -$offset);
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ final class MeasureOfDispersion
|
|||
*/
|
||||
public static function range(array $values) : float
|
||||
{
|
||||
sort($values);
|
||||
\sort($values);
|
||||
$end = \end($values);
|
||||
$start = \reset($values);
|
||||
|
||||
|
|
|
|||
|
|
@ -146,7 +146,7 @@ final class Header extends HeaderAbstract
|
|||
*/
|
||||
public static function getAllHeaders() : array
|
||||
{
|
||||
if (function_exists('getallheaders')) {
|
||||
if (\function_exists('getallheaders')) {
|
||||
// @codeCoverageIgnoreStart
|
||||
return getallheaders();
|
||||
// @codeCoverageIgnoreEnd
|
||||
|
|
@ -241,7 +241,7 @@ final class Header extends HeaderAbstract
|
|||
|
||||
foreach ($this->header as $name => $arr) {
|
||||
foreach ($arr as $ele => $value) {
|
||||
header($name . ': ' . $value);
|
||||
\header($name . ': ' . $value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -234,11 +234,11 @@ final class Header extends HeaderAbstract
|
|||
|
||||
foreach ($this->header as $name => $arr) {
|
||||
foreach ($arr as $ele => $value) {
|
||||
header($name . ': ' . $value);
|
||||
\header($name . ': ' . $value);
|
||||
}
|
||||
}
|
||||
|
||||
header("X-Powered-By: hidden");
|
||||
\header("X-Powered-By: hidden");
|
||||
|
||||
$this->lock();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,12 +42,12 @@ final class Rest
|
|||
throw new \Exception();
|
||||
}
|
||||
|
||||
curl_setopt($curl, CURLOPT_NOBODY, true);
|
||||
curl_setopt($curl, CURLOPT_HEADER, false);
|
||||
\curl_setopt($curl, CURLOPT_NOBODY, true);
|
||||
\curl_setopt($curl, CURLOPT_HEADER, false);
|
||||
|
||||
switch ($request->getMethod()) {
|
||||
case RequestMethod::GET:
|
||||
curl_setopt($curl, CURLOPT_HTTPGET, true);
|
||||
\curl_setopt($curl, CURLOPT_HTTPGET, true);
|
||||
break;
|
||||
case RequestMethod::PUT:
|
||||
\curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'PUT');
|
||||
|
|
|
|||
|
|
@ -118,7 +118,7 @@ abstract class ModuleAbstract
|
|||
public static function getLocalization(string $language, string $destination) : array
|
||||
{
|
||||
$lang = [];
|
||||
if (file_exists($oldPath = __DIR__ . '/../../Modules/' . static::MODULE_NAME . '/Theme/' . $destination . '/Lang/' . $language . '.lang.php')) {
|
||||
if (\file_exists($oldPath = __DIR__ . '/../../Modules/' . static::MODULE_NAME . '/Theme/' . $destination . '/Lang/' . $language . '.lang.php')) {
|
||||
/** @noinspection PhpIncludeInspection */
|
||||
return include $oldPath;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -249,7 +249,7 @@ final class ModuleManager
|
|||
public function getAllModules() : array
|
||||
{
|
||||
if (empty($this->all)) {
|
||||
chdir($this->modulePath);
|
||||
\chdir($this->modulePath);
|
||||
$files = \glob('*', GLOB_ONLYDIR);
|
||||
$c = \count($files);
|
||||
|
||||
|
|
@ -572,7 +572,7 @@ final class ModuleManager
|
|||
*/
|
||||
public function installProviding(string $from, string $for) : void
|
||||
{
|
||||
if (file_exists($this->modulePath . '/' . $from . '/Admin/Install/' . $for . '.php')) {
|
||||
if (\file_exists($this->modulePath . '/' . $from . '/Admin/Install/' . $for . '.php')) {
|
||||
$class = '\\Modules\\' . $from . '\\Admin\\Install\\' . $for;
|
||||
$class::install($this->modulePath, $this->app->dbPool);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ class CommandManager implements \Countable
|
|||
*/
|
||||
public function detach(string $cmd, $source) : void
|
||||
{
|
||||
if (array_key_exists($cmd, $this->commands)) {
|
||||
if (\array_key_exists($cmd, $this->commands)) {
|
||||
unset($this->commands[$cmd]);
|
||||
$this->count--;
|
||||
}
|
||||
|
|
@ -98,7 +98,7 @@ class CommandManager implements \Countable
|
|||
*/
|
||||
public function trigger(string $cmd, $conn, $para)
|
||||
{
|
||||
if (array_key_exists($cmd, $this->commands)) {
|
||||
if (\array_key_exists($cmd, $this->commands)) {
|
||||
return $this->commands[$cmd][0]($conn, $para);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ class Server extends SocketAbstract
|
|||
$connected = @fsockopen("www.google.com", 80);
|
||||
|
||||
if ($connected) {
|
||||
fclose($connected);
|
||||
\fclose($connected);
|
||||
|
||||
return true;
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ class PriorityQueue implements \Countable, \Serializable
|
|||
{
|
||||
do {
|
||||
$key = \rand();
|
||||
} while (array_key_exists($key, $this->queue));
|
||||
} while (\array_key_exists($key, $this->queue));
|
||||
|
||||
if ($this->count === 0) {
|
||||
$this->queue[$key] = ['key' => $key, 'job' => $job, 'priority' => $priority];
|
||||
|
|
@ -80,7 +80,7 @@ class PriorityQueue implements \Countable, \Serializable
|
|||
}
|
||||
|
||||
$original = [];
|
||||
array_splice($original, $pos, 0, [$key => ['key' => $key, 'job' => $job, 'priority' => $priority]]);
|
||||
\array_splice($original, $pos, 0, [$key => ['key' => $key, 'job' => $job, 'priority' => $priority]]);
|
||||
}
|
||||
|
||||
return $key;
|
||||
|
|
|
|||
|
|
@ -272,7 +272,7 @@ class Directory extends FileAbstract implements DirectoryInterface
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function rewind()
|
||||
public function \rewind()
|
||||
{
|
||||
\reset($this->nodes);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -179,7 +179,7 @@ class File extends FileAbstract implements FileInterface
|
|||
$con = self::ftpConnect($http);
|
||||
$exists = self::ftpExists($con, $http->getPath());
|
||||
|
||||
fclose($con);
|
||||
\fclose($con);
|
||||
|
||||
return $exists;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ final class Directory extends FileAbstract implements DirectoryInterface
|
|||
$this->filter = \ltrim($filter, '\\/');
|
||||
parent::__construct($path);
|
||||
|
||||
if (file_exists($this->path)) {
|
||||
if (\file_exists($this->path)) {
|
||||
$this->index();
|
||||
}
|
||||
}
|
||||
|
|
@ -449,7 +449,7 @@ final class Directory extends FileAbstract implements DirectoryInterface
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function rewind()
|
||||
public function \rewind()
|
||||
{
|
||||
\reset($this->nodes);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -283,10 +283,10 @@ final class File extends FileAbstract implements FileInterface
|
|||
}
|
||||
|
||||
if ($overwrite && \file_exists($to)) {
|
||||
unlink($to);
|
||||
\unlink($to);
|
||||
}
|
||||
|
||||
copy($from, $to);
|
||||
\copy($from, $to);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
@ -317,7 +317,7 @@ final class File extends FileAbstract implements FileInterface
|
|||
return false;
|
||||
}
|
||||
|
||||
unlink($path);
|
||||
\unlink($path);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,11 +48,11 @@ final class SystemUtils
|
|||
|
||||
if (\stristr(PHP_OS, 'WIN')) {
|
||||
$memArr = [];
|
||||
exec('wmic memorychip get capacity', $memArr);
|
||||
\exec('wmic memorychip get capacity', $memArr);
|
||||
|
||||
$mem = \array_sum($memArr) / 1024;
|
||||
} elseif (\stristr(PHP_OS, 'LINUX')) {
|
||||
$fh = \fopen('/proc/meminfo', 'r');
|
||||
$fh = \fopen('/proc/meminfo', 'r');
|
||||
|
||||
if ($fh === false) {
|
||||
return $mem;
|
||||
|
|
@ -113,7 +113,7 @@ final class SystemUtils
|
|||
|
||||
if (\stristr(PHP_OS, 'WIN') !== false) {
|
||||
$cpuUsage = null;
|
||||
exec('wmic cpu get LoadPercentage', $cpuUsage);
|
||||
\exec('wmic cpu get LoadPercentage', $cpuUsage);
|
||||
$cpuUsage = $cpuUsage[1];
|
||||
} elseif (\stristr(PHP_OS, 'LINUX') !== false) {
|
||||
$cpuUsage = \sys_getloadavg()[0] * 100;
|
||||
|
|
|
|||
|
|
@ -285,7 +285,7 @@ final class ArrayUtils
|
|||
|
||||
/** @noinspection PhpMethodParametersCountMismatchInspection */
|
||||
\fputcsv($outstream, $data, $delimiter, $enclosure, $escape);
|
||||
rewind($outstream);
|
||||
\rewind($outstream);
|
||||
$csv = \fgets($outstream);
|
||||
\fclose($outstream);
|
||||
|
||||
|
|
|
|||
|
|
@ -82,9 +82,9 @@ class Numeric
|
|||
for ($i = 1; $i <= $numberLen; ++$i) {
|
||||
$newOutput = \bcadd(
|
||||
$newOutput,
|
||||
bcmul(
|
||||
\bcmul(
|
||||
(string) \array_search($number[$i - 1], $fromBase),
|
||||
bcpow((string) $fromLen, (string) ($numberLen - $i))
|
||||
\bcpow((string) $fromLen, (string) ($numberLen - $i))
|
||||
)
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -83,13 +83,13 @@ final class Dictionary
|
|||
$source = \str_replace($source[0], '', $source);
|
||||
}
|
||||
|
||||
sort($count);
|
||||
\sort($count);
|
||||
while (\count($count) > 1) {
|
||||
$row1 = array_shift($count);
|
||||
$row2 = array_shift($count);
|
||||
$count[] = [$row1[0] + $row2[0], [$row1, $row2]];
|
||||
|
||||
sort($count);
|
||||
\sort($count);
|
||||
}
|
||||
|
||||
$this->fill(\is_array($count[0][1]) ? $count[0][1] : $count);
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ class TarGz implements ArchiveInterface
|
|||
}
|
||||
|
||||
$pack = Gz::pack($destination . '.tmp', $destination, $overwrite);
|
||||
unlink($destination . '.tmp');
|
||||
\unlink($destination . '.tmp');
|
||||
|
||||
return $pack;
|
||||
}
|
||||
|
|
@ -51,7 +51,7 @@ class TarGz implements ArchiveInterface
|
|||
}
|
||||
|
||||
$unpacked = Tar::unpack($destination . '.tmp', $destination);
|
||||
unlink($destination . '.tmp');
|
||||
\unlink($destination . '.tmp');
|
||||
|
||||
return $unpacked;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -80,22 +80,22 @@ class JobQueue
|
|||
$this->run = false;
|
||||
}
|
||||
|
||||
sleep(1);
|
||||
\sleep(1);
|
||||
}
|
||||
|
||||
sleep(1);
|
||||
\sleep(1);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
private function runAsDeamon()
|
||||
{
|
||||
ob_end_clean();
|
||||
fclose(STDIN);
|
||||
fclose(STDOUT);
|
||||
fclose(STDERR);
|
||||
\ob_end_clean();
|
||||
\fclose(STDIN);
|
||||
\fclose(STDOUT);
|
||||
\fclose(STDERR);
|
||||
|
||||
register_shutdown_function(function() { posix_kill(posix_getpid(), SIGHUP); });
|
||||
\register_shutdown_function(function() { \posix_kill(\posix_getpid(), SIGHUP); });
|
||||
}
|
||||
|
||||
public function setRunning(bool $run = true) : void
|
||||
|
|
|
|||
|
|
@ -38,9 +38,9 @@ class ArrayRandomize
|
|||
$shuffled = [];
|
||||
|
||||
while (!empty($arr)) {
|
||||
$rnd = (int) array_rand($arr);
|
||||
$rnd = (int) \array_rand($arr);
|
||||
$shuffled[] = $arr[$rnd] ?? null;
|
||||
array_splice($arr, $rnd, 1);
|
||||
\array_splice($arr, $rnd, 1);
|
||||
}
|
||||
|
||||
return $shuffled;
|
||||
|
|
@ -60,7 +60,7 @@ class ArrayRandomize
|
|||
$shuffled = [];
|
||||
|
||||
for ($i = \count($arr) - 1; $i > 0; $i--) {
|
||||
$rnd = mt_rand(0, $i);
|
||||
$rnd = \mt_rand(0, $i);
|
||||
$shuffled[$i] = $arr[$rnd];
|
||||
$shuffled[$rnd] = $arr[$i];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ final class StringUtils
|
|||
public static function mb_contains(string $haystack, array $needles) : bool
|
||||
{
|
||||
foreach ($needles as $needle) {
|
||||
if (mb_strpos($haystack, $needle) !== false) {
|
||||
if (\mb_strpos($haystack, $needle) !== false) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -173,7 +173,7 @@ final class StringUtils
|
|||
}
|
||||
|
||||
foreach ($needles as $needle) {
|
||||
if ($needle === '' || mb_strrpos($haystack, $needle, -mb_strlen($haystack)) !== false) {
|
||||
if ($needle === '' || \mb_strrpos($haystack, $needle, -\mb_strlen($haystack)) !== false) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -205,7 +205,7 @@ final class StringUtils
|
|||
}
|
||||
|
||||
foreach ($needles as $needle) {
|
||||
if ($needle === '' || (($temp = mb_strlen($haystack) - mb_strlen($needle)) >= 0 && mb_strpos($haystack, $needle, $temp) !== false)) {
|
||||
if ($needle === '' || (($temp = \mb_strlen($haystack) - \mb_strlen($needle)) >= 0 && mb_strpos($haystack, $needle, $temp) !== false)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -224,9 +224,9 @@ final class StringUtils
|
|||
*/
|
||||
public static function mb_ucfirst(string $string) : string
|
||||
{
|
||||
$strlen = mb_strlen($string);
|
||||
$firstChar = mb_substr($string, 0, 1);
|
||||
$then = mb_substr($string, 1, $strlen - 1);
|
||||
$strlen = \mb_strlen($string);
|
||||
$firstChar = \mb_substr($string, 0, 1);
|
||||
$then = \mb_substr($string, 1, $strlen - 1);
|
||||
|
||||
return mb_strtoupper($firstChar) . $then;
|
||||
}
|
||||
|
|
@ -242,9 +242,9 @@ final class StringUtils
|
|||
*/
|
||||
public static function mb_lcfirst(string $string) : string
|
||||
{
|
||||
$strlen = mb_strlen($string);
|
||||
$firstChar = mb_substr($string, 0, 1);
|
||||
$then = mb_substr($string, 1, $strlen - 1);
|
||||
$strlen = \mb_strlen($string);
|
||||
$firstChar = \mb_substr($string, 0, 1);
|
||||
$then = \mb_substr($string, 1, $strlen - 1);
|
||||
|
||||
return mb_strtolower($firstChar) . $then;
|
||||
}
|
||||
|
|
@ -264,9 +264,9 @@ final class StringUtils
|
|||
if ($charlist === ' ') {
|
||||
return \trim($string);
|
||||
} else {
|
||||
$charlist = \str_replace('/', '\/', preg_quote($charlist));
|
||||
$charlist = \str_replace('/', '\/', \preg_quote($charlist));
|
||||
|
||||
return preg_replace('/(^[' . $charlist . ']+)|([ ' . $charlist . ']+$)/us', '', $string);
|
||||
return \preg_replace('/(^[' . $charlist . ']+)|([ ' . $charlist . ']+$)/us', '', $string);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -285,9 +285,9 @@ final class StringUtils
|
|||
if ($charlist === ' ') {
|
||||
return \rtrim($string);
|
||||
} else {
|
||||
$charlist = \str_replace('/', '\/', preg_quote($charlist));
|
||||
$charlist = \str_replace('/', '\/', \preg_quote($charlist));
|
||||
|
||||
return preg_replace('/([' . $charlist . ']+$)/us', '', $string);
|
||||
return \preg_replace('/([' . $charlist . ']+$)/us', '', $string);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -306,9 +306,9 @@ final class StringUtils
|
|||
if ($charlist === ' ') {
|
||||
return \ltrim($string);
|
||||
} else {
|
||||
$charlist = \str_replace('/', '\/', preg_quote($charlist));
|
||||
$charlist = \str_replace('/', '\/', \preg_quote($charlist));
|
||||
|
||||
return preg_replace('/(^[' . $charlist . ']+)/us', '', $string);
|
||||
return \preg_replace('/(^[' . $charlist . ']+)/us', '', $string);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -353,7 +353,7 @@ final class StringUtils
|
|||
public static function getEntropy(string $value) : float
|
||||
{
|
||||
$entroy = 0.0;
|
||||
$size = mb_strlen($value);
|
||||
$size = \mb_strlen($value);
|
||||
$countChars = self::mb_count_chars($value);
|
||||
|
||||
foreach ($countChars as $v) {
|
||||
|
|
@ -375,13 +375,13 @@ final class StringUtils
|
|||
*/
|
||||
public static function mb_count_chars(string $input) : array
|
||||
{
|
||||
$l = mb_strlen($input, 'UTF-8');
|
||||
$l = \mb_strlen($input, 'UTF-8');
|
||||
$unique = [];
|
||||
|
||||
for ($i = 0; $i < $l; ++$i) {
|
||||
$char = mb_substr($input, $i, 1, 'UTF-8');
|
||||
$char = \mb_substr($input, $i, 1, 'UTF-8');
|
||||
|
||||
if (!array_key_exists($char, $unique)) {
|
||||
if (!\array_key_exists($char, $unique)) {
|
||||
$unique[$char] = 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ class Cron extends SchedulerAbstract
|
|||
$this->run('-l > ' . __DIR__ . '/tmpcron.tmp');
|
||||
\file_put_contents(__DIR__ . '/tmpcron.tmp', $task->__toString() . "\n", FILE_APPEND);
|
||||
$this->run(__DIR__ . '/tmpcron.tmp');
|
||||
unlink(__DIR__ . '/tmpcron.tmp');
|
||||
\unlink(__DIR__ . '/tmpcron.tmp');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -63,7 +63,7 @@ class Cron extends SchedulerAbstract
|
|||
}
|
||||
|
||||
$this->run(__DIR__ . '/tmpcron.tmp');
|
||||
unlink(__DIR__ . '/tmpcron.tmp');
|
||||
\unlink(__DIR__ . '/tmpcron.tmp');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -101,7 +101,7 @@ class Cron extends SchedulerAbstract
|
|||
}
|
||||
|
||||
$this->run(__DIR__ . '/tmpcron.tmp');
|
||||
unlink(__DIR__ . '/tmpcron.tmp');
|
||||
\unlink(__DIR__ . '/tmpcron.tmp');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -137,7 +137,7 @@ class Cron extends SchedulerAbstract
|
|||
}
|
||||
|
||||
$this->run(__DIR__ . '/tmpcron.tmp');
|
||||
unlink(__DIR__ . '/tmpcron.tmp');
|
||||
\unlink(__DIR__ . '/tmpcron.tmp');
|
||||
|
||||
return $jobs;
|
||||
}
|
||||
|
|
@ -169,7 +169,7 @@ class Cron extends SchedulerAbstract
|
|||
}
|
||||
|
||||
$this->run(__DIR__ . '/tmpcron.tmp');
|
||||
unlink(__DIR__ . '/tmpcron.tmp');
|
||||
\unlink(__DIR__ . '/tmpcron.tmp');
|
||||
|
||||
return $jobs;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -184,7 +184,7 @@ abstract class ViewAbstract implements \Serializable
|
|||
$this->views[$id] = $view;
|
||||
|
||||
if ($order !== 0) {
|
||||
uasort($this->views, ['\phpOMS\Views\View', 'viewSort']);
|
||||
\uasort($this->views, ['\phpOMS\Views\View', 'viewSort']);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
@ -250,7 +250,7 @@ abstract class ViewAbstract implements \Serializable
|
|||
}
|
||||
|
||||
try {
|
||||
ob_start();
|
||||
\ob_start();
|
||||
/** @noinspection PhpIncludeInspection */
|
||||
$includeData = include $path;
|
||||
$ob = (string) ob_get_clean();
|
||||
|
|
|
|||
|
|
@ -2,9 +2,9 @@
|
|||
|
||||
ini_set('memory_limit', '2048M');
|
||||
|
||||
if (file_exists('vendor/autoload.php')) {
|
||||
if (\file_exists('vendor/autoload.php')) {
|
||||
include_once 'vendor/autoload.php';
|
||||
} elseif (file_exists('../../vendor/autoload.php')) {
|
||||
} elseif (\file_exists('../../vendor/autoload.php')) {
|
||||
include_once '../../vendor/autoload.php';
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -19,8 +19,8 @@ class FileCacheTest extends \PHPUnit\Framework\TestCase
|
|||
{
|
||||
public function testDefault()
|
||||
{
|
||||
if (file_exists(__DIR__ . '/Cache')) {
|
||||
rmdir(__DIR__ . '/Cache');
|
||||
if (\file_exists(__DIR__ . '/Cache')) {
|
||||
\rmdir(__DIR__ . '/Cache');
|
||||
}
|
||||
|
||||
$cache = new FileCache(__DIR__ . '/Cache');
|
||||
|
|
@ -30,15 +30,15 @@ class FileCacheTest extends \PHPUnit\Framework\TestCase
|
|||
self::assertEquals(50, $cache->getThreshold());
|
||||
self::assertEquals(null, $cache->get('test'));
|
||||
|
||||
if (file_exists(__DIR__ . '/Cache')) {
|
||||
rmdir(__DIR__ . '/Cache');
|
||||
if (\file_exists(__DIR__ . '/Cache')) {
|
||||
\rmdir(__DIR__ . '/Cache');
|
||||
}
|
||||
}
|
||||
|
||||
public function testGetSet()
|
||||
{
|
||||
if (file_exists(__DIR__ . '/Cache')) {
|
||||
rmdir(__DIR__ . '/Cache');
|
||||
if (\file_exists(__DIR__ . '/Cache')) {
|
||||
\rmdir(__DIR__ . '/Cache');
|
||||
}
|
||||
|
||||
$cache = new FileCache(__DIR__ . '/Cache');
|
||||
|
|
@ -70,8 +70,8 @@ class FileCacheTest extends \PHPUnit\Framework\TestCase
|
|||
$cache->flushAll();
|
||||
self::assertEquals(null, $cache->get('key5'));
|
||||
|
||||
if (file_exists(__DIR__ . '/Cache')) {
|
||||
rmdir(__DIR__ . '/Cache');
|
||||
if (\file_exists(__DIR__ . '/Cache')) {
|
||||
\rmdir(__DIR__ . '/Cache');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,15 +27,15 @@ class FileLoggerTest extends \PHPUnit\Framework\TestCase
|
|||
self::assertObjectHasAttribute('fp', $log);
|
||||
self::assertObjectHasAttribute('path', $log);
|
||||
|
||||
if (file_exists(__DIR__ . '/' . date('Y-m-d') . '.log')) {
|
||||
unlink(__DIR__ . '/' . date('Y-m-d') . '.log');
|
||||
if (\file_exists(__DIR__ . '/' . date('Y-m-d') . '.log')) {
|
||||
\unlink(__DIR__ . '/' . date('Y-m-d') . '.log');
|
||||
}
|
||||
}
|
||||
|
||||
public function testDefault()
|
||||
{
|
||||
if (file_exists(__DIR__ . '/' . date('Y-m-d') . '.log')) {
|
||||
unlink(__DIR__ . '/' . date('Y-m-d') . '.log');
|
||||
if (\file_exists(__DIR__ . '/' . date('Y-m-d') . '.log')) {
|
||||
\unlink(__DIR__ . '/' . date('Y-m-d') . '.log');
|
||||
}
|
||||
|
||||
$log = FileLogger::getInstance(__DIR__);
|
||||
|
|
@ -44,15 +44,15 @@ class FileLoggerTest extends \PHPUnit\Framework\TestCase
|
|||
self::assertEquals([], $log->get());
|
||||
self::assertEquals([], $log->getByLine());
|
||||
|
||||
if (file_exists(__DIR__ . '/' . date('Y-m-d') . '.log')) {
|
||||
unlink(__DIR__ . '/' . date('Y-m-d') . '.log');
|
||||
if (\file_exists(__DIR__ . '/' . date('Y-m-d') . '.log')) {
|
||||
\unlink(__DIR__ . '/' . date('Y-m-d') . '.log');
|
||||
}
|
||||
}
|
||||
|
||||
public function testGetSet()
|
||||
{
|
||||
if (file_exists(__DIR__ . '/test.log')) {
|
||||
unlink(__DIR__ . '/test.log');
|
||||
if (\file_exists(__DIR__ . '/test.log')) {
|
||||
\unlink(__DIR__ . '/test.log');
|
||||
}
|
||||
|
||||
$log = new FileLogger(__DIR__ . '/test.log', false);
|
||||
|
|
@ -124,7 +124,7 @@ class FileLoggerTest extends \PHPUnit\Framework\TestCase
|
|||
self::assertEquals([6, 7, 8, 9, 10], array_keys($log->get(5, 1)));
|
||||
self::assertEquals('alert', $log->getByLine(2)['level']);
|
||||
|
||||
ob_start();
|
||||
\ob_start();
|
||||
$log->console(FileLogger::MSG_FULL, true, [
|
||||
'message' => 'msg',
|
||||
'line' => 11,
|
||||
|
|
@ -134,18 +134,18 @@ class FileLoggerTest extends \PHPUnit\Framework\TestCase
|
|||
self::assertEquals(1, $log->countLogs()['info'] ?? 0);
|
||||
self::assertTrue(\stripos($ob, 'msg;') !== false);
|
||||
|
||||
ob_start();
|
||||
\ob_start();
|
||||
$log->console('test', true);
|
||||
$ob = ob_get_clean();
|
||||
self::assertEquals(\date('[Y-m-d H:i:s] ') . "test\r\n", $ob);
|
||||
|
||||
unlink(__DIR__ . '/test.log');
|
||||
\unlink(__DIR__ . '/test.log');
|
||||
|
||||
if (file_exists(__DIR__ . '/' . date('Y-m-d') . '.log')) {
|
||||
unlink(__DIR__ . '/' . date('Y-m-d') . '.log');
|
||||
if (\file_exists(__DIR__ . '/' . date('Y-m-d') . '.log')) {
|
||||
\unlink(__DIR__ . '/' . date('Y-m-d') . '.log');
|
||||
}
|
||||
|
||||
ob_clean();
|
||||
\ob_clean();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -170,12 +170,12 @@ class FileLoggerTest extends \PHPUnit\Framework\TestCase
|
|||
|
||||
public static function tearDownAfterClass()
|
||||
{
|
||||
if (file_exists(__DIR__ . '/test.log')) {
|
||||
unlink(__DIR__ . '/test.log');
|
||||
if (\file_exists(__DIR__ . '/test.log')) {
|
||||
\unlink(__DIR__ . '/test.log');
|
||||
}
|
||||
|
||||
if (file_exists(__DIR__ . '/' . date('Y-m-d') . '.log')) {
|
||||
unlink(__DIR__ . '/' . date('Y-m-d') . '.log');
|
||||
if (\file_exists(__DIR__ . '/' . date('Y-m-d') . '.log')) {
|
||||
\unlink(__DIR__ . '/' . date('Y-m-d') . '.log');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -63,13 +63,13 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase
|
|||
$dirTestPath = self::BASE . '/dirtest';
|
||||
|
||||
self::assertTrue(Directory::copy($dirTestPath, self::BASE . '/newdirtest'));
|
||||
self::assertTrue(file_exists(self::BASE . '/newdirtest/sub/path/test3.txt'));
|
||||
self::assertTrue(\file_exists(self::BASE . '/newdirtest/sub/path/test3.txt'));
|
||||
|
||||
self::assertTrue(Directory::delete($dirTestPath));
|
||||
self::assertFalse(Directory::exists($dirTestPath));
|
||||
|
||||
self::assertTrue(Directory::move(self::BASE . '/newdirtest', $dirTestPath));
|
||||
self::assertTrue(file_exists($dirTestPath . '/sub/path/test3.txt'));
|
||||
self::assertTrue(\file_exists($dirTestPath . '/sub/path/test3.txt'));
|
||||
|
||||
self::assertEquals(4, Directory::count($dirTestPath));
|
||||
self::assertEquals(1, Directory::count($dirTestPath, false));
|
||||
|
|
|
|||
|
|
@ -76,15 +76,15 @@ class FileTest extends \PHPUnit\Framework\TestCase
|
|||
self::assertFalse(File::exists($newPath2));
|
||||
self::assertFalse(File::delete($newPath2));
|
||||
|
||||
unlink($newPath);
|
||||
rmdir(self::BASE . '/sub/path/');
|
||||
rmdir(self::BASE . '/sub/');
|
||||
\unlink($newPath);
|
||||
\rmdir(self::BASE . '/sub/path/');
|
||||
\rmdir(self::BASE . '/sub/');
|
||||
|
||||
self::assertTrue(File::create($testFile));
|
||||
self::assertFalse(File::create($testFile));
|
||||
self::assertEquals('', File::get($testFile));
|
||||
|
||||
unlink($testFile);
|
||||
\unlink($testFile);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -76,15 +76,15 @@ class FtpStorageTest extends \PHPUnit\Framework\TestCase
|
|||
self::assertFalse(FtpStorage::exists($newPath2));
|
||||
self::assertFalse(FtpStorage::delete($newPath2));
|
||||
|
||||
unlink($newPath);
|
||||
rmdir(self::BASE . '/sub/path/');
|
||||
rmdir(self::BASE . '/sub/');
|
||||
\unlink($newPath);
|
||||
\rmdir(self::BASE . '/sub/path/');
|
||||
\rmdir(self::BASE . '/sub/');
|
||||
|
||||
self::assertTrue(FtpStorage::create($testFile));
|
||||
self::assertFalse(FtpStorage::create($testFile));
|
||||
self::assertEquals('', FtpStorage::get($testFile));
|
||||
|
||||
unlink($testFile);
|
||||
\unlink($testFile);
|
||||
}
|
||||
|
||||
public function testDirectory()
|
||||
|
|
@ -127,13 +127,13 @@ class FtpStorageTest extends \PHPUnit\Framework\TestCase
|
|||
|
||||
$dirTestPath = self::BASE . '/dirtest';
|
||||
self::assertTrue(FtpStorage::copy($dirTestPath, self::BASE . '/newdirtest'));
|
||||
self::assertTrue(file_exists(self::BASE . '/newdirtest/sub/path/test3.txt'));
|
||||
self::assertTrue(\file_exists(self::BASE . '/newdirtest/sub/path/test3.txt'));
|
||||
|
||||
self::assertTrue(FtpStorage::delete($dirTestPath));
|
||||
self::assertFalse(FtpStorage::exists($dirTestPath));
|
||||
|
||||
self::assertTrue(FtpStorage::move(self::BASE . '/newdirtest', $dirTestPath));
|
||||
self::assertTrue(file_exists($dirTestPath . '/sub/path/test3.txt'));
|
||||
self::assertTrue(\file_exists($dirTestPath . '/sub/path/test3.txt'));
|
||||
|
||||
self::assertEquals(4, FtpStorage::count($dirTestPath));
|
||||
self::assertEquals(1, FtpStorage::count($dirTestPath, false));
|
||||
|
|
|
|||
|
|
@ -52,13 +52,13 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase
|
|||
$dirTestPath = __DIR__ . '/dirtest';
|
||||
|
||||
self::assertTrue(Directory::copy($dirTestPath, __DIR__ . '/newdirtest'));
|
||||
self::assertTrue(file_exists(__DIR__ . '/newdirtest/sub/path/test3.txt'));
|
||||
self::assertTrue(\file_exists(__DIR__ . '/newdirtest/sub/path/test3.txt'));
|
||||
|
||||
self::assertTrue(Directory::delete($dirTestPath));
|
||||
self::assertFalse(Directory::exists($dirTestPath));
|
||||
|
||||
self::assertTrue(Directory::move(__DIR__ . '/newdirtest', $dirTestPath));
|
||||
self::assertTrue(file_exists($dirTestPath . '/sub/path/test3.txt'));
|
||||
self::assertTrue(\file_exists($dirTestPath . '/sub/path/test3.txt'));
|
||||
|
||||
self::assertEquals(4, Directory::count($dirTestPath));
|
||||
self::assertEquals(1, Directory::count($dirTestPath, false));
|
||||
|
|
|
|||
|
|
@ -69,15 +69,15 @@ class FileTest extends \PHPUnit\Framework\TestCase
|
|||
self::assertFalse(File::exists($newPath2));
|
||||
self::assertFalse(File::delete($newPath2));
|
||||
|
||||
unlink($newPath);
|
||||
rmdir(__DIR__ . '/sub/path/');
|
||||
rmdir(__DIR__ . '/sub/');
|
||||
\unlink($newPath);
|
||||
\rmdir(__DIR__ . '/sub/path/');
|
||||
\rmdir(__DIR__ . '/sub/');
|
||||
|
||||
self::assertTrue(File::create($testFile));
|
||||
self::assertFalse(File::create($testFile));
|
||||
self::assertEquals('', File::get($testFile));
|
||||
|
||||
unlink($testFile);
|
||||
\unlink($testFile);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -69,15 +69,15 @@ class LocalStorageTest extends \PHPUnit\Framework\TestCase
|
|||
self::assertFalse(LocalStorage::exists($newPath2));
|
||||
self::assertFalse(LocalStorage::delete($newPath2));
|
||||
|
||||
unlink($newPath);
|
||||
rmdir(__DIR__ . '/sub/path/');
|
||||
rmdir(__DIR__ . '/sub/');
|
||||
\unlink($newPath);
|
||||
\rmdir(__DIR__ . '/sub/path/');
|
||||
\rmdir(__DIR__ . '/sub/');
|
||||
|
||||
self::assertTrue(LocalStorage::create($testFile));
|
||||
self::assertFalse(LocalStorage::create($testFile));
|
||||
self::assertEquals('', LocalStorage::get($testFile));
|
||||
|
||||
unlink($testFile);
|
||||
\unlink($testFile);
|
||||
}
|
||||
|
||||
public function testDirectory()
|
||||
|
|
@ -112,13 +112,13 @@ class LocalStorageTest extends \PHPUnit\Framework\TestCase
|
|||
{
|
||||
$dirTestPath = __DIR__ . '/dirtest';
|
||||
self::assertTrue(LocalStorage::copy($dirTestPath, __DIR__ . '/newdirtest'));
|
||||
self::assertTrue(file_exists(__DIR__ . '/newdirtest/sub/path/test3.txt'));
|
||||
self::assertTrue(\file_exists(__DIR__ . '/newdirtest/sub/path/test3.txt'));
|
||||
|
||||
self::assertTrue(LocalStorage::delete($dirTestPath));
|
||||
self::assertFalse(LocalStorage::exists($dirTestPath));
|
||||
|
||||
self::assertTrue(LocalStorage::move(__DIR__ . '/newdirtest', $dirTestPath));
|
||||
self::assertTrue(file_exists($dirTestPath . '/sub/path/test3.txt'));
|
||||
self::assertTrue(\file_exists($dirTestPath . '/sub/path/test3.txt'));
|
||||
|
||||
self::assertEquals(4, LocalStorage::count($dirTestPath));
|
||||
self::assertEquals(1, LocalStorage::count($dirTestPath, false));
|
||||
|
|
|
|||
|
|
@ -19,11 +19,11 @@ class UnhandledHandlerTest extends \PHPUnit\Framework\TestCase
|
|||
{
|
||||
public function testErrorHandling()
|
||||
{
|
||||
set_exception_handler(['\phpOMS\UnhandledHandler', 'exceptionHandler']);
|
||||
set_error_handler(['\phpOMS\UnhandledHandler', 'errorHandler']);
|
||||
register_shutdown_function(['\phpOMS\UnhandledHandler', 'shutdownHandler']);
|
||||
\set_exception_handler(['\phpOMS\UnhandledHandler', 'exceptionHandler']);
|
||||
\set_error_handler(['\phpOMS\UnhandledHandler', 'errorHandler']);
|
||||
\register_shutdown_function(['\phpOMS\UnhandledHandler', 'shutdownHandler']);
|
||||
|
||||
trigger_error('', E_USER_ERROR);
|
||||
\trigger_error('', E_USER_ERROR);
|
||||
|
||||
UnhandledHandler::shutdownHandler();
|
||||
|
||||
|
|
|
|||
|
|
@ -20,13 +20,13 @@ class C128aTest extends \PHPUnit\Framework\TestCase
|
|||
public function testImage()
|
||||
{
|
||||
$path = __DIR__ . '/c128a.png';
|
||||
if (file_exists($path)) {
|
||||
unlink($path);
|
||||
if (\file_exists($path)) {
|
||||
\unlink($path);
|
||||
}
|
||||
|
||||
$img = new C128a('ABCDEFG0123()+-', 200, 50);
|
||||
$img->saveToPngFile($path);
|
||||
|
||||
self::assertTrue(file_exists($path));
|
||||
self::assertTrue(\file_exists($path));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,13 +20,13 @@ class C128bTest extends \PHPUnit\Framework\TestCase
|
|||
public function testImage()
|
||||
{
|
||||
$path = __DIR__ . '/c128b.png';
|
||||
if (file_exists($path)) {
|
||||
unlink($path);
|
||||
if (\file_exists($path)) {
|
||||
\unlink($path);
|
||||
}
|
||||
|
||||
$img = new C128b('ABcdeFG0123+-!@?', 200, 50);
|
||||
$img->saveToPngFile($path);
|
||||
|
||||
self::assertTrue(file_exists($path));
|
||||
self::assertTrue(\file_exists($path));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,13 +20,13 @@ class C128cTest extends \PHPUnit\Framework\TestCase
|
|||
public function testImage()
|
||||
{
|
||||
$path = __DIR__ . '/c128c.png';
|
||||
if (file_exists($path)) {
|
||||
unlink($path);
|
||||
if (\file_exists($path)) {
|
||||
\unlink($path);
|
||||
}
|
||||
|
||||
$img = new C128c('412163', 200, 50);
|
||||
$img->saveToPngFile($path);
|
||||
|
||||
self::assertTrue(file_exists($path));
|
||||
self::assertTrue(\file_exists($path));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,13 +20,13 @@ class C25Test extends \PHPUnit\Framework\TestCase
|
|||
public function testImage()
|
||||
{
|
||||
$path = __DIR__ . '/c25.png';
|
||||
if (file_exists($path)) {
|
||||
unlink($path);
|
||||
if (\file_exists($path)) {
|
||||
\unlink($path);
|
||||
}
|
||||
|
||||
$img = new C25('1234567890', 150, 50);
|
||||
$img->saveToPngFile($path);
|
||||
|
||||
self::assertTrue(file_exists($path));
|
||||
self::assertTrue(\file_exists($path));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,13 +20,13 @@ class C39Test extends \PHPUnit\Framework\TestCase
|
|||
public function testImage()
|
||||
{
|
||||
$path = __DIR__ . '/c39.png';
|
||||
if (file_exists($path)) {
|
||||
unlink($path);
|
||||
if (\file_exists($path)) {
|
||||
\unlink($path);
|
||||
}
|
||||
|
||||
$img = new C39('ABCDEFG0123+-', 150, 50);
|
||||
$img->saveToPngFile($path);
|
||||
|
||||
self::assertTrue(file_exists($path));
|
||||
self::assertTrue(\file_exists($path));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,13 +20,13 @@ class CodebarTest extends \PHPUnit\Framework\TestCase
|
|||
public function testImage()
|
||||
{
|
||||
$path = __DIR__ . '/codebar.png';
|
||||
if (file_exists($path)) {
|
||||
unlink($path);
|
||||
if (\file_exists($path)) {
|
||||
\unlink($path);
|
||||
}
|
||||
|
||||
$img = new Codebar('412163', 200, 50);
|
||||
$img->saveToPngFile($path);
|
||||
|
||||
self::assertTrue(file_exists($path));
|
||||
self::assertTrue(\file_exists($path));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ class HuffmanTest extends \PHPUnit\Framework\TestCase
|
|||
$huff = new Huffman();
|
||||
|
||||
self::assertEquals(
|
||||
hex2bin('a42f5debafd35bee6a940f78f38638fb3f4d6fd13cc672cf01d61bb1ce59e03cdbe89e8e56b5d63aa61387d1ba10'),
|
||||
\hex2bin('a42f5debafd35bee6a940f78f38638fb3f4d6fd13cc672cf01d61bb1ce59e03cdbe89e8e56b5d63aa61387d1ba10'),
|
||||
$huff->encode('This is a test message in order to test the encoding and decoding of the Huffman algorithm.')
|
||||
);
|
||||
|
||||
|
|
@ -34,7 +34,7 @@ class HuffmanTest extends \PHPUnit\Framework\TestCase
|
|||
|
||||
self::assertEquals(
|
||||
'This is a test message in order to test the encoding and decoding of the Huffman algorithm.',
|
||||
$man->decode(hex2bin('a42f5debafd35bee6a940f78f38638fb3f4d6fd13cc672cf01d61bb1ce59e03cdbe89e8e56b5d63aa61387d1ba10'))
|
||||
$man->decode(\hex2bin('a42f5debafd35bee6a940f78f38638fb3f4d6fd13cc672cf01d61bb1ce59e03cdbe89e8e56b5d63aa61387d1ba10'))
|
||||
);
|
||||
|
||||
self::assertEquals('', $man->decode(''));
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ class ZipTest extends \PHPUnit\Framework\TestCase
|
|||
__DIR__ . '/test.zip'
|
||||
));
|
||||
|
||||
self::assertTrue(file_exists(__DIR__ . '/test.zip'));
|
||||
self::assertTrue(\file_exists(__DIR__ . '/test.zip'));
|
||||
|
||||
self::assertFalse(Zip::pack(
|
||||
[
|
||||
|
|
@ -45,31 +45,31 @@ class ZipTest extends \PHPUnit\Framework\TestCase
|
|||
$d = \file_get_contents(__DIR__ . '/test/test d.txt');
|
||||
$e = \file_get_contents(__DIR__ . '/test/sub/test e.txt');
|
||||
|
||||
unlink(__DIR__ . '/test a.txt');
|
||||
unlink(__DIR__ . '/test b.md');
|
||||
unlink(__DIR__ . '/test/test c.txt');
|
||||
unlink(__DIR__ . '/test/test d.txt');
|
||||
unlink(__DIR__ . '/test/sub/test e.txt');
|
||||
rmdir(__DIR__ . '/test/sub');
|
||||
rmdir(__DIR__ . '/test');
|
||||
\unlink(__DIR__ . '/test a.txt');
|
||||
\unlink(__DIR__ . '/test b.md');
|
||||
\unlink(__DIR__ . '/test/test c.txt');
|
||||
\unlink(__DIR__ . '/test/test d.txt');
|
||||
\unlink(__DIR__ . '/test/sub/test e.txt');
|
||||
\rmdir(__DIR__ . '/test/sub');
|
||||
\rmdir(__DIR__ . '/test');
|
||||
|
||||
self::assertFalse(file_exists(__DIR__ . '/test a.txt'));
|
||||
self::assertFalse(file_exists(__DIR__ . '/test b.md'));
|
||||
self::assertFalse(file_exists(__DIR__ . '/test/test c.txt'));
|
||||
self::assertFalse(file_exists(__DIR__ . '/test/test d.txt'));
|
||||
self::assertFalse(file_exists(__DIR__ . '/test/sub/test e.txt'));
|
||||
self::assertFalse(file_exists(__DIR__ . '/test/sub'));
|
||||
self::assertFalse(file_exists(__DIR__ . '/test'));
|
||||
self::assertFalse(\file_exists(__DIR__ . '/test a.txt'));
|
||||
self::assertFalse(\file_exists(__DIR__ . '/test b.md'));
|
||||
self::assertFalse(\file_exists(__DIR__ . '/test/test c.txt'));
|
||||
self::assertFalse(\file_exists(__DIR__ . '/test/test d.txt'));
|
||||
self::assertFalse(\file_exists(__DIR__ . '/test/sub/test e.txt'));
|
||||
self::assertFalse(\file_exists(__DIR__ . '/test/sub'));
|
||||
self::assertFalse(\file_exists(__DIR__ . '/test'));
|
||||
|
||||
self::assertTrue(Zip::unpack(__DIR__ . '/test.zip', __DIR__));
|
||||
|
||||
self::assertTrue(file_exists(__DIR__ . '/test a.txt'));
|
||||
self::assertTrue(file_exists(__DIR__ . '/test b.md'));
|
||||
self::assertTrue(file_exists(__DIR__ . '/test/test c.txt'));
|
||||
self::assertTrue(file_exists(__DIR__ . '/test/test d.txt'));
|
||||
self::assertTrue(file_exists(__DIR__ . '/test/sub/test e.txt'));
|
||||
self::assertTrue(file_exists(__DIR__ . '/test/sub'));
|
||||
self::assertTrue(file_exists(__DIR__ . '/test'));
|
||||
self::assertTrue(\file_exists(__DIR__ . '/test a.txt'));
|
||||
self::assertTrue(\file_exists(__DIR__ . '/test b.md'));
|
||||
self::assertTrue(\file_exists(__DIR__ . '/test/test c.txt'));
|
||||
self::assertTrue(\file_exists(__DIR__ . '/test/test d.txt'));
|
||||
self::assertTrue(\file_exists(__DIR__ . '/test/sub/test e.txt'));
|
||||
self::assertTrue(\file_exists(__DIR__ . '/test/sub'));
|
||||
self::assertTrue(\file_exists(__DIR__ . '/test'));
|
||||
|
||||
self::assertEquals($a, \file_get_contents(__DIR__ . '/test a.txt'));
|
||||
self::assertEquals($b, \file_get_contents(__DIR__ . '/test b.md'));
|
||||
|
|
@ -77,8 +77,8 @@ class ZipTest extends \PHPUnit\Framework\TestCase
|
|||
self::assertEquals($d, \file_get_contents(__DIR__ . '/test/test d.txt'));
|
||||
self::assertEquals($e, \file_get_contents(__DIR__ . '/test/sub/test e.txt'));
|
||||
|
||||
unlink(__DIR__ . '/test.zip');
|
||||
self::assertFalse(file_exists(__DIR__ . '/test.zip'));
|
||||
\unlink(__DIR__ . '/test.zip');
|
||||
self::assertFalse(\file_exists(__DIR__ . '/test.zip'));
|
||||
self::assertFalse(Zip::unpack(__DIR__ . '/test.zip', __DIR__));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user