Compare commits

...

1 Commits

Author SHA1 Message Date
Clemens Schwaighofer
736f822363 PHPstan check for level 5
Fix various issues for phpstan level 5

Start initial settings for level 6 (needs type declarations for all
vars)
2021-10-22 11:14:00 +09:00
22 changed files with 118 additions and 78 deletions

View File

@@ -33,3 +33,13 @@ last tested PHP 5.6 and PHP 7.0
### namespace ### namespace
The new namespace branch. This is the development area for the master branch The new namespace branch. This is the development area for the master branch
## Static checks
With phpstan
`phpstan`
With phan
`phan --progress-bar -C --analyze-twice`
pslam is setup but not configured

View File

@@ -3,5 +3,7 @@
// Boostrap file for PHPstand // Boostrap file for PHPstand
// sets the _SERVER['HTTP_HOST'] var so we can have DB detection // sets the _SERVER['HTTP_HOST'] var so we can have DB detection
$_SERVER['HTTP_HOST'] = 'soba.tokyo.tequila.jp'; $_SERVER['HTTP_HOST'] = 'soba.tokyo.tequila.jp';
// so www/includes/edit_base.php works
require_once('www/lib/Smarty/SmartyBC.class.php');
// __END__ // __END__

View File

@@ -2,7 +2,7 @@
parameters: parameters:
tmpDir: /tmp/phpstan-corelibs tmpDir: /tmp/phpstan-corelibs
level: 1 level: 5
paths: paths:
- %currentWorkingDirectory%/www - %currentWorkingDirectory%/www
bootstrapFiles: bootstrapFiles:
@@ -20,6 +20,8 @@ parameters:
# no check admin # no check admin
- www/admin/qq_file_upload_front.php - www/admin/qq_file_upload_front.php
- www/admin/qq_file_upload_ajax.php - www/admin/qq_file_upload_ajax.php
- www/admin/class_test*php
- www/admin/error_test.php
# admin synlink files # admin synlink files
- www/admin/edit_access.php - www/admin/edit_access.php
- www/admin/edit_groups.php - www/admin/edit_groups.php
@@ -50,7 +52,10 @@ parameters:
# ignore the smartyextend # ignore the smartyextend
- www/lib/CoreLibs/Template/SmartyExtend.php - www/lib/CoreLibs/Template/SmartyExtend.php
# ignore errores with # ignore errores with
# ignoreErrors: ignoreErrors:
# -
# message: '#Reflection error: [a-zA-Z0-9\\_]+ not found.#'
# path: www/includes/edit_base.php
#- 'error regex' #- 'error regex'
#- #-
# message: 'error regex' # message: 'error regex'

View File

@@ -33,7 +33,7 @@ use CoreLibs\Combined\ArrayHandler;
use CoreLibs\Debug\Support as DgS; use CoreLibs\Debug\Support as DgS;
$basic = new CoreLibs\Basic(); $basic = new CoreLibs\Basic();
// $_array= new CoreLibs\Combined\ArrayHandler(); // $_array = new CoreLibs\Combined\ArrayHandler();
// $array_class = 'CoreLibs\Combination\ArrayHandler'; // $array_class = 'CoreLibs\Combination\ArrayHandler';
print "<html><head><title>TEST CLASS: ARRAY HANDLER</title><head>"; print "<html><head><title>TEST CLASS: ARRAY HANDLER</title><head>";

View File

