Compare commits

..

1 Commits

Author SHA1 Message Date
Clemens Schwaighofer
51e700cd10 Fixes from phan/phpstan tests 2022-04-28 14:17:30 +09:00
5 changed files with 78 additions and 6 deletions

View File

@@ -1,7 +1,72 @@
parameters: parameters:
ignoreErrors: ignoreErrors:
- -
message: "#^Parameter \\#1 \\$result of function pg_result_error expects resource, object\\|resource\\|true given\\.$#" message: "#^Parameter \\#1 \\$connection of function pg_connection_busy expects PgSql\\\\Connection, object\\|resource given\\.$#"
count: 3
path: www/lib/CoreLibs/DB/SQL/PgSQL.php
-
message: "#^Parameter \\#1 \\$connection of function pg_connection_status expects PgSql\\\\Connection, object\\|resource given\\.$#"
count: 1
path: www/lib/CoreLibs/DB/SQL/PgSQL.php
-
message: "#^Parameter \\#1 \\$connection of function pg_get_result expects PgSql\\\\Connection, object\\|resource given\\.$#"
count: 2
path: www/lib/CoreLibs/DB/SQL/PgSQL.php
-
message: "#^Parameter \\#1 \\$connection of function pg_meta_data expects PgSql\\\\Connection, object\\|resource given\\.$#"
count: 1
path: www/lib/CoreLibs/DB/SQL/PgSQL.php
-
message: "#^Parameter \\#1 \\$connection of function pg_send_query expects PgSql\\\\Connection, object\\|resource given\\.$#"
count: 2
path: www/lib/CoreLibs/DB/SQL/PgSQL.php
-
message: "#^Parameter \\#1 \\$connection of function pg_socket expects PgSql\\\\Connection, object\\|resource given\\.$#"
count: 1
path: www/lib/CoreLibs/DB/SQL/PgSQL.php
-
message: "#^Parameter \\#1 \\$connection of function pg_version expects PgSql\\\\Connection\\|null, object\\|resource given\\.$#"
count: 2
path: www/lib/CoreLibs/DB/SQL/PgSQL.php
-
message: "#^Parameter \\#1 \\$result of function pg_affected_rows expects PgSql\\\\Result, object\\|resource given\\.$#"
count: 1
path: www/lib/CoreLibs/DB/SQL/PgSQL.php
-
message: "#^Parameter \\#1 \\$result of function pg_fetch_all expects PgSql\\\\Result, object\\|resource given\\.$#"
count: 1
path: www/lib/CoreLibs/DB/SQL/PgSQL.php
-
message: "#^Parameter \\#1 \\$result of function pg_fetch_array expects PgSql\\\\Result, object\\|resource given\\.$#"
count: 1
path: www/lib/CoreLibs/DB/SQL/PgSQL.php
-
message: "#^Parameter \\#1 \\$result of function pg_field_name expects PgSql\\\\Result, object\\|resource given\\.$#"
count: 1
path: www/lib/CoreLibs/DB/SQL/PgSQL.php
-
message: "#^Parameter \\#1 \\$result of function pg_num_fields expects PgSql\\\\Result, object\\|resource given\\.$#"
count: 1
path: www/lib/CoreLibs/DB/SQL/PgSQL.php
-
message: "#^Parameter \\#1 \\$result of function pg_num_rows expects PgSql\\\\Result, object\\|resource given\\.$#"
count: 1
path: www/lib/CoreLibs/DB/SQL/PgSQL.php
-
message: "#^Parameter \\#1 \\$result of function pg_result_error expects PgSql\\\\Result, object\\|resource given\\.$#"
count: 1 count: 1
path: www/lib/CoreLibs/DB/SQL/PgSQL.php path: www/lib/CoreLibs/DB/SQL/PgSQL.php

View File

