diff --git a/Account/Account.php b/Account/Account.php index 5ed5beeef..6c9ef5834 100644 --- a/Account/Account.php +++ b/Account/Account.php @@ -320,15 +320,15 @@ class Account implements ArrayableInterface, \JsonSerializable */ public function hasPermission(int $permission, int $unit = null, string $app = null, int $module = null, int $type = null, $element = null, $component = null) : bool { - $app = isset($app) ? strtolower($app) : $app; + $app = $app !== null ? strtolower($app) : $app; foreach ($this->permissions as $p) { - if (($p->getUnit() === $unit || $p->getUnit() === null || !isset($unit)) - && ($p->getApp() === $app || $p->getApp() === null || !isset($app)) - && ($p->getModule() === $module || $p->getModule() === null || !isset($module)) - && ($p->getType() === $type || $p->getType() === null || !isset($type)) - && ($p->getElement() === $element || $p->getElement() === null || !isset($element)) - && ($p->getComponent() === $component || $p->getComponent() === null || !isset($component)) + if (($p->getUnit() === $unit || $p->getUnit() === null || $unit === null) + && ($p->getApp() === $app || $p->getApp() === null || $app === null) + && ($p->getModule() === $module || $p->getModule() === null || $module === null) + && ($p->getType() === $type || $p->getType() === null || $type === null) + && ($p->getElement() === $element || $p->getElement() === null || $element === null) + && ($p->getComponent() === $component || $p->getComponent() === null || $component === null) && ($p->getPermission() | $permission) === $p->getPermission() ) { return true; diff --git a/DataStorage/Database/Connection/ConnectionAbstract.php b/DataStorage/Database/Connection/ConnectionAbstract.php index 64a79fd3d..e9f3041c0 100644 --- a/DataStorage/Database/Connection/ConnectionAbstract.php +++ b/DataStorage/Database/Connection/ConnectionAbstract.php @@ -161,7 +161,7 @@ abstract class ConnectionAbstract implements ConnectionInterface */ public function getGrammar() : Grammar { - if (!isset($this->grammar)) { + if ($this->grammar === null) { $this->grammar = new Grammar(); } @@ -173,7 +173,7 @@ abstract class ConnectionAbstract implements ConnectionInterface */ public function getSchemaGrammar() : SchemaGrammar { - if (!isset($this->schemaGrammar)) { + if ($this->schemaGrammar === null) { $this->schemaGrammar = new SchemaGrammar(); } diff --git a/DataStorage/Database/Connection/SQLiteConnection.php b/DataStorage/Database/Connection/SQLiteConnection.php index 3b32191bb..dd4df8a5d 100644 --- a/DataStorage/Database/Connection/SQLiteConnection.php +++ b/DataStorage/Database/Connection/SQLiteConnection.php @@ -55,7 +55,7 @@ class SqliteConnection extends ConnectionAbstract { $this->close(); - $this->dbdata = isset($dbdata) ? $dbdata : $this->dbdata; + $this->dbdata = $dbdata !== null ? $dbdata : $this->dbdata; $this->prefix = $dbdata['prefix']; try { diff --git a/DataStorage/Database/Query/Builder.php b/DataStorage/Database/Query/Builder.php index 89efe010c..eb813626d 100644 --- a/DataStorage/Database/Query/Builder.php +++ b/DataStorage/Database/Query/Builder.php @@ -486,7 +486,7 @@ class Builder extends BuilderAbstract */ public function where($columns, $operator = null, $values = null, $boolean = 'and') : Builder { - if (isset($operator) && !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.'); } diff --git a/Localization/L11nManager.php b/Localization/L11nManager.php index d5cb76f62..99ae9a18f 100644 --- a/Localization/L11nManager.php +++ b/Localization/L11nManager.php @@ -126,7 +126,7 @@ class L11nManager */ public function getModuleLanguage(string $language, string $module = null) : array { - if (!isset($module) && isset($this->language[$language])) { + if ($module === null && isset($this->language[$language])) { return $this->language[$language]; } elseif (isset($this->language[$language], $this->language[$language][$module])) { return $this->language[$language][$module]; diff --git a/Math/Statistic/MeasureOfDispersion.php b/Math/Statistic/MeasureOfDispersion.php index 5eb1d801a..36c6f8d75 100644 --- a/Math/Statistic/MeasureOfDispersion.php +++ b/Math/Statistic/MeasureOfDispersion.php @@ -64,7 +64,7 @@ class MeasureOfDispersion */ public static function empiricalVariationCoefficient(array $values, float $mean = null) : float { - $mean = isset($mean) ? $mean : Average::arithmeticMean($values); + $mean = $mean !== null ? $mean : Average::arithmeticMean($values); if ($mean === 0) { throw new ZeroDevisionException(); @@ -89,7 +89,7 @@ class MeasureOfDispersion */ public static function standardDeviation(array $values, float $mean = null) : float { - $mean = isset($mean) ? $mean : Average::arithmeticMean($values); + $mean = $mean !== null ? $mean : Average::arithmeticMean($values); $sum = 0.0; foreach ($values as $value) { @@ -156,7 +156,7 @@ class MeasureOfDispersion throw new ZeroDevisionException(); } - $mean = $hasProbability ? Average::weightedAverage($values, $probabilities) : (isset($mean) ? $mean : Average::arithmeticMean($values)); + $mean = $hasProbability ? Average::weightedAverage($values, $probabilities) : ($mean !== null ? $mean : Average::arithmeticMean($values)); $sum = 0; foreach ($values as $key => $value) { @@ -196,8 +196,8 @@ class MeasureOfDispersion throw new InvalidDimensionException($count . 'x' . count($y)); } - $xMean = isset($meanX) ? $meanX : Average::arithmeticMean($x); - $yMean = isset($meanY) ? $meanY : Average::arithmeticMean($y); + $xMean = $meanX !== null ? $meanX : Average::arithmeticMean($x); + $yMean = $meanY !== null ? $meanY : Average::arithmeticMean($y); $sum = 0.0; @@ -234,7 +234,7 @@ class MeasureOfDispersion */ public static function meanDeviation(array $x, float $mean = null) : float { - $mean = isset($mean) ? $mean : Average::arithmeticMean($x); + $mean = $mean !== null ? $mean : Average::arithmeticMean($x); $sum = 0.0; foreach ($x as $xi) { @@ -256,7 +256,7 @@ class MeasureOfDispersion */ public static function meanAbsoluteDeviation(array $x, float $mean = null) : float { - $mean = isset($mean) ? $mean : Average::arithmeticMean($x); + $mean = $mean !== null ? $mean : Average::arithmeticMean($x); $sum = 0.0; foreach ($x as $xi) { @@ -278,7 +278,7 @@ class MeasureOfDispersion */ public static function squaredMeanDeviation(array $x, float $mean = null) : float { - $mean = isset($mean) ? $mean : Average::arithmeticMean($x); + $mean = $mean !== null ? $mean : Average::arithmeticMean($x); $sum = 0.0; foreach ($x as $xi) { diff --git a/Message/Http/Request.php b/Message/Http/Request.php index bf1fe9973..b92895263 100644 --- a/Message/Http/Request.php +++ b/Message/Http/Request.php @@ -97,7 +97,7 @@ class Request extends RequestAbstract */ private function init() /* : void */ { - if (!isset($this->uri)) { + if ($this->uri === null) { $this->initCurrentRequest(); $this->lock(); $this->cleanupGlobals(); @@ -263,7 +263,7 @@ class Request extends RequestAbstract */ public function getRequestInfo() : array { - if (!isset($this->info)) { + if ($this->info === null) { $this->info['browser'] = $this->getBrowser(); $this->info['os'] = $this->getOS(); } @@ -280,7 +280,7 @@ class Request extends RequestAbstract */ public function getBrowser() : string { - if (!isset($this->browser)) { + if ($this->browser === null) { $arr = BrowserType::getConstants(); $httpUserAgent = strtolower($_SERVER['HTTP_USER_AGENT']); @@ -321,7 +321,7 @@ class Request extends RequestAbstract */ public function getOS() : string { - if (!isset($this->os)) { + if ($this->os === null) { $arr = OSType::getConstants(); $httpUserAgent = strtolower($_SERVER['HTTP_USER_AGENT']); @@ -444,7 +444,7 @@ class Request extends RequestAbstract */ public function getMethod() : string { - if (!isset($this->method)) { + if ($this->method === null) { $this->method = $_SERVER['REQUEST_METHOD'] ?? RequestMethod::GET; } diff --git a/Message/Mail/EmailAbstract.php b/Message/Mail/EmailAbstract.php index 0a6b58ac1..91edac091 100644 --- a/Message/Mail/EmailAbstract.php +++ b/Message/Mail/EmailAbstract.php @@ -127,7 +127,7 @@ class EmailAbstract */ public function disconnect() /* : void */ { - if (!isset($this->con)) { + if ($this->con === null) { imap_close($this->con); $this->con = null; } @@ -148,7 +148,7 @@ class EmailAbstract $this->mailbox = substr($this->mailbox, 0, -1) . ($this->ssl ? '/ssl/validate-cert' : '/novalidate-cert') . '}'; // /novalidate-cert - if (!isset($this->con)) { + if ($this->con === null) { $this->con = imap_open($this->mailbox . 'INBOX', $user, $pass); } } diff --git a/Message/RequestAbstract.php b/Message/RequestAbstract.php index b6a3902e7..a1492d3b8 100644 --- a/Message/RequestAbstract.php +++ b/Message/RequestAbstract.php @@ -203,7 +203,7 @@ abstract class RequestAbstract implements MessageInterface */ public function getData($key = null) { - if (!isset($key)) { + if ($key === null) { return $this->data; } diff --git a/Module/ModuleManager.php b/Module/ModuleManager.php index c10c687f3..0b225c055 100644 --- a/Module/ModuleManager.php +++ b/Module/ModuleManager.php @@ -140,7 +140,7 @@ class ModuleManager */ public function getUriLoad(RequestAbstract $request) : array { - if (!isset($this->uriLoad)) { + if ($this->uriLoad === null) { switch ($this->app->dbPool->get('select')->getType()) { case DatabaseType::MYSQL: $uriHash = $request->getHash(); @@ -233,7 +233,7 @@ class ModuleManager */ public function getAllModules() : array { - if (!isset($this->all)) { + if ($this->all === null) { chdir($this->modulePath); $files = glob('*', GLOB_ONLYDIR); $c = count($files); diff --git a/Stdlib/Graph/BinaryTree.php b/Stdlib/Graph/BinaryTree.php index 7284f2165..cc6f2f387 100644 --- a/Stdlib/Graph/BinaryTree.php +++ b/Stdlib/Graph/BinaryTree.php @@ -155,11 +155,11 @@ class BinaryTree extends Tree $left = $this->getLeft($node); $right = $this->getRight($node); - if (isset($left)) { + if ($left !== null) { $this->getVerticalOrder($left, $horizontalDistance - 1, $order); } - if (isset($right)) { + if ($right !== null) { $this->getVerticalOrder($right, $horizontalDistance + 1, $order); } } @@ -198,18 +198,18 @@ class BinaryTree extends Tree */ public function isSymmetric(Node $node1 = null, Node $node2 = null) : bool { - if (!isset($node1) && !isset($node2)) { + if ($node1 === null && $node2 === null) { return true; } $left1 = $this->getLeft($node1); $right1 = $this->getRight($node1); - $left2 = isset($node2) ? $this->getLeft($node1) : $this->getLeft($node2); - $right2 = isset($node2) ? $this->getRight($node1) : $this->getRight($node2); + $left2 = $node2 !== null ? $this->getLeft($node1) : $this->getLeft($node2); + $right2 = $node2 !== null ? $this->getRight($node1) : $this->getRight($node2); // todo: compare values? true symmetry requires the values to be the same - if (isset($node1, $node2)) { + if ($node1 !== null && $node2 !== null) { return $this->isSymmetric($left1, $right2) && $this->isSymmetric($right1, $left2); } diff --git a/Stdlib/Graph/Tree.php b/Stdlib/Graph/Tree.php index b874c0f87..744e5a063 100644 --- a/Stdlib/Graph/Tree.php +++ b/Stdlib/Graph/Tree.php @@ -74,7 +74,7 @@ class Tree extends Graph { $currentNode = $node ?? $this->root; - if (!isset($currentNode)) { + if ($currentNode === null) { return 0; } @@ -101,7 +101,7 @@ class Tree extends Graph { $currentNode = $node ?? $this->root; - if (!isset($currentNode)) { + if ($currentNode === null) { return 0; } diff --git a/System/File/Ftp/Directory.php b/System/File/Ftp/Directory.php index f138d6139..1b3ad5271 100644 --- a/System/File/Ftp/Directory.php +++ b/System/File/Ftp/Directory.php @@ -300,7 +300,7 @@ class Directory extends FileAbstract implements DirectoryInterface */ public function offsetSet($offset, $value) { - if (!isset($offset)) { + if ($offset === null) { $this->addNode($value); } else { $this->nodes[$offset] = $value; diff --git a/System/File/Ftp/FtpStorage.php b/System/File/Ftp/FtpStorage.php index 9c01a9137..b39fe227c 100644 --- a/System/File/Ftp/FtpStorage.php +++ b/System/File/Ftp/FtpStorage.php @@ -39,7 +39,7 @@ class FtpStorage extends StorageAbstract public static function getInstance() : StorageAbstract { - if (!isset(self::$instance)) { + if (self::$instance === null) { self::$instance = new self(); } diff --git a/System/File/Local/Directory.php b/System/File/Local/Directory.php index 49911fe02..ab41e5ece 100644 --- a/System/File/Local/Directory.php +++ b/System/File/Local/Directory.php @@ -470,7 +470,7 @@ class Directory extends FileAbstract implements DirectoryInterface */ public function offsetSet($offset, $value) { - if (!isset($offset)) { + if ($offset === null) { $this->addNode($value); } else { $this->nodes[$offset] = $value; diff --git a/System/File/Local/LocalStorage.php b/System/File/Local/LocalStorage.php index e511112b8..d7e1df229 100644 --- a/System/File/Local/LocalStorage.php +++ b/System/File/Local/LocalStorage.php @@ -55,7 +55,7 @@ class LocalStorage extends StorageAbstract */ public static function getInstance() : StorageAbstract { - if (!isset(self::$instance)) { + if (self::$instance === null) { self::$instance = new self(); } diff --git a/Uri/Http.php b/Uri/Http.php index 586c7d75b..ae5535746 100644 --- a/Uri/Http.php +++ b/Uri/Http.php @@ -275,7 +275,7 @@ class Http implements UriInterface */ public function getQuery(string $key = null) : string { - if (isset($key)) { + if ($key !== null) { $key = strtolower($key); return $this->query[$key] ?? ''; @@ -338,7 +338,7 @@ class Http implements UriInterface public function getAuthority() : string { return ($this->getUser() !== '' ? $this->getUser() . '@' : '') . $this->host - . (isset($this->port) && $this->port !== 0 ? ':' . $this->port : ''); + . ($this->port !== null && $this->port !== 0 ? ':' . $this->port : ''); } /** diff --git a/Utils/Git/Repository.php b/Utils/Git/Repository.php index 9cc8ca9d1..6c951112d 100644 --- a/Utils/Git/Repository.php +++ b/Utils/Git/Repository.php @@ -246,7 +246,7 @@ class Repository throw new \Exception('Already repository'); } - if (isset($source)) { + if ($source !== null) { return stripos($source, '//') !== false ? $this->cloneRemote($source) : $this->cloneFrom($source); } @@ -688,11 +688,11 @@ class Repository */ public function getContributors(\DateTime $start = null, \DateTime $end = null) : array { - if (!isset($start)) { + if ($start === null) { $start = new \DateTime('1970-12-31'); } - if (!isset($end)) { + if ($end === null) { $end = new \DateTime('now'); } @@ -727,11 +727,11 @@ class Repository */ public function getCommitsCount(\DateTime $start = null, \DateTime $end = null) : array { - if (!isset($start)) { + if ($start === null) { $start = new \DateTime('1970-12-31'); } - if (!isset($end)) { + if ($end === null) { $end = new \DateTime('now'); } @@ -760,11 +760,11 @@ class Repository */ public function getAdditionsRemovalsByContributor(Author $author, \DateTime $start = null, \DateTime $end = null) : array { - if (!isset($start)) { + if ($start === null) { $start = new \DateTime('1900-01-01'); } - if (!isset($end)) { + if ($end === null) { $end = new \DateTime('now'); } @@ -811,15 +811,15 @@ class Repository */ public function getCommitsBy(\DateTime $start = null, \DateTime $end = null, Author $author = null) : array { - if (!isset($start)) { + if ($start === null) { $start = new \DateTime('1970-12-31'); } - if (!isset($end)) { + if ($end === null) { $end = new \DateTime('now'); } - if (!isset($author)) { + if ($author === null) { $author = ''; } else { $author = ' --author=' . escapeshellarg($author->getName()) . ''; diff --git a/Utils/Parser/Markdown/Markdown.php b/Utils/Parser/Markdown/Markdown.php index 2bf675ca5..a0833ba79 100644 --- a/Utils/Parser/Markdown/Markdown.php +++ b/Utils/Parser/Markdown/Markdown.php @@ -170,7 +170,7 @@ class Markdown if (isset($currentBlock['continuable'])) { $block = self::{'block' . $currentBlock['type'] . 'Continue'}($lineArray, $currentBlock); - if (isset($block)) { + if ($block !== null) { $currentBlock = $block; continue; @@ -191,7 +191,7 @@ class Markdown foreach ($blockTypes as $blockType) { $block = self::{'block' . $blockType}($lineArray, $currentBlock); - if (isset($block)) { + if ($block !== null) { $block['type'] = $blockType; if (!isset($block['identified'])) { @@ -243,7 +243,7 @@ class Markdown protected static function blockCode(array $lineArray, array $block = null) /* : ?array */ { - if (isset($block) && !isset($block['type']) && !isset($block['interrupted'])) { + if ($block !== null && !isset($block['type']) && !isset($block['interrupted'])) { return; } @@ -676,7 +676,7 @@ class Markdown foreach (self::$inlineTypes[$marker] as $inlineType) { $inline = self::{'inline' . $inlineType}($excerptArray); - if (!isset($inline)) { + if ($inline === null) { continue; } @@ -794,7 +794,7 @@ class Markdown $excerpt['text'] = substr($excerpt['text'], 1); $link = self::inlineLink($excerpt); - if (!isset($link)) { + if ($link === null) { return; } diff --git a/Utils/Parser/Php/ArrayParser.php b/Utils/Parser/Php/ArrayParser.php index 192b66bf4..af90f6490 100644 --- a/Utils/Parser/Php/ArrayParser.php +++ b/Utils/Parser/Php/ArrayParser.php @@ -68,7 +68,7 @@ class ArrayParser return '"' . $value . '"'; } elseif (is_scalar($value)) { return (string) $value; - } elseif (!isset($value)) { + } elseif ($value === null) { return 'null'; } elseif (is_bool($value)) { return $value ? 'true' : 'false'; diff --git a/Utils/TaskSchedule/Interval.php b/Utils/TaskSchedule/Interval.php index 7ac01ceac..bde6b0083 100644 --- a/Utils/TaskSchedule/Interval.php +++ b/Utils/TaskSchedule/Interval.php @@ -100,7 +100,7 @@ class Interval implements \Serializable { $this->start = new \DateTime('now'); - if (isset($interval)) { + if ($interval !== null) { $this->unserialize($interval); } } diff --git a/Validation/Validator.php b/Validation/Validator.php index 18dcde896..6fb8e5c55 100644 --- a/Validation/Validator.php +++ b/Validation/Validator.php @@ -39,7 +39,7 @@ final class Validator extends ValidatorAbstract */ public static function isValid($var, array $constraints = null) : bool { - if (!isset($constraints)) { + if ($constraints === null) { return true; } diff --git a/Views/View.php b/Views/View.php index d7702771c..8b12a16c4 100644 --- a/Views/View.php +++ b/Views/View.php @@ -85,7 +85,7 @@ class View extends ViewAbstract $this->app = $app; $this->request = $request; $this->response = $response; - $this->l11n = isset($response) ? $response->getHeader()->getL11n() : null; + $this->l11n = $response !== null ? $response->getHeader()->getL11n() : null; } /** @@ -174,7 +174,7 @@ class View extends ViewAbstract */ public function getText($translation, string $module = null, string $theme = null) : string { - if (!isset($module)) { + if ($module === null) { $match = '/Modules/'; if (($start = strripos($this->template, $match)) === false) { @@ -186,7 +186,7 @@ class View extends ViewAbstract $module = substr($this->template, $start, $end - $start); } - if (!isset($theme)) { + if ($theme === null) { $match = '/Theme/'; if (($start = strripos($this->template, $match)) === false) {