Skip to content

Commit

Permalink
fix PHP 8.0 errors: key(): Argument #1 ($array) must be of type array…
Browse files Browse the repository at this point in the history
…, null given

guarding key() from calling with null eg. $button = key($content['button']) --> key($content['button'] ?? []) or check before !empty($content['button'])
  • Loading branch information
ralfbecker committed Oct 6, 2021
1 parent fe58692 commit 92ba02e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions inc/class.projectmanager_eroles_ui.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,9 @@ function eroles($content=null)
}
}
}
if ($content['delete'] || $content['edit'])
if (!empty($content['delete']) || !empty($content['edit']))
{
$erole = $content['delete'] ? key($content['delete']) : key($content['edit']);
$erole = key($content['delete'] ?? $content['edit']);
if(!($erole = $this->eroles->read($erole)))
{
$msg = lang('Permission denied !!!');
Expand Down
4 changes: 2 additions & 2 deletions inc/class.projectmanager_roles_ui.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,9 @@ function roles($content=null)
}
}
}
if ($content['delete'] || $content['edit'])
if (!empty($content['delete']) || !empty($content['edit']))
{
$role = $content['delete'] ? key($content['delete']) : key($content['edit']);
$role = key($content['delete'] ?? $content['edit']);
if(!($role = $this->roles->read($role)) ||
$role['pm_id'] && !$this->check_acl(EGW_ACL_ROLES,$role['pm_id']) ||
!$role['pm_id'] && !$this->is_admin)
Expand Down
6 changes: 3 additions & 3 deletions inc/class.projectmanager_ui.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ function edit($content=null,$view=false)
{
reset($sel_options['pm_accounting_type']);
$content['pm_accounting_type'] = $preserv['pm_accounting_type'] =
key($sel_options['pm_accounting_type']);
key($sel_options['pm_accounting_type'] ?? []);
}
$readonlys['pm_accounting_type'] = true;
}
Expand Down Expand Up @@ -728,11 +728,11 @@ function pm_list($content=null,$msg='')
$delete_sources = $content['delete_sources'];
$content = $content['nm']['rows'];

if ($content['delete'] || $content['ganttchart'])
if (!empty($content['delete']) || !empty($content['ganttchart']))
{
foreach(array('delete','ganttchart') as $action)
{
if ($content[$action])
if (!empty($content[$action]))
{
$pm_id = key($content[$action]);
break;
Expand Down

0 comments on commit 92ba02e

Please sign in to comment.