@@ -42,7 +42,7 @@ function readEnvFile(string $path = __DIR__, string $env_file = '.env'): int
$var = ''; $var = '';
while ($line = fgets($fp)) { while ($line = fgets($fp)) {
// main match for variable = value part // main match for variable = value part
if (preg_match("/^\s*([\w_]+)\s*=\s*((\"?).*)/", $line, $matches)) { if (preg_match("/^\s*([\w_.]+)\s*=\s*((\"?).*)/", $line, $matches)) {
$var = $matches[1]; $var = $matches[1];
$value = $matches[2]; $value = $matches[2];
$quotes = $matches[3]; $quotes = $matches[3];

View File

@@ -176,7 +176,7 @@ class Login extends \CoreLibs\DB\IO
// check what schema to use. if there is a login schema use this, else check // check what schema to use. if there is a login schema use this, else check
// if there is a schema set in the config, or fall back to DB_SCHEMA // if there is a schema set in the config, or fall back to DB_SCHEMA
// if this exists, if this also does not exists use public schema // if this exists, if this also does not exists use public schema
if (defined('LOGIN_DB_SCHEMA') && LOGIN_DB_SCHEMA) { if (defined('LOGIN_DB_SCHEMA') && !empty(LOGIN_DB_SCHEMA)) {
$SCHEMA = LOGIN_DB_SCHEMA; $SCHEMA = LOGIN_DB_SCHEMA;
} elseif (isset($db_config['db_schema']) && $db_config['db_schema']) { } elseif (isset($db_config['db_schema']) && $db_config['db_schema']) {
$SCHEMA = $db_config['db_schema']; $SCHEMA = $db_config['db_schema'];

View File

@@ -178,7 +178,7 @@ class Backend extends \CoreLibs\DB\IO
} }
// check schema // check schema
if (defined('LOGIN_DB_SCHEMA') && LOGIN_DB_SCHEMA) { if (defined('LOGIN_DB_SCHEMA') && !empty(LOGIN_DB_SCHEMA)) {
$SCHEMA = LOGIN_DB_SCHEMA; $SCHEMA = LOGIN_DB_SCHEMA;
} elseif ($this->dbGetSchema()) { } elseif ($this->dbGetSchema()) {
$SCHEMA = $this->dbGetSchema(); $SCHEMA = $this->dbGetSchema();
@@ -475,7 +475,7 @@ class Backend extends \CoreLibs\DB\IO
string $associate = null, string $associate = null,
string $file = null string $file = null
): void { ): void {
if (defined('GLOBAL_DB_SCHEMA') && GLOBAL_DB_SCHEMA) { if (defined('GLOBAL_DB_SCHEMA') && !empty(GLOBAL_DB_SCHEMA)) {
$SCHEMA = GLOBAL_DB_SCHEMA; $SCHEMA = GLOBAL_DB_SCHEMA;
} elseif ($this->dbGetSchema()) { } elseif ($this->dbGetSchema()) {
$SCHEMA = $this->dbGetSchema(); $SCHEMA = $this->dbGetSchema();

View File

@@ -35,8 +35,6 @@ class Password
} else { } else {
return false; return false;
} }
// in case something strange, return false on default
return false;
} }
/** /**
@@ -51,8 +49,6 @@ class Password
} else { } else {
return false; return false;
} }
// in case of strange, force re-hash
return true;
} }
} }

View File

@@ -40,14 +40,10 @@ class PhpVersion
define('PHP_VERSION_ID', (int)$version[0] * 10000 + (int)$version[1] * 100 + (int)$version[2]); define('PHP_VERSION_ID', (int)$version[0] * 10000 + (int)$version[1] * 100 + (int)$version[2]);
} }
// check if matching for version // check if matching for version
if ($min_version && !$max_version) { if (!$max_version && PHP_VERSION_ID >= $min_version) {
if (PHP_VERSION_ID >= $min_version) { return true;
return true; } elseif (PHP_VERSION_ID >= $min_version && PHP_VERSION_ID <= $max_version) {
} return true;
} elseif ($min_version && $max_version) {
if (PHP_VERSION_ID >= $min_version && PHP_VERSION_ID <= $max_version) {
return true;
}
} }
// if no previous return, fail // if no previous return, fail
return false; return false;

View File

@@ -214,6 +214,8 @@ class DateTime
return 0; return 0;
} elseif ($start_date > $end_date) { } elseif ($start_date > $end_date) {
return 1; return 1;
} else {
return false;
} }
} }
@@ -242,6 +244,8 @@ class DateTime
return 0; return 0;
} elseif ($start_timestamp > $end_timestamp) { } elseif ($start_timestamp > $end_timestamp) {
return 1; return 1;
} else {
return false;
} }
} }

View File

@@ -910,7 +910,7 @@ class IO extends \CoreLibs\Basic
$this->db_debug = 0; $this->db_debug = 0;
} elseif ($this->db_debug) { } elseif ($this->db_debug) {
$this->db_debug = 0; $this->db_debug = 0;
} elseif (!$this->db_debug) { } else {
$this->db_debug = 1; $this->db_debug = 1;
} }
return $this->db_debug; return $this->db_debug;
@@ -1789,7 +1789,7 @@ class IO extends \CoreLibs\Basic
); );
$this->insert_id_ext = $this->insert_id; $this->insert_id_ext = $this->insert_id;
$this->insert_id_arr[] = $this->insert_id; $this->insert_id_arr[] = $this->insert_id;
} elseif ($result) { } elseif (!empty($result)) {
$this->insert_id = []; $this->insert_id = [];
$this->insert_id_ext = []; $this->insert_id_ext = [];
$this->insert_id_arr = []; $this->insert_id_arr = [];
@@ -1988,8 +1988,6 @@ class IO extends \CoreLibs\Basic
return 'f'; return 'f';
} }
} }
// if neither, just return data as is
return $string;
} }
// ** REMARK ** // ** REMARK **
@@ -2018,9 +2016,6 @@ class IO extends \CoreLibs\Basic
if (!is_array($not_write_array)) { if (!is_array($not_write_array)) {
$not_write_array = []; $not_write_array = [];
} }
if (is_array($table)) {
return false;
}
$not_write_update_array = []; $not_write_update_array = [];
return $this->dbWriteDataExt( return $this->dbWriteDataExt(
$write_array, $write_array,
@@ -2077,8 +2072,8 @@ class IO extends \CoreLibs\Basic
// loop through the write array and each field to build the query // loop through the write array and each field to build the query
foreach ($write_array as $field) { foreach ($write_array as $field) {
if ( if (
(!$primary_key['value'] || (empty($primary_key['value']) ||
($primary_key['value'] && (!empty($primary_key['value']) &&
!in_array($field, $not_write_update_array)) !in_array($field, $not_write_update_array))
) && ) &&
!in_array($field, $not_write_array) !in_array($field, $not_write_array)

View File

@@ -239,9 +239,9 @@ class PgSQL
* if there is no pk_name tries to auto built it from the table name * if there is no pk_name tries to auto built it from the table name
* this only works if db schema is after "no plural names. and pk name is table name + _id * this only works if db schema is after "no plural names. and pk name is table name + _id
* detects schema prefix in table name * detects schema prefix in table name
* @param string $query query string * @param string $query query string
* @param string $pk_name primary key name, if '' then auto detect * @param string $pk_name primary key name, if '' then auto detect
* @return string|int primary key value * @return string|int|false primary key value
*/ */
public function __dbInsertId(string $query, string $pk_name) public function __dbInsertId(string $query, string $pk_name)
{ {
@@ -274,6 +274,9 @@ class PgSQL
$id = [-1, $q]; $id = [-1, $q];
} }
return $id; return $id;
} else {
//if not insert, return false
return false;
} }
} }
@@ -351,9 +354,7 @@ class PgSQL
$this->dbh = pg_connect("host=" . $db_host . " port=" . $db_port . " user=" $this->dbh = pg_connect("host=" . $db_host . " port=" . $db_port . " user="
. $db_user . " password=" . $db_pass . " dbname=" . $db_name . " sslmode=" . $db_ssl); . $db_user . " password=" . $db_pass . " dbname=" . $db_name . " sslmode=" . $db_ssl);
if (!$this->dbh) { if (!$this->dbh) {
die("<!-- Can't connect [host=" . $db_host . " port=" . $db_port . " user=" die("<!-- Can't connect to database //-->");
. $db_user . " password=XXXX dbname=" . $db_name . " sslmode=" . $db_ssl . "] //-->");
return null;
} }
return $this->dbh; return $this->dbh;
} }

