From 138b631a655a9bc7a51063b1d412d3d9f9329dc3 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Fri, 24 Aug 2018 14:48:49 +0200 Subject: [PATCH] Use more global paths --- DataStorage/Database/DataMapperAbstract.php | 2 +- Dispatcher/Dispatcher.php | 6 +++--- Localization/Money.php | 14 +++++++------- Math/Number/Complex.php | 12 ++++++------ Math/Statistic/Basic.php | 2 +- .../Distribution/ChiSquaredDistribution.php | 2 +- Stdlib/Map/MultiMap.php | 2 +- System/File/Ftp/FtpStorage.php | 14 +++++++------- System/File/Storage.php | 2 +- Utils/ArrayUtils.php | 12 ++++++------ Utils/Encoding/Huffman/Dictionary.php | 2 +- Utils/Parser/Php/ArrayParser.php | 10 +++++----- Utils/StringUtils.php | 8 ++++---- Views/ViewAbstract.php | 2 +- tests/Account/AccountTest.php | 18 +++++++++--------- tests/Account/GroupTest.php | 10 +++++----- .../Cache/Connection/FileCacheTest.php | 2 +- tests/Stdlib/Map/MultiMapTest.php | 4 ++-- tests/Views/ViewTest.php | 2 +- 19 files changed, 63 insertions(+), 63 deletions(-) diff --git a/DataStorage/Database/DataMapperAbstract.php b/DataStorage/Database/DataMapperAbstract.php index 943831a12..a3ad628c2 100644 --- a/DataStorage/Database/DataMapperAbstract.php +++ b/DataStorage/Database/DataMapperAbstract.php @@ -1407,7 +1407,7 @@ class DataMapperAbstract implements DataMapperInterface { self::extend(__CLASS__); - if (is_scalar($obj)) { + if (\is_scalar($obj)) { $obj = static::get($obj); } diff --git a/Dispatcher/Dispatcher.php b/Dispatcher/Dispatcher.php index 0c3a34174..fc42ca1c5 100644 --- a/Dispatcher/Dispatcher.php +++ b/Dispatcher/Dispatcher.php @@ -73,13 +73,13 @@ final class Dispatcher { $views = []; - if (is_array($controller) && isset($controller['dest'])) { + if (\is_array($controller) && isset($controller['dest'])) { $controller = $controller['dest']; } - if (is_string($controller)) { + if (\is_string($controller)) { $views += $this->dispatchString($controller, $data); - } elseif (is_array($controller)) { + } elseif (\is_array($controller)) { $views += $this->dispatchArray($controller, $data); } elseif ($controller instanceof \Closure) { $views[] = $this->dispatchClosure($controller, $data); diff --git a/Localization/Money.php b/Localization/Money.php index 90da81e40..2c668853e 100644 --- a/Localization/Money.php +++ b/Localization/Money.php @@ -213,9 +213,9 @@ final class Money implements \Serializable */ public function add($value) : Money { - if (is_string($value) || is_float($value)) { + if (\is_string($value) || is_float($value)) { $this->value += self::toInt((string) $value, $this->thousands, $this->decimal); - } elseif (is_int($value)) { + } elseif (\is_int($value)) { $this->value += $value; } elseif ($value instanceof Money) { $this->value += $value->getInt(); @@ -247,9 +247,9 @@ final class Money implements \Serializable */ public function sub($value) : Money { - if (is_string($value) || is_float($value)) { + if (\is_string($value) || is_float($value)) { $this->value -= self::toInt((string) $value, $this->thousands, $this->decimal); - } elseif (is_int($value)) { + } elseif (\is_int($value)) { $this->value -= $value; } elseif ($value instanceof Money) { $this->value -= $value->getInt(); @@ -269,7 +269,7 @@ final class Money implements \Serializable */ public function mult($value) : Money { - if (is_float($value) || is_int($value)) { + if (\is_float($value) || is_int($value)) { $this->value = (int) ($this->value * $value); } @@ -287,7 +287,7 @@ final class Money implements \Serializable */ public function div($value) : Money { - if (is_float($value) || is_int($value)) { + if (\is_float($value) || is_int($value)) { $this->value = (int) ($this->value / $value); } @@ -319,7 +319,7 @@ final class Money implements \Serializable */ public function pow($value) : Money { - if (is_float($value) || is_int($value)) { + if (\is_float($value) || is_int($value)) { $this->value = (int) ($this->value ** $value); } diff --git a/Math/Number/Complex.php b/Math/Number/Complex.php index 9f5fce944..585bddded 100644 --- a/Math/Number/Complex.php +++ b/Math/Number/Complex.php @@ -148,9 +148,9 @@ final class Complex public function pow($value) : Complex { - if (is_int($value)) { + if (\is_int($value)) { return $this->powInteger($value); - } elseif (is_numeric($value)) { + } elseif (\is_numeric($value)) { return $this->powScalar($value); } elseif ($value instanceof Complex) { return $this->powComplex($value); @@ -202,7 +202,7 @@ final class Complex */ public function add($value) : Complex { - if (is_numeric($value)) { + if (\is_numeric($value)) { return $this->addScalar($value); } elseif ($value instanceof Complex) { return $this->addComplex($value); @@ -252,7 +252,7 @@ final class Complex */ public function sub($value) : Complex { - if (is_numeric($value)) { + if (\is_numeric($value)) { return $this->subScalar($value); } elseif ($value instanceof Complex) { return $this->subComplex($value); @@ -302,7 +302,7 @@ final class Complex */ public function mult($value) : Complex { - if (is_numeric($value)) { + if (\is_numeric($value)) { return $this->multScalar($value); } elseif ($value instanceof Complex) { return $this->multComplex($value); @@ -355,7 +355,7 @@ final class Complex */ public function div($value) : Complex { - if (is_numeric($value)) { + if (\is_numeric($value)) { return $this->divScalar($value); } elseif ($value instanceof Complex) { return $this->divComplex($value); diff --git a/Math/Statistic/Basic.php b/Math/Statistic/Basic.php index 385494b6a..8bd00139f 100644 --- a/Math/Statistic/Basic.php +++ b/Math/Statistic/Basic.php @@ -56,7 +56,7 @@ final class Basic } foreach ($values as $value) { - if (is_array($value)) { + if (\is_array($value)) { $freaquency[] = self::frequency($value); } else { $freaquency[] = $value / $sum; diff --git a/Math/Stochastic/Distribution/ChiSquaredDistribution.php b/Math/Stochastic/Distribution/ChiSquaredDistribution.php index d01a69bda..a3126a5a0 100644 --- a/Math/Stochastic/Distribution/ChiSquaredDistribution.php +++ b/Math/Stochastic/Distribution/ChiSquaredDistribution.php @@ -134,7 +134,7 @@ class ChiSquaredDistribution */ public static function getDegreesOfFreedom(array $values) : int { - if (is_array($first = \reset($values))) { + if (\is_array($first = \reset($values))) { return (\count($values) - 1) * (\count($first) - 1); } else { return \count($values) - 1; diff --git a/Stdlib/Map/MultiMap.php b/Stdlib/Map/MultiMap.php index 0c9b79359..a0b4001d7 100644 --- a/Stdlib/Map/MultiMap.php +++ b/Stdlib/Map/MultiMap.php @@ -200,7 +200,7 @@ class MultiMap implements \Countable */ private function getMultiple($key) { - if (is_array($key)) { + if (\is_array($key)) { if ($this->orderType === OrderType::LOOSE) { $keys = Permutation::permut($key); diff --git a/System/File/Ftp/FtpStorage.php b/System/File/Ftp/FtpStorage.php index 460ae5490..c93b2f2b1 100644 --- a/System/File/Ftp/FtpStorage.php +++ b/System/File/Ftp/FtpStorage.php @@ -56,7 +56,7 @@ class FtpStorage extends StorageAbstract */ public static function put(string $path, string $content, int $mode = 0) : bool { - if (is_dir($path)) { + if (\is_dir($path)) { throw new PathException($path); } @@ -68,7 +68,7 @@ class FtpStorage extends StorageAbstract */ public static function get(string $path) : string { - if (is_dir($path)) { + if (\is_dir($path)) { throw new PathException($path); } @@ -88,7 +88,7 @@ class FtpStorage extends StorageAbstract */ public static function list(string $path, string $filter = '*') : array { - if (is_file($path)) { + if (\is_file($path)) { throw new PathException($path); } @@ -100,7 +100,7 @@ class FtpStorage extends StorageAbstract */ public static function set(string $path, string $content) : bool { - if (is_dir($path)) { + if (\is_dir($path)) { throw new PathException($path); } @@ -112,7 +112,7 @@ class FtpStorage extends StorageAbstract */ public static function append(string $path, string $content) : bool { - if (is_dir($path)) { + if (\is_dir($path)) { throw new PathException($path); } @@ -124,7 +124,7 @@ class FtpStorage extends StorageAbstract */ public static function prepend(string $path, string $content) : bool { - if (is_dir($path)) { + if (\is_dir($path)) { throw new PathException($path); } @@ -136,7 +136,7 @@ class FtpStorage extends StorageAbstract */ public static function extension(string $path) : string { - if (is_dir($path)) { + if (\is_dir($path)) { throw new PathException($path); } diff --git a/System/File/Storage.php b/System/File/Storage.php index 607f5d619..1a5dd73f7 100644 --- a/System/File/Storage.php +++ b/System/File/Storage.php @@ -59,7 +59,7 @@ final class Storage public static function env(string $env = 'local') : StorageAbstract { if (isset(self::$registered[$env])) { - if (is_string(self::$registered[$env])) { + if (\is_string(self::$registered[$env])) { $env = self::$registered[$env]::getInstance(); } elseif (self::$registered[$env] instanceof StorageAbstract || self::$registered[$env] instanceof ContainerInterface) { $env = self::$registered[$env]; diff --git a/Utils/ArrayUtils.php b/Utils/ArrayUtils.php index 76f785766..b3e10d7eb 100644 --- a/Utils/ArrayUtils.php +++ b/Utils/ArrayUtils.php @@ -102,11 +102,11 @@ final class ArrayUtils if ($overwrite) { $current = $value; - } elseif (is_array($current) && !is_array($value)) { + } elseif (\is_array($current) && !is_array($value)) { $current[] = $value; - } elseif (is_array($current) && is_array($value)) { + } elseif (\is_array($current) && is_array($value)) { $current = array_merge($current, $value); - } elseif (is_scalar($current) && $current !== null) { + } elseif (\is_scalar($current) && $current !== null) { $current = [$current, $value]; } else { $current = $value; @@ -163,7 +163,7 @@ final class ArrayUtils foreach ($haystack as $item) { if ($item === $needle) { return true; - } elseif (is_array($item)) { + } elseif (\is_array($item)) { $found = self::inArrayRecursive($needle, $item); if ($found) { @@ -233,7 +233,7 @@ final class ArrayUtils $str = '['; foreach ($array as $key => $value) { - if (is_string($key)) { + if (\is_string($key)) { $key = '\'' . $key . '\''; } @@ -352,7 +352,7 @@ final class ArrayUtils while (!empty($stack)) { $value = array_shift($stack); - if (is_array($value)) { + if (\is_array($value)) { $stack = array_merge(array_values($value), $stack); } else { $flat[] = $value; diff --git a/Utils/Encoding/Huffman/Dictionary.php b/Utils/Encoding/Huffman/Dictionary.php index b294cf3a4..969178866 100644 --- a/Utils/Encoding/Huffman/Dictionary.php +++ b/Utils/Encoding/Huffman/Dictionary.php @@ -92,7 +92,7 @@ final class Dictionary sort($count); } - $this->fill(is_array($count[0][1]) ? $count[0][1] : $count); + $this->fill(\is_array($count[0][1]) ? $count[0][1] : $count); } /** diff --git a/Utils/Parser/Php/ArrayParser.php b/Utils/Parser/Php/ArrayParser.php index ae98ed482..6c9e2627c 100644 --- a/Utils/Parser/Php/ArrayParser.php +++ b/Utils/Parser/Php/ArrayParser.php @@ -41,7 +41,7 @@ class ArrayParser $stringify = '[' . "\n"; foreach ($arr as $key => $val) { - if (is_string($key)) { + if (\is_string($key)) { $key = '\'' . \str_replace('\'', '\\\'', $key) . '\''; } @@ -63,15 +63,15 @@ class ArrayParser */ public static function parseVariable($value, int $depth = 1) : string { - if (is_array($value)) { + if (\is_array($value)) { return ArrayParser::serializeArray($value, $depth); - } elseif (is_string($value)) { + } elseif (\is_string($value)) { return '\'' . \str_replace('\'', '\\\'', $value) . '\''; - } elseif (is_scalar($value)) { + } elseif (\is_scalar($value)) { return (string) $value; } elseif ($value === null) { return 'null'; - } elseif (is_bool($value)) { + } elseif (\is_bool($value)) { return $value ? 'true' : 'false'; } elseif ($value instanceOf \Serializable) { return self::parseVariable($value->serialize()); diff --git a/Utils/StringUtils.php b/Utils/StringUtils.php index f18f63181..79f12901c 100644 --- a/Utils/StringUtils.php +++ b/Utils/StringUtils.php @@ -108,7 +108,7 @@ final class StringUtils */ public static function endsWith(string $haystack, $needles) : bool { - if (is_string($needles)) { + if (\is_string($needles)) { $needles = [$needles]; } @@ -140,7 +140,7 @@ final class StringUtils */ public static function startsWith(string $haystack, $needles) : bool { - if (is_string($needles)) { + if (\is_string($needles)) { $needles = [$needles]; } @@ -168,7 +168,7 @@ final class StringUtils */ public static function mb_startsWith(string $haystack, $needles) : bool { - if (is_string($needles)) { + if (\is_string($needles)) { $needles = [$needles]; } @@ -200,7 +200,7 @@ final class StringUtils */ public static function mb_endsWith(string $haystack, $needles) : bool { - if (is_string($needles)) { + if (\is_string($needles)) { $needles = [$needles]; } diff --git a/Views/ViewAbstract.php b/Views/ViewAbstract.php index 53a817794..4bec21240 100644 --- a/Views/ViewAbstract.php +++ b/Views/ViewAbstract.php @@ -255,7 +255,7 @@ abstract class ViewAbstract implements \Serializable $includeData = include $path; $ob = (string) ob_get_clean(); - if (is_array($includeData)) { + if (\is_array($includeData)) { return (string) \json_encode($includeData); } } catch (\Throwable $e) { diff --git a/tests/Account/AccountTest.php b/tests/Account/AccountTest.php index 3f470b6d1..9302ded7c 100644 --- a/tests/Account/AccountTest.php +++ b/tests/Account/AccountTest.php @@ -62,32 +62,32 @@ class AccountTest extends \PHPUnit\Framework\TestCase $account = new Account(); /* Testing default values */ - self::assertTrue(is_int($account->getId())); + self::assertTrue(\is_int($account->getId())); self::assertEquals(0, $account->getId()); self::assertInstanceOf('\phpOMS\Localization\Localization', $account->getL11n()); self::assertEquals([], $account->getGroups()); - self::assertTrue(is_string($account->getName())); + self::assertTrue(\is_string($account->getName())); self::assertEquals('', $account->getName()); - self::assertTrue(is_string($account->getName1())); + self::assertTrue(\is_string($account->getName1())); self::assertEquals('', $account->getName1()); - self::assertTrue(is_string($account->getName2())); + self::assertTrue(\is_string($account->getName2())); self::assertEquals('', $account->getName2()); - self::assertTrue(is_string($account->getName3())); + self::assertTrue(\is_string($account->getName3())); self::assertEquals('', $account->getName3()); - self::assertTrue(is_string($account->getEmail())); + self::assertTrue(\is_string($account->getEmail())); self::assertEquals('', $account->getEmail()); - self::assertTrue(is_int($account->getStatus())); + self::assertTrue(\is_int($account->getStatus())); self::assertEquals(AccountStatus::INACTIVE, $account->getStatus()); - self::assertTrue(is_int($account->getType())); + self::assertTrue(\is_int($account->getType())); self::assertEquals(AccountType::USER, $account->getType()); self::assertEquals([], $account->getPermissions()); @@ -96,7 +96,7 @@ class AccountTest extends \PHPUnit\Framework\TestCase self::assertInstanceOf('\DateTime', $account->getCreatedAt()); $array = $account->toArray(); - self::assertTrue(is_array($array)); + self::assertTrue(\is_array($array)); self::assertGreaterThan(0, \count($array)); self::assertEquals(\json_encode($array), $account->__toString()); self::assertEquals($array, $account->jsonSerialize()); diff --git a/tests/Account/GroupTest.php b/tests/Account/GroupTest.php index 838961dcf..b894606d4 100644 --- a/tests/Account/GroupTest.php +++ b/tests/Account/GroupTest.php @@ -40,20 +40,20 @@ class GroupTest extends \PHPUnit\Framework\TestCase $group = new Group(); /* Testing default values */ - self::assertTrue(is_int($group->getId())); + self::assertTrue(\is_int($group->getId())); self::assertEquals(0, $group->getId()); - self::assertTrue(is_string($group->getName())); + self::assertTrue(\is_string($group->getName())); self::assertEquals('', $group->getName()); - self::assertTrue(is_int($group->getStatus())); + self::assertTrue(\is_int($group->getStatus())); self::assertEquals(GroupStatus::INACTIVE, $group->getStatus()); - self::assertTrue(is_string($group->getDescription())); + self::assertTrue(\is_string($group->getDescription())); self::assertEquals('', $group->getDescription()); $array = $group->toArray(); - self::assertTrue(is_array($array)); + self::assertTrue(\is_array($array)); self::assertGreaterThan(0, \count($array)); self::assertEquals(\json_encode($array), $group->__toString()); self::assertEquals($array, $group->jsonSerialize()); diff --git a/tests/DataStorage/Cache/Connection/FileCacheTest.php b/tests/DataStorage/Cache/Connection/FileCacheTest.php index 2c5a3356a..80d5d4a3b 100644 --- a/tests/DataStorage/Cache/Connection/FileCacheTest.php +++ b/tests/DataStorage/Cache/Connection/FileCacheTest.php @@ -25,7 +25,7 @@ class FileCacheTest extends \PHPUnit\Framework\TestCase $cache = new FileCache(__DIR__ . '/Cache'); - self::assertTrue(is_dir(__DIR__ . '/Cache')); + self::assertTrue(\is_dir(__DIR__ . '/Cache')); self::assertTrue($cache->flushAll()); self::assertEquals(50, $cache->getThreshold()); self::assertEquals(null, $cache->get('test')); diff --git a/tests/Stdlib/Map/MultiMapTest.php b/tests/Stdlib/Map/MultiMapTest.php index 94a905391..a76b8484e 100644 --- a/tests/Stdlib/Map/MultiMapTest.php +++ b/tests/Stdlib/Map/MultiMapTest.php @@ -155,8 +155,8 @@ class MultiMapTest extends \PHPUnit\Framework\TestCase self::assertEquals(3, \count($map->keys())); self::assertEquals(2, \count($map->values())); - self::assertTrue(is_array($map->keys())); - self::assertTrue(is_array($map->values())); + self::assertTrue(\is_array($map->keys())); + self::assertTrue(\is_array($map->values())); } public function testSiblings() diff --git a/tests/Views/ViewTest.php b/tests/Views/ViewTest.php index cba8d4eb4..503bed021 100644 --- a/tests/Views/ViewTest.php +++ b/tests/Views/ViewTest.php @@ -51,7 +51,7 @@ class ViewTest extends \PHPUnit\Framework\TestCase self::assertEmpty($view->getTemplate()); self::assertEmpty($view->getViews()); - self::assertTrue(is_array($view->getViews())); + self::assertTrue(\is_array($view->getViews())); self::assertFalse($view->getView(0)); self::assertFalse($view->removeView(0)); self::assertNull($view->getData(0));