summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/errorhandler.php50
-rw-r--r--include/functions.php1
-rwxr-xr-xinclude/login_form.php18
3 files changed, 33 insertions, 36 deletions
diff --git a/include/errorhandler.php b/include/errorhandler.php
index ea464f77a..4f773bc19 100644
--- a/include/errorhandler.php
+++ b/include/errorhandler.php
@@ -2,40 +2,38 @@
/**
* @param array<int, array<string, mixed>> $trace
*/
-function format_backtrace($trace): string {
+function format_backtrace(array $trace): string {
$rv = "";
$idx = 1;
- if (is_array($trace)) {
- foreach ($trace as $e) {
- if (isset($e["file"]) && isset($e["line"])) {
- $fmt_args = [];
-
- if (is_array($e["args"] ?? false)) {
- foreach ($e["args"] as $a) {
- if (is_object($a)) {
- array_push($fmt_args, "{" . get_class($a) . "}");
- } else if (is_array($a)) {
- array_push($fmt_args, "[" . truncate_string(json_encode($a), 256, "...")) . "]";
- } else if (is_resource($a)) {
- array_push($fmt_args, truncate_string(get_resource_type($a), 256, "..."));
- } else if (is_string($a)) {
- array_push($fmt_args, truncate_string($a, 256, "..."));
- }
+ foreach ($trace as $e) {
+ if (isset($e["file"]) && isset($e["line"])) {
+ $fmt_args = [];
+
+ if (is_array($e["args"] ?? false)) {
+ foreach ($e["args"] as $a) {
+ if (is_object($a)) {
+ array_push($fmt_args, "{" . get_class($a) . "}");
+ } else if (is_array($a)) {
+ array_push($fmt_args, "[" . truncate_string(json_encode($a), 256, "...")) . "]";
+ } else if (is_resource($a)) {
+ array_push($fmt_args, truncate_string(get_resource_type($a), 256, "..."));
+ } else if (is_string($a)) {
+ array_push($fmt_args, truncate_string($a, 256, "..."));
}
}
+ }
- $filename = str_replace(dirname(__DIR__) . "/", "", $e["file"]);
+ $filename = str_replace(dirname(__DIR__) . "/", "", $e["file"]);
- $rv .= sprintf("%d. %s(%s): %s(%s)\n",
- $idx,
- $filename,
- $e["line"],
- $e["function"],
- implode(", ", $fmt_args));
+ $rv .= sprintf("%d. %s(%s): %s(%s)\n",
+ $idx,
+ $filename,
+ $e["line"],
+ $e["function"],
+ implode(", ", $fmt_args));
- $idx++;
- }
+ $idx++;
}
}
diff --git a/include/functions.php b/include/functions.php
index c32924743..a79a19711 100644
--- a/include/functions.php
+++ b/include/functions.php
@@ -123,6 +123,7 @@
// create a list like "en" => 0.8
$langs = array_combine($lang_parse[1], $lang_parse[4]);
+ /** @phpstan-ignore function.alreadyNarrowedType (PHP 7.4 will return false if array_value has an issue) */
if (is_array($langs)) {
// set default to 1 for any without q factor
foreach ($langs as $lang => $val) {
diff --git a/include/login_form.php b/include/login_form.php
index 0545a51be..5ff2b378e 100755
--- a/include/login_form.php
+++ b/include/login_form.php
@@ -39,16 +39,14 @@
<?php
foreach (PluginHost::getInstance()->get_plugins() as $n => $p) {
- if (method_exists($p, "get_login_js")) {
- $script = $p->get_login_js();
-
- if ($script) {
- echo "try {
- $script
- } catch (e) {
- console.warn('failed to initialize plugin JS: $n', e);
- }";
- }
+ $script = $p->get_login_js();
+
+ if ($script) {
+ echo "try {
+ $script
+ } catch (e) {
+ console.warn('failed to initialize plugin JS: $n', e);
+ }";
}
}
?>