View File

@@ -11,6 +11,7 @@ namespace CoreLibs\Debug;
class FileWriter class FileWriter
{ {
/** @var string */
private static $debug_filename = 'debug_file.log'; // where to write output private static $debug_filename = 'debug_file.log'; // where to write output
/** /**

View File

@@ -341,7 +341,7 @@ class Logging
*/ */
public function debugFor(string $type, string $flag): void public function debugFor(string $type, string $flag): void
{ {
/** @phan-suppress-next-line PhanTypeMismatchArgumentReal */ /** @phan-suppress-next-line PhanTypeMismatchArgumentReal @phpstan-ignore-next-line */
$this->setLogLevel(...[func_get_args()]); $this->setLogLevel(...[func_get_args()]);
} }

View File

@@ -108,13 +108,13 @@ class GetTextReader
/** /**
* Constructor * Constructor
* *
* @param object $Reader the StreamReader object * @param object|bool $Reader the StreamReader object
* @param bool $enable_cache Enable or disable caching of strings (default on) * @param bool $enable_cache Enable or disable caching of strings (default on)
*/ */
public function __construct($Reader, $enable_cache = true) public function __construct($Reader, $enable_cache = true)
{ {
// If there isn't a StreamReader, turn on short circuit mode. // If there isn't a StreamReader, turn on short circuit mode.
if (!$Reader || $Reader->error) { if ((!is_object($Reader) && !$Reader) || (is_object($Reader) && $Reader->error)) {
$this->short_circuit = true; $this->short_circuit = true;
return; return;
} }
@@ -125,7 +125,7 @@ class GetTextReader
$MAGIC1 = "\x95\x04\x12\xde"; $MAGIC1 = "\x95\x04\x12\xde";
$MAGIC2 = "\xde\x12\x04\x95"; $MAGIC2 = "\xde\x12\x04\x95";
$this->STREAM = $Reader; $this->STREAM = (object)$Reader;
$magic = $this->read(4); $magic = $this->read(4);
if ($magic == $MAGIC1) { if ($magic == $MAGIC1) {
$this->BYTEORDER = 1; $this->BYTEORDER = 1;
@@ -351,7 +351,7 @@ class GetTextReader
return $expr; return $expr;
} }
/** /**
* Get possible plural forms from MO header * Get possible plural forms from MO header
* *
* @access private * @access private
@@ -394,6 +394,7 @@ class GetTextReader
$plural = 0; $plural = 0;
eval("$string"); eval("$string");
/** @phpstan-ignore-next-line */
if ($plural >= $total) { if ($plural >= $total) {
$plural = $total - 1; $plural = $total - 1;
} }

View File

@@ -270,6 +270,9 @@ class Elements
return "mailto:" . $email; return "mailto:" . $email;
} elseif ($atag) { } elseif ($atag) {
return $atag . $email; return $atag . $email;
} else {
// else just return email as is
return $email;
} }
} }
} }

