summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2021-11-12 09:59:57 +0300
committerAndrew Dolgov <[email protected]>2021-11-12 09:59:57 +0300
commit0a059d9948c169f6a57b13d8d5039468d3e4de7c (patch)
treedfabcd5af08a6b1aec26e6f2d41babb518455982 /include
parent111895a34211bb58d64797edd17e9b335874c1da (diff)
WIP: fix most of phpstan level 6 warnings
Diffstat (limited to 'include')
-rw-r--r--include/common.php14
-rw-r--r--include/sessions.php4
2 files changed, 9 insertions, 9 deletions
diff --git a/include/common.php b/include/common.php
index ee3921b..2e179e6 100644
--- a/include/common.php
+++ b/include/common.php
@@ -9,23 +9,23 @@
require_once "autoload.php";
/** its a dummy :( */
- function T_sprintf(...$args) {
+ function T_sprintf(mixed ...$args) : string {
return sprintf(...$args);
}
- function validate_csrf($csrf_token) {
- return isset($csrf_token) && hash_equals($_SESSION['csrf_token'] ?? "", $csrf_token);
+ function validate_csrf(string $csrf_token) : bool {
+ return $csrf_token && hash_equals($_SESSION['csrf_token'] ?? "", $csrf_token);
}
- function sql_bool_to_bool($s) {
+ function sql_bool_to_bool(mixed $s) : bool {
return $s && ($s !== "f" && $s !== "false"); //no-op for PDO, backwards compat for legacy layer
}
- function bool_to_sql_bool($s) {
+ function bool_to_sql_bool(bool $s) : int {
return $s ? 1 : 0;
}
- function read_stdin() {
+ function read_stdin() : string {
$fp = fopen("php://stdin", "r");
if ($fp) {
@@ -34,5 +34,5 @@
return $line;
}
- return null;
+ return "";
}
diff --git a/include/sessions.php b/include/sessions.php
index aa0cd94..e92a7d9 100644
--- a/include/sessions.php
+++ b/include/sessions.php
@@ -26,7 +26,7 @@
ini_get("session.cookie_secure"),
ini_get("session.cookie_httponly"));
- function validate_session() {
+ function validate_session() : bool {
if (!empty($_SESSION["owner"])) {
$user = ORM::for_table('epube_users')
@@ -41,7 +41,7 @@
return false;
}
- function logout_user() {
+ function logout_user() : void {
if (session_status() == PHP_SESSION_ACTIVE) {
session_destroy();