1 | <?php |
||
2 | |||
3 | /** |
||
4 | * FreeBusyModule Module. |
||
5 | */ |
||
6 | class FreeBusyModule extends Module { |
||
7 | public function __construct($id, $data) { |
||
8 | parent::__construct($id, $data); |
||
9 | } |
||
10 | |||
11 | #[Override] |
||
12 | public function execute() { |
||
13 | foreach ($this->data as $actionType => $selUser) { |
||
14 | if (isset($actionType)) { |
||
15 | try { |
||
16 | match ($actionType) { |
||
17 | 'list' => $this->addUserData($selUser), |
||
0 ignored issues
–
show
|
|||
18 | default => $this->handleUnknownActionType($actionType), |
||
0 ignored issues
–
show
Are you sure the usage of
$this->handleUnknownActionType($actionType) targeting Module::handleUnknownActionType() seems to always return null.
This check looks for function or method calls that always return null and whose return value is used. class A
{
function getObject()
{
return null;
}
}
$a = new A();
if ($a->getObject()) {
The method The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes. ![]() |
|||
19 | }; |
||
20 | } |
||
21 | catch (MAPIException $e) { |
||
22 | $this->processException($e, $actionType); |
||
23 | } |
||
24 | } |
||
25 | } |
||
26 | } |
||
27 | |||
28 | /** |
||
29 | * This function will get user info from address book and add freebusy data of the user to |
||
30 | * response. |
||
31 | * |
||
32 | * @param array $selUser User that should be resolved |
||
33 | */ |
||
34 | public function addUserData($selUser) { |
||
35 | $data = [ |
||
36 | 'users' => [], |
||
37 | ]; |
||
38 | |||
39 | foreach ($selUser['users'] as $fbUser) { |
||
40 | // Copy the identifier of the user. |
||
41 | $user = [ |
||
42 | 'userid' => $fbUser['userid'], |
||
43 | 'entryid' => $fbUser['entryid'], |
||
44 | ]; |
||
45 | |||
46 | // Obtain the Freebusy data for this user |
||
47 | $busyArray = $this->getFreeBusyInfo($fbUser['entryid'], $selUser['start'], $selUser['end']); |
||
48 | $user['items'] = $busyArray; |
||
49 | $data['users'][] = $user; |
||
50 | } |
||
51 | |||
52 | $this->addActionData('list', $data); |
||
53 | $GLOBALS['bus']->addData($this->getResponseData()); |
||
54 | } |
||
55 | |||
56 | /** |
||
57 | * This function will get freebusy data for user based on the timeframe passed in arguments. |
||
58 | * |
||
59 | * @param string $entryID Entryid of the user for which we need to get freebusy data |
||
60 | * @param int $start start offset for freebusy publish range |
||
61 | * @param int $end end offset for freebusy publish range |
||
62 | * |
||
63 | * @return array freebusy blocks for passed publish range |
||
64 | */ |
||
65 | public function getFreeBusyInfo($entryID, $start, $end) { |
||
66 | $result = []; |
||
67 | |||
68 | $fbdata = mapi_getuserfreebusy($GLOBALS['mapisession']->getSession(), hex2bin($entryID), $start, $end); |
||
69 | |||
70 | foreach ($fbdata['fbevents'] as $event) { |
||
71 | $result[] = [ |
||
72 | 'start' => $event['start'], |
||
73 | 'end' => $event['end'], |
||
74 | 'status' => $event['busystatus'], |
||
75 | ]; |
||
76 | } |
||
77 | |||
78 | return $result; |
||
79 | } |
||
80 | } |
||
81 |
This check looks for function or method calls that always return null and whose return value is used.
The method
getObject()
can return nothing but null, so it makes no sense to use the return value.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.