View File

@@ -267,6 +267,7 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
*/ */
public function __construct(array $db_config, int $table_width = 750) public function __construct(array $db_config, int $table_width = 750)
{ {
global $table_arrays;
// replace any non valid variable names // replace any non valid variable names
// TODO extracft only alphanumeric and _ after . to _ replacement // TODO extracft only alphanumeric and _ after . to _ replacement
$this->my_page_name = str_replace(['.'], '_', \CoreLibs\Get\System::getPageName(1)); $this->my_page_name = str_replace(['.'], '_', \CoreLibs\Get\System::getPageName(1));
@@ -278,12 +279,15 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
// first check if we have a in page override as $table_arrays[page name] // first check if we have a in page override as $table_arrays[page name]
if ( if (
isset($_GLOBALS['table_arrays']) && /* isset($GLOBALS['table_arrays']) &&
is_array($_GLOBALS['table_arrays']) && is_array($GLOBALS['table_arrays']) &&
isset($_GLOBALS['table_arrays'][\CoreLibs\Get\System::getPageName(1)]) && isset($GLOBALS['table_arrays'][\CoreLibs\Get\System::getPageName(1)]) &&
is_array($_GLOBALS['table_arrays'][\CoreLibs\Get\System::getPageName(1)]) is_array($GLOBALS['table_arrays'][\CoreLibs\Get\System::getPageName(1)]) */
isset($table_arrays[\CoreLibs\Get\System::getPageName(1)]) &&
is_array($table_arrays[\CoreLibs\Get\System::getPageName(1)])
) { ) {
$config_array = $_GLOBALS['table_arrays'][\CoreLibs\Get\System::getPageName(1)]; // $config_array = $GLOBALS['table_arrays'][\CoreLibs\Get\System::getPageName(1)];
$config_array = $table_arrays[\CoreLibs\Get\System::getPageName(1)];
} else { } else {
// WARNING: auto spl load does not work with this as it is an array and not a function/object // WARNING: auto spl load does not work with this as it is an array and not a function/object
// check if this is the old path or the new path // check if this is the old path or the new path
@@ -810,7 +814,6 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
(isset($this->security_level['delete']) && (isset($this->security_level['delete']) &&
$this->base_acl_level >= $this->security_level['delete']) $this->base_acl_level >= $this->security_level['delete'])
) { ) {
$old_school_hidden = 0;
if ($this->base_acl_level >= $this->security_level['save']) { if ($this->base_acl_level >= $this->security_level['save']) {
$seclevel_okay = 1; $seclevel_okay = 1;
if (empty($this->table_array[$this->int_pk_name]['value'])) { if (empty($this->table_array[$this->int_pk_name]['value'])) {
@@ -819,7 +822,7 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
$save = $this->l->__('Update'); $save = $this->l->__('Update');
} }
// print the old_school hidden if requestet // print the old_school hidden if requestet
if ($old_school_hidden) { if ($old_school_hidden == 1) {
$pk_name = $this->int_pk_name; $pk_name = $this->int_pk_name;
$pk_value = $this->table_array[$this->int_pk_name]['value']; $pk_value = $this->table_array[$this->int_pk_name]['value'];
} }
@@ -1270,7 +1273,10 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
// if mandatory && no input // if mandatory && no input
// $this->log->debug('form', 'A: ' . $this->table_array[$key]['type'] . ' -- ' // $this->log->debug('form', 'A: ' . $this->table_array[$key]['type'] . ' -- '
// . $this->table_array[$key]['input_value'] . ' -- ' . $this->table_array[$key]['value']); // . $this->table_array[$key]['input_value'] . ' -- ' . $this->table_array[$key]['value']);
if (!$this->table_array[$key]['value'] && $this->table_array[$key]['type'] != 'binary') { if (
empty($this->table_array[$key]['value']) &&
$this->table_array[$key]['type'] != 'binary'
) {
$this->msg .= sprintf( $this->msg .= sprintf(
$this->l->__('Please enter something into the <b>%s</b> field!<br>'), $this->l->__('Please enter something into the <b>%s</b> field!<br>'),
$this->table_array[$key]['output_name'] $this->table_array[$key]['output_name']
@@ -1505,7 +1511,7 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
if ($order_name) { if ($order_name) {
// first check out of order ... // first check out of order ...
if (!$this->table_array[$order_name]['value']) { if (empty($this->table_array[$order_name]['value'])) {
// set order (read max) // set order (read max)
$q = 'SELECT MAX(' . $order_name . ') + 1 AS max_page_order FROM ' . $this->table_name; $q = 'SELECT MAX(' . $order_name . ') + 1 AS max_page_order FROM ' . $this->table_name;
list($this->table_array[$order_name]['value']) = $this->dbReturnRow($q); list($this->table_array[$order_name]['value']) = $this->dbReturnRow($q);
@@ -1513,7 +1519,7 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
if (!$this->table_array[$order_name]['value']) { if (!$this->table_array[$order_name]['value']) {
$this->table_array[$order_name]['value'] = 1; $this->table_array[$order_name]['value'] = 1;
} }
} elseif ($this->table_array[$this->int_pk_name]['value']) { } elseif (!empty($this->table_array[$this->int_pk_name]['value'])) {
$q = 'SELECT ' . $order_name $q = 'SELECT ' . $order_name
. ' FROM ' . $this->table_name . ' FROM ' . $this->table_name
. ' WHERE ' . $this->int_pk_name . ' = ' . $this->table_array[$this->int_pk_name]['value']; . ' WHERE ' . $this->int_pk_name . ' = ' . $this->table_array[$this->int_pk_name]['value'];
@@ -2377,7 +2383,7 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
$this->element_list[$table_name]['max_empty'] = 10; $this->element_list[$table_name]['max_empty'] = 10;
} }
// check if we need to fill fields // check if we need to fill fields
$element_count = (isset($data['content']) && is_array($data['content'])) ? count($data['content']) : 0; $element_count = count($data['content'] ?? []);
$missing_empty_count = $this->element_list[$table_name]['max_empty'] - $element_count; $missing_empty_count = $this->element_list[$table_name]['max_empty'] - $element_count;
$this->log->debug('CFG MAX', 'Max empty: ' $this->log->debug('CFG MAX', 'Max empty: '
. $this->element_list[$table_name]['max_empty'] . ', Missing: ' . $missing_empty_count . $this->element_list[$table_name]['max_empty'] . ', Missing: ' . $missing_empty_count

View File

@@ -130,10 +130,10 @@ class Image
array_map('unlink', glob($delete_filename . '*')); array_map('unlink', glob($delete_filename . '*'));
} }
} else { } else {
if ($dummy && strstr($dummy, '/') === false) { if (!empty($dummy) && strstr($dummy, '/') === false) {
// check if we have the "dummy" image flag set // check if we have the "dummy" image flag set
$filename = PICTURES . ICONS . strtoupper($dummy) . ".png"; $filename = PICTURES . ICONS . strtoupper($dummy) . ".png";
if ($dummy && file_exists($filename) && is_file($filename)) { if (!empty($dummy) && file_exists($filename) && is_file($filename)) {
$return_data = $filename; $return_data = $filename;
} else { } else {
$return_data = false; $return_data = false;

View File

@@ -22,9 +22,13 @@ class ProgressBar
{ {
// private vars // private vars
/** @var string */
public $code; // unique code public $code; // unique code
/** @var string */
public $status = 'new'; // current status (new,show,hide) public $status = 'new'; // current status (new,show,hide)
/** @var int */
public $step = 0; // current step public $step = 0; // current step
/** @var array<string,?int> */
public $position = [ // current bar position public $position = [ // current bar position
'left' => null, 'left' => null,
'top' => null, 'top' => null,
@@ -32,27 +36,43 @@ class ProgressBar
'height' => null, 'height' => null,
]; ];
/** @var int */
public $clear_buffer_size = 1; // we need to send this before the lfush to get browser output public $clear_buffer_size = 1; // we need to send this before the lfush to get browser output
/** @var int */
public $clear_buffer_size_init = 1024 * 1024; // if I don't send that junk, it won't send anything public $clear_buffer_size_init = 1024 * 1024; // if I don't send that junk, it won't send anything
// public vars // public vars
/** @var int */
public $min = 0; // minimal steps public $min = 0; // minimal steps
/** @var int */
public $max = 100; // maximal steps public $max = 100; // maximal steps
/** @var int */
public $left = 5; // bar position from left public $left = 5; // bar position from left
/** @var int */
public $top = 5; // bar position from top public $top = 5; // bar position from top
/** @var int */
public $width = 300; // bar width public $width = 300; // bar width
/** @var int */
public $height = 25; // bar height public $height = 25; // bar height
/** @var int */
public $pedding = 0; // bar pedding public $pedding = 0; // bar pedding
/** @var string */
public $color = '#0033ff'; // bar color public $color = '#0033ff'; // bar color
/** @var string */
public $bgr_color = '#c0c0c0'; // bar background color public $bgr_color = '#c0c0c0'; // bar background color
/** @var string */
public $bgr_color_master = '#ffffff'; // master div background color public $bgr_color_master = '#ffffff'; // master div background color
/** @var int */
public $border = 1; // bar border width public $border = 1; // bar border width
/** @var string */
public $brd_color = '#000000'; // bar border color public $brd_color = '#000000'; // bar border color
/** @var string */
public $direction = 'right'; // direction of motion (right,left,up,down) public $direction = 'right'; // direction of motion (right,left,up,down)
/** @var array<string,mixed> */
public $frame = ['show' => false]; // ProgressBar Frame public $frame = ['show' => false]; // ProgressBar Frame
/* 'show' => false, # frame show (true/false) /* 'show' => false, # frame show (true/false)
'left' => 200, # frame position from left 'left' => 200, # frame position from left
@@ -64,6 +84,7 @@ class ProgressBar
'brd_color' => '#dfdfdf #404040 #404040 #dfdfdf' # frame border color 'brd_color' => '#dfdfdf #404040 #404040 #dfdfdf' # frame border color
*/ */
/** @var array<mixed> */
public $label = []; // ProgressBar Labels public $label = []; // ProgressBar Labels
/* 'name' => [ # label name /* 'name' => [ # label name
'type' => 'text', # label type (text,button,step,percent,crossbar) 'type' => 'text', # label type (text,button,step,percent,crossbar)
@@ -81,6 +102,7 @@ class ProgressBar
] ]
*/ */
/** @var string */
// output strings // output strings
public $prefix_message = ''; public $prefix_message = '';
@@ -141,8 +163,8 @@ class ProgressBar
/** /**
* calculate position in bar step * calculate position in bar step
* @param float $step percent step to do * @param float $step percent step to do
* @return array bar position as array * @return array<mixed> bar position as array
*/ */
private function __calculatePosition(float $step): array private function __calculatePosition(float $step): array
{ {

View File

@@ -10,22 +10,24 @@
* error etc will still be written to the log/display * error etc will still be written to the log/display
*********************************************************************/ *********************************************************************/
declare(strict_types=1); declare(strict_types=1);
/** /**
* will catch any error except E_ERROR and try to write them to the log file * will catch any error except E_ERROR and try to write them to the log file
* in log/php_error-<DAY>.log * in log/php_error-<DAY>.log
* if this fails, it will print the data to the window via echo * if this fails, it will print the data to the window via echo
* @param int $type the error code from PHP * @param int $type the error code from PHP
* @param string $message the error message from php * @param string $message the error message from php
* @param string $file in which file the error happend. this is the source file (eg include) * @param string $file in which file the error happend.
* @param int $line in which line the error happened * this is the source file (eg include)
* @param array $context array with all the variable * @param int $line in which line the error happened
* @return bool true, so cought errors do not get processed by the PHP error engine * @param array<mixed> $context array with all the variable
* @return bool True, so cought errors do not get processed
* by the PHP error engine
*/ */
function MyErrorHandler(int $type, string $message, string $file, int $line, array $context): bool function MyErrorHandler(int $type, string $message, string $file, int $line, array $context): bool
{ {
if (!(error_reporting() & $type) && !SHOW_ALL_ERRORS) { if (!(error_reporting() & $type) && empty(SHOW_ALL_ERRORS)) {
// This error code is not included in error_reporting // This error code is not included in error_reporting
return false; return false;
} }

View File

@@ -10,21 +10,26 @@ if (class_exists('Autoload', false) === false) {
// define the auto loader class // define the auto loader class
class Autoload class Autoload
{ {
// we do it simple here /**
// passes on the class to load and we search here in namespace * we do it simple here
// to load that class * passes on the class to load and we search here in namespace
public static function load($class) * to load that class
*
* @param string $class Namespace + class to load
* @return void
*/
public static function load(string $class)
{ {
// print "(1) Class: $class / DIR: ".__DIR__."<br>"; // print "(1) Class: $class / DIR: ".__DIR__."<br>";
// set directory seperator (we need to replace from namespace) // set directory seperator (we need to replace from namespace)
$DS = defined('DS') ? DS : DIRECTORY_SEPARATOR; $DS = DIRECTORY_SEPARATOR;
// base lib // base lib
$LIB = defined('LIB') ? LIB : 'lib' . $DS; $LIB = defined('LIB') ? LIB : 'lib' . $DS;
// if lib is in path at the end, do not add lib again // if lib is in path at the end, do not add lib again
// note that $LIB can have a directory seperator at the end // note that $LIB can have a directory seperator at the end
// strip that out before we do a match // strip that out before we do a match
$_LIB = rtrim($LIB, $DS); $_LIB = rtrim($LIB, $DS);
if (preg_match("|$_LIB$|", __DIR__) === false) { if (!preg_match("|$_LIB$|", __DIR__)) {
$LIB .= $DS; $LIB .= $DS;
} else { } else {
$LIB = ''; $LIB = '';
@@ -50,9 +55,7 @@ if (class_exists('Autoload', false) === false) {
// we should sub that // we should sub that
// self::loadFile($path); // self::loadFile($path);
include $path; include $path;
return true;
} }
return false;
} }
// end class define // end class define
} }

View File

@@ -11,12 +11,6 @@
<projectFiles> <projectFiles>
<file name="admin/class_test.php" /> <file name="admin/class_test.php" />
<file name="admin/config.php" /> <file name="admin/config.php" />
<file name="admin/error_test.php" />
<file name="admin/l10n_test.php" />
<file name="admin/namespace_test.php" />
<file name="admin/other_test.php" />
<file name="admin/smarty_test.php" />
<file name="admin/various_class_test.php" />
<directory name="configs" /> <directory name="configs" />
<directory name="frontend" /> <directory name="frontend" />
<directory name="includes" /> <directory name="includes" />
@@ -58,7 +52,6 @@
<MissingReturnType errorLevel="error" /> <MissingReturnType errorLevel="error" />
<MissingPropertyType errorLevel="error" /> <MissingPropertyType errorLevel="error" />
<InvalidDocblock errorLevel="error" /> <InvalidDocblock errorLevel="error" />
<MisplacedRequiredParam errorLevel="error" />
<PropertyNotSetInConstructor errorLevel="error" /> <PropertyNotSetInConstructor errorLevel="error" />
<MissingConstructor errorLevel="error" /> <MissingConstructor errorLevel="error" />