Skip to content

Commit

Permalink
minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
vendeeglobe committed Jun 4, 2022
1 parent dba1236 commit 36a2c4c
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 22 deletions.
12 changes: 6 additions & 6 deletions src/class/dbal.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,25 +48,25 @@ function __construct()
}
}

function quote($string)
function quote($string): string
{
return $this->db->quote($string);
}

function q($data)
function q($data): string
{
return "'" . $this->quote($data) . "'";
}

function date($t = null)
function date($t = null): string
{
Ut::is_empty($t) && $t = time();
is_string($t) && $t = strtotime($t);

return gmdate(self::SQL_DATE_FORMAT, (int) $t);
}

function is_null_date($t)
function is_null_date($t): bool
{
return Ut::is_empty($t) || !$t || $t === self::SQL_DATE_NULL;
}
Expand Down Expand Up @@ -179,15 +179,15 @@ private function get_cache($query)
}

// save serialized sql results
private function put_cache($data)
private function put_cache($data): void
{
$data['affected_rows'] = $this->affected_rows;
file_put_contents($this->sqlfile, Ut::serialize($data));
chmod($this->sqlfile, CHMOD_SAFE);
}

// Invalidate the SQL cache
function invalidate_sql_cache()
function invalidate_sql_cache(): void
{
if ($this->cache_sql)
{
Expand Down
2 changes: 1 addition & 1 deletion src/class/dbmysqli.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ function query($query)
return $result;
}

function quote($string)
function quote($string): string
{
$string ??= '';

Expand Down
2 changes: 1 addition & 1 deletion src/class/dbpdo.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ function query($query)
return $result;
}

function quote($string)
function quote($string): string
{
$string ??= '';

Expand Down
28 changes: 14 additions & 14 deletions src/lib/safehtml/safehtml.php
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ public function __construct()
*
* @return boolean
*/
protected function writeAttrs($attrs)
protected function writeAttrs($attrs): bool
{
if (is_array($attrs))
{
Expand Down Expand Up @@ -412,7 +412,7 @@ function ($matches) { return chr(hexdec($matches[1])); },
*
* @return boolean
*/
public function openHandler(&$parser, $name, $attrs)
public function openHandler(&$parser, $name, $attrs): bool
{
$name = strtolower($name);

Expand Down Expand Up @@ -510,7 +510,7 @@ public function openHandler(&$parser, $name, $attrs)
*
* @return boolean
*/
public function closeHandler(&$parser, $name)
public function closeHandler(&$parser, $name): bool
{
$name = strtolower($name);

Expand Down Expand Up @@ -552,7 +552,7 @@ public function closeHandler(&$parser, $name)
*
* @return boolean
*/
protected function closeTag($tag)
protected function closeTag($tag): bool
{
if (!in_array($tag, $this->noClose))
{
Expand Down Expand Up @@ -582,7 +582,7 @@ protected function closeTag($tag)
*
* @return boolean
*/
public function dataHandler(&$parser, $data)
public function dataHandler(&$parser, $data): bool
{
if (count($this->dcStack) == 0)
{
Expand Down Expand Up @@ -618,7 +618,7 @@ public function escapeHandler(&$parser, $data)
*
* @return void
*/
public function setAllowTags($tags = [])
public function setAllowTags($tags = []): void
{
if (is_array($tags))
{
Expand All @@ -631,7 +631,7 @@ public function setAllowTags($tags = [])
*
* @return array
*/
public function getAllowTags()
public function getAllowTags(): array
{
return $this->allowTags;
}
Expand All @@ -641,7 +641,7 @@ public function getAllowTags()
*
* @return void
*/
public function resetAllowTags()
public function resetAllowTags(): void
{
$this->allowTags = [];
}
Expand All @@ -651,7 +651,7 @@ public function resetAllowTags()
*
* @return string Processed (X)HTML document
*/
public function getXHTML()
public function getXHTML(): string
{
while ($tag = array_pop($this->stack))
{
Expand All @@ -666,7 +666,7 @@ public function getXHTML()
*
* @return boolean
*/
public function clear()
public function clear(): bool
{
$this->xhtml = '';

Expand All @@ -680,7 +680,7 @@ public function clear()
*
* @return string Processed (X)HTML document
*/
public function parse($doc)
public function parse($doc): string
{
$result = '';

Expand Down Expand Up @@ -716,7 +716,7 @@ public function parse($doc)
* @return string Decoded document
* @access private
*/
function repackUTF7($str)
function repackUTF7($str): string
{
return preg_replace_callback('!\+([a-zA-Z\d/]+)\-!', [$this, 'repackUTF7Callback'], $str);
}
Expand All @@ -728,7 +728,7 @@ function repackUTF7($str)
* @return string Recoded string
* @access private
*/
function repackUTF7Callback($str)
function repackUTF7Callback($str): string
{
$str = base64_decode($str[1]);
$str = preg_replace_callback('/^((?:\x00.)*)((?:[^\x00].)+)/', [$this, 'repackUTF7Back'], $str);
Expand All @@ -743,7 +743,7 @@ function repackUTF7Callback($str)
* @return string Recoded string
* @access private
*/
function repackUTF7Back($str)
function repackUTF7Back($str): string
{
return $str[1] . '+' . rtrim(base64_encode($str[2]), '=') . '-';
}
Expand Down

0 comments on commit 36a2c4c

Please sign in to comment.