Avoid some PHP warnings

- Undefined array keys
- Undefined class variables
- Passing null to string functions
This commit is contained in:
nathan 2023-06-07 13:50:08 -06:00
parent f16cfd45fe
commit 492993e78e
6 changed files with 15 additions and 7 deletions

View File

@ -114,7 +114,7 @@ class Date extends Transformer
return $value;
} // otherwise we will get current date or 1970-01-01 instead of an empty value
$format = $this->attrs['dataFormat'] ?? $this->attrs['data_format'];
$format = $this->attrs['dataFormat'] ?? $this->attrs['data_format'] ?? "";
// for DateTime objects (regular PHP and Api\DateTime ones), set user timezone
if($value instanceof \DateTime)
{

View File

@ -189,9 +189,9 @@ class Grid extends Box
foreach(array_merge(array($direct_child), $n ? array() : $direct_child->children) as $child)
{
$pat = $child->id;
while(($patstr = strstr($pat, '$')))
while($pat && ($patstr = strstr($pat, '$')))
{
$pat = substr($patstr,$patstr[1] == '{' ? 2 : 1);
$pat = substr($patstr, $patstr[1] == '{' ? 2 : 1);
switch ($this->type)
{

View File

@ -136,7 +136,7 @@ class Nextmatch extends Etemplate\Widget
}
// Check for sort preference. We only apply this on first load so it can be changed
if($GLOBALS['egw_info']['user']['preferences'][$app][$this->attrs['template'] . "_sort"])
if(array_key_exists($this->attrs['template'] . "_sort", $GLOBALS['egw_info']['user']['preferences'][$app]))
{
$send_value['sort'] = $GLOBALS['egw_info']['user']['preferences'][$app][$this->attrs['template'] . "_sort"];
}

View File

@ -644,7 +644,7 @@ class Select extends Etemplate\Widget
}
// Legacy / static support
// Have to do this explicitly, since legacy options is not defined on class level
$legacy_options = explode(',',$_legacy_options);
$legacy_options = explode(',', $_legacy_options ?? "");
foreach($legacy_options as &$field)
{
$field = self::expand_name($field, 0, 0,'','',self::$cont);

View File

@ -261,12 +261,16 @@ class Hooks
// some apps have setup_info for more then themselfs (eg. api for groupdav)
foreach($setup_info as $appname => $data)
{
if(!array_key_exists('hooks', $data))
{
continue;
}
foreach((array)$data['hooks'] as $location => $methods)
{
if (is_int($location))
{
$location = $methods;
$methods = '/'.$appname.'/inc/hook_'.$methods.'.inc.php';
$methods = '/' . $appname . '/inc/hook_' . $methods . '.inc.php';
}
$locations[$location][$appname] = (array)$methods;
}

View File

@ -51,6 +51,10 @@ class importexport_definitions_ui
* @var object
*/
var $plugin;
private Etemplate $etpl;
private string $clock;
private array $steps;
private $wizard_content_template;
function __construct()
{
@ -60,7 +64,7 @@ class importexport_definitions_ui
$GLOBALS['egw_info']['flags']['currentapp'] = self::_appname;
$this->etpl = new Etemplate();
$this->clock = Api\Html::image(self::_appname,'clock');
$this->clock = Api\Html::image(self::_appname, 'clock');
$this->steps = array(
'wizard_step10' => lang('Choose an application'),
'wizard_step20' => lang('Choose a plugin'),