@@ -24,7 +24,9 @@ parameters:
# do not check old qq file uploader tests # do not check old qq file uploader tests
- www/admin/qq_file_upload_*.php - www/admin/qq_file_upload_*.php
# ignore all test files # ignore all test files
- www/admin/class_test*php - www/admin/class_test*.php
# extra in sub folder
- www/admin/subfolder/class_test*.php
- www/admin/error_test.php - www/admin/error_test.php
# admin synlink files # admin synlink files
- www/admin/edit_*.php - www/admin/edit_*.php
@@ -47,9 +49,12 @@ parameters:
- www/vendor - www/vendor
# ignore errores with # ignore errores with
ignoreErrors: ignoreErrors:
- # this error is ignore because of the PHP 8.0 to 8.1 change for pg_* - # this error is ignore because of the PHP 8.0 to 8.1 change for pg_*, only for 8.0 or lower
message: "#^Parameter \\#1 \\$(result|connection) of function pg_\\w+ expects resource(\\|null)?, object\\|resource(\\|bool)? given\\.$#" message: "#^Parameter \\#1 \\$(result|connection) of function pg_\\w+ expects resource(\\|null)?, object\\|resource(\\|bool)? given\\.$#"
path: %currentWorkingDirectory%/www/lib/CoreLibs/DB/SQL/PgSQL.php path: %currentWorkingDirectory%/www/lib/CoreLibs/DB/SQL/PgSQL.php
- # this is for 8.1 or newer
message: "#^Parameter \\#1 \\$(result|connection) of function pg_\\w+ expects PgSql\\\\(Result|Connection(\\|null)?), object\\|resource given\\.$#"
path: %currentWorkingDirectory%/www/lib/CoreLibs/DB/SQL/PgSQL.php
# this is ignored for now # this is ignored for now
# - '#Expression in empty\(\) is always falsy.#' # - '#Expression in empty\(\) is always falsy.#'
# - # -

View File

@@ -42,7 +42,6 @@ $log = new CoreLibs\Debug\Logging([
'echo_all' => $ECHO_ALL ?? false, 'echo_all' => $ECHO_ALL ?? false,
'print_all' => $PRINT_ALL ?? false, 'print_all' => $PRINT_ALL ?? false,
]); ]);
$basic = new CoreLibs\Basic($log);
print "<!DOCTYPE html>"; print "<!DOCTYPE html>";
print "<html><head><title>TEST CLASS: SYSTEM</title><head>"; print "<html><head><title>TEST CLASS: SYSTEM</title><head>";

View File

@@ -818,6 +818,7 @@ class Login
} }
// set the default edit access // set the default edit access
$this->acl['default_edit_access'] = $_SESSION['UNIT_DEFAULT'] ?? null; $this->acl['default_edit_access'] = $_SESSION['UNIT_DEFAULT'] ?? null;
$this->acl['min'] = [];
// integrate the type acl list, but only for the keyword -> level // integrate the type acl list, but only for the keyword -> level
foreach ($this->default_acl_list as $level => $data) { foreach ($this->default_acl_list as $level => $data) {
$this->acl['min'][$data['type']] = $level; $this->acl['min'][$data['type']] = $level;
@@ -846,6 +847,8 @@ class Login
) { ) {
return false; return false;
} }
// phan claims $this->acl['min'] can be null, but above should skip
/** @phan-suppress-next-line PhanTypeArraySuspiciousNullable */
if ($this->acl[$source] >= $this->acl['min'][$min_access]) { if ($this->acl[$source] >= $this->acl['min'][$min_access]) {
return true; return true;
} }
@@ -1492,7 +1495,7 @@ EOM;
/** /**
* Return ACL array as is * Return ACL array as is
* *
* @return array * @return array<mixed>
*/ */
public function loginGetAcl(): array public function loginGetAcl(): array
{ {

View File

@@ -604,7 +604,7 @@ class PgSQL implements \CoreLibs\DB\SQL\SqlInterface\SqlFunctions
return ''; return '';
} }
// extract element // extract element
$return_string = pg_version($this->dbh)[$parameter] ?? ''; $return_string = (string)(pg_version($this->dbh)[$parameter] ?? '');
// for version, strip if requested // for version, strip if requested
if ( if (
in_array($parameter, ['server']) && in_array($parameter, ['server']) &&