These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | /** |
||
3 | * Delete a user. |
||
4 | * |
||
5 | * The user will be deleted recursively, meaning all entities |
||
6 | * owned or contained by the user will also be removed. |
||
7 | */ |
||
8 | |||
9 | // Get the user |
||
10 | $guid = get_input('guid'); |
||
11 | $user = get_user($guid); |
||
12 | |||
13 | if ($guid == elgg_get_logged_in_user_guid()) { |
||
14 | return elgg_error_response(elgg_echo('admin:user:self:delete:no')); |
||
15 | } |
||
16 | |||
17 | if (!$user || !$user->canEdit()) { |
||
1 ignored issue
–
show
|
|||
18 | return elgg_error_response(elgg_echo('admin:user:delete:no')); |
||
19 | } |
||
20 | |||
21 | $name = $user->getDisplayName(); |
||
1 ignored issue
–
show
The method
getDisplayName does only exist in ElggEntity , but not in stdClass .
It seems like the method you are trying to call exists only in some of the possible types. Let’s take a look at an example: class A
{
public function foo() { }
}
class B extends A
{
public function bar() { }
}
/**
* @param A|B $x
*/
function someFunction($x)
{
$x->foo(); // This call is fine as the method exists in A and B.
$x->bar(); // This method only exists in B and might cause an error.
}
Available Fixes
![]() |
|||
22 | $username = $user->username; |
||
23 | |||
24 | if (!$user->delete()) { |
||
1 ignored issue
–
show
The method
delete does only exist in ElggEntity , but not in stdClass .
It seems like the method you are trying to call exists only in some of the possible types. Let’s take a look at an example: class A
{
public function foo() { }
}
class B extends A
{
public function bar() { }
}
/**
* @param A|B $x
*/
function someFunction($x)
{
$x->foo(); // This call is fine as the method exists in A and B.
$x->bar(); // This method only exists in B and might cause an error.
}
Available Fixes
![]() |
|||
25 | return elgg_error_response(elgg_echo('admin:user:delete:no')); |
||
26 | } |
||
27 | |||
28 | // forward to user administration if on a user's page as it no longer exists |
||
29 | $forward = REFERER; |
||
30 | if (strpos($_SERVER['HTTP_REFERER'], $username) != false) { |
||
31 | $forward = 'admin/users/newest'; |
||
32 | } |
||
33 | |||
34 | return elgg_ok_response('', elgg_echo('admin:user:delete:yes'), $forward); |
||
35 |
It seems like the method you are trying to call exists only in some of the possible types.
Let’s take a look at an example:
Available Fixes
Add an additional type-check:
Only allow a single type to be passed if the variable comes from a parameter: