Completed
Push — master ( 173441...3e3f46 )
by Maxence
16s queued 11s
created

Provider::parseAsModerator()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 9
rs 9.9666
cc 2
nc 2
nop 3
1
<?php
2
3
/**
4
 * Circles - Bring cloud-users closer together.
5
 *
6
 * This file is licensed under the Affero General Public License version 3 or
7
 * later. See the COPYING file.
8
 *
9
 * @author Maxence Lange <[email protected]>
10
 * @copyright 2017
11
 * @license GNU AGPL version 3 or any later version
12
 *
13
 * This program is free software: you can redistribute it and/or modify
14
 * it under the terms of the GNU Affero General Public License as
15
 * published by the Free Software Foundation, either version 3 of the
16
 * License, or (at your option) any later version.
17
 *
18
 * This program is distributed in the hope that it will be useful,
19
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21
 * GNU Affero General Public License for more details.
22
 *
23
 * You should have received a copy of the GNU Affero General Public License
24
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
25
 *
26
 */
27
28
namespace OCA\Circles\Activity;
29
30
use Exception;
31
use InvalidArgumentException;
32
use OCA\Circles\AppInfo\Application;
33
use OCA\Circles\Exceptions\FakeException;
34
use OCA\Circles\Model\Circle;
35
use OCA\Circles\Model\FederatedLink;
36
use OCA\Circles\Model\Member;
37
use OCA\Circles\Service\CirclesService;
38
use OCA\Circles\Service\MiscService;
39
use OCP\Activity\IEvent;
40
use OCP\Activity\IManager;
41
use OCP\Activity\IProvider;
42
use OpenCloud\Common\Exceptions\InvalidArgumentError;
43
44
class Provider implements IProvider {
45
46
47
	/** @var ProviderSubjectCircle */
48
	private $parserCircle;
49
50
	/** @var ProviderSubjectMember */
51
	private $parserMember;
52
53
	/** @var ProviderSubjectGroup */
54
	private $parserGroup;
55
56
	/** @var ProviderSubjectLink */
57
	private $parserLink;
58
59
	/** @var MiscService */
60
	protected $miscService;
61
62
	/** @var IManager */
63
	protected $activityManager;
64
65
66
	public function __construct(
67
		IManager $activityManager, MiscService $miscService, ProviderSubjectCircle $parserCircle,
68
		ProviderSubjectMember $parserMember, ProviderSubjectGroup $parserGroup,
69
		ProviderSubjectLink $parserLink
70
	) {
71
		$this->activityManager = $activityManager;
72
		$this->miscService = $miscService;
73
74
		$this->parserCircle = $parserCircle;
75
		$this->parserMember = $parserMember;
76
		$this->parserGroup = $parserGroup;
77
		$this->parserLink = $parserLink;
78
	}
79
80
81
	/**
82
	 * {@inheritdoc}
83
	 */
84
	public function parse($lang, IEvent $event, IEvent $previousEvent = null) {
85
86
		try {
87
			$params = $event->getSubjectParameters();
88
			$this->initActivityParser($event, $params);
89
90
			$circle = Circle::fromJSON($params['circle']);
91
92
			$this->setIcon($event, $circle);
93
			$this->parseAsNonMember($event, $circle, $params);
94
			$this->parseAsMember($event, $circle, $params);
95
			$this->parseAsModerator($event, $circle, $params);
96
97
		} catch (FakeException $e) {
98
			/** clean exit */
99
		}
100
101
		return $event;
102
	}
103
104
105
	/**
106
	 * @param IEvent $event
107
	 * @param array $params
108
	 */
109
	private function initActivityParser(IEvent $event, $params) {
110
		if ($event->getApp() !== Application::APP_NAME) {
111
			throw new InvalidArgumentException();
112
		}
113
114
		if (!key_exists('circle', $params)) {
115
			throw new InvalidArgumentException();
116
		}
117
	}
118
119
120
	/**
121
	 * @param IEvent $event
122
	 * @param Circle $circle
123
	 */
124
	private function setIcon(IEvent $event, Circle $circle) {
125
		$event->setIcon(
126
			CirclesService::getCircleIcon(
127
				$circle->getType(),
128
				(method_exists($this->activityManager, 'getRequirePNG')
129
				 && $this->activityManager->getRequirePNG())
130
			)
131
		);
132
	}
133
134
135
136
	/**
137
	 * @param IEvent $event
138
	 * @param Circle $circle
139
	 * @param array $params
140
	 *
141
	 * @throws FakeException
142
	 */
143
	private function parseAsNonMember(IEvent $event, Circle $circle, $params) {
144
		if ($event->getType() !== 'circles_as_non_member') {
145
			return;
146
		}
147
148
		$this->parserCircle->parseSubjectCircleCreate($event, $circle);
149
	}
150
151
	/**
152
	 * @param IEvent $event
153
	 * @param Circle $circle
154
	 * @param array $params
155
	 *
156
	 * @throws FakeException
157
	 */
158
	private function parseAsMember(IEvent $event, Circle $circle, $params) {
159
		if ($event->getType() !== 'circles_as_member') {
160
			return;
161
		}
162
163
//		$this->parserCircle->parseSubjectCircleCreate($event, $circle);
164
		$this->parserCircle->parseSubjectCircleDelete($event, $circle);
165
		$this->parseMemberAsMember($event, $circle, $params);
166
	}
167
168
169
	/**
170
	 * @param Circle $circle
171
	 * @param IEvent $event
172
	 * @param array $params
173
	 *
174
	 * @throws Exception
175
	 */
176
	private function parseAsModerator(IEvent $event, Circle $circle, $params) {
177
		if ($event->getType() !== 'circles_as_moderator') {
178
			return;
179
		}
180
181
		$this->parseMemberAsModerator($event, $circle, $params);
182
		$this->parseGroupAsModerator($event, $circle, $params);
183
		$this->parseLinkAsModerator($event, $circle, $params);
184
	}
185
186
187
	/**
188
	 * @param IEvent $event
189
	 * @param Circle $circle
190
	 * @param array $params
191
	 *
192
	 * @throws InvalidArgumentError
193
	 */
194 View Code Duplication
	private function parseMemberAsMember(IEvent $event, Circle $circle, $params) {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
195
196
		if (!key_exists('member', $params)) {
197
			return;
198
		}
199
200
		$member = Member::fromJSON($params['member']);
201
202
		$this->parserMember->parseSubjectMemberJoin($event, $circle, $member);
0 ignored issues
show
Bug introduced by
It seems like $member defined by \OCA\Circles\Model\Membe...JSON($params['member']) on line 200 can be null; however, OCA\Circles\Activity\Pro...arseSubjectMemberJoin() does not accept null, maybe add an additional type check?

Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code:

/** @return stdClass|null */
function mayReturnNull() { }

function doesNotAcceptNull(stdClass $x) { }

// With potential error.
function withoutCheck() {
    $x = mayReturnNull();
    doesNotAcceptNull($x); // Potential error here.
}

// Safe - Alternative 1
function withCheck1() {
    $x = mayReturnNull();
    if ( ! $x instanceof stdClass) {
        throw new \LogicException('$x must be defined.');
    }
    doesNotAcceptNull($x);
}

// Safe - Alternative 2
function withCheck2() {
    $x = mayReturnNull();
    if ($x instanceof stdClass) {
        doesNotAcceptNull($x);
    }
}
Loading history...
203
		$this->parserMember->parseSubjectMemberAdd($event, $circle, $member);
0 ignored issues
show
Bug introduced by
It seems like $member defined by \OCA\Circles\Model\Membe...JSON($params['member']) on line 200 can be null; however, OCA\Circles\Activity\Pro...parseSubjectMemberAdd() does not accept null, maybe add an additional type check?

Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code:

/** @return stdClass|null */
function mayReturnNull() { }

function doesNotAcceptNull(stdClass $x) { }

// With potential error.
function withoutCheck() {
    $x = mayReturnNull();
    doesNotAcceptNull($x); // Potential error here.
}

// Safe - Alternative 1
function withCheck1() {
    $x = mayReturnNull();
    if ( ! $x instanceof stdClass) {
        throw new \LogicException('$x must be defined.');
    }
    doesNotAcceptNull($x);
}

// Safe - Alternative 2
function withCheck2() {
    $x = mayReturnNull();
    if ($x instanceof stdClass) {
        doesNotAcceptNull($x);
    }
}
Loading history...
204
		$this->parserMember->parseSubjectMemberLeft($event, $circle, $member);
0 ignored issues
show
Bug introduced by
It seems like $member defined by \OCA\Circles\Model\Membe...JSON($params['member']) on line 200 can be null; however, OCA\Circles\Activity\Pro...arseSubjectMemberLeft() does not accept null, maybe add an additional type check?

Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code:

/** @return stdClass|null */
function mayReturnNull() { }

function doesNotAcceptNull(stdClass $x) { }

// With potential error.
function withoutCheck() {
    $x = mayReturnNull();
    doesNotAcceptNull($x); // Potential error here.
}

// Safe - Alternative 1
function withCheck1() {
    $x = mayReturnNull();
    if ( ! $x instanceof stdClass) {
        throw new \LogicException('$x must be defined.');
    }
    doesNotAcceptNull($x);
}

// Safe - Alternative 2
function withCheck2() {
    $x = mayReturnNull();
    if ($x instanceof stdClass) {
        doesNotAcceptNull($x);
    }
}
Loading history...
205
		$this->parserMember->parseSubjectMemberRemove($event, $circle, $member);
0 ignored issues
show
Bug introduced by
It seems like $member defined by \OCA\Circles\Model\Membe...JSON($params['member']) on line 200 can be null; however, OCA\Circles\Activity\Pro...seSubjectMemberRemove() does not accept null, maybe add an additional type check?

Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code:

/** @return stdClass|null */
function mayReturnNull() { }

function doesNotAcceptNull(stdClass $x) { }

// With potential error.
function withoutCheck() {
    $x = mayReturnNull();
    doesNotAcceptNull($x); // Potential error here.
}

// Safe - Alternative 1
function withCheck1() {
    $x = mayReturnNull();
    if ( ! $x instanceof stdClass) {
        throw new \LogicException('$x must be defined.');
    }
    doesNotAcceptNull($x);
}

// Safe - Alternative 2
function withCheck2() {
    $x = mayReturnNull();
    if ($x instanceof stdClass) {
        doesNotAcceptNull($x);
    }
}
Loading history...
206
	}
207
208
209
	/**
210
	 * @param IEvent $event
211
	 * @param Circle $circle
212
	 * @param array $params
213
	 */
214
	private function parseGroupAsModerator(IEvent $event, Circle $circle, $params) {
215
		if (!key_exists('group', $params)) {
216
			return;
217
		}
218
219
		$group = Member::fromJSON($params['group']);
220
221
		$this->parserGroup->parseGroupLink($event, $circle, $group);
0 ignored issues
show
Bug introduced by
It seems like $group defined by \OCA\Circles\Model\Membe...mJSON($params['group']) on line 219 can be null; however, OCA\Circles\Activity\Pro...Group::parseGroupLink() does not accept null, maybe add an additional type check?

Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code:

/** @return stdClass|null */
function mayReturnNull() { }

function doesNotAcceptNull(stdClass $x) { }

// With potential error.
function withoutCheck() {
    $x = mayReturnNull();
    doesNotAcceptNull($x); // Potential error here.
}

// Safe - Alternative 1
function withCheck1() {
    $x = mayReturnNull();
    if ( ! $x instanceof stdClass) {
        throw new \LogicException('$x must be defined.');
    }
    doesNotAcceptNull($x);
}

// Safe - Alternative 2
function withCheck2() {
    $x = mayReturnNull();
    if ($x instanceof stdClass) {
        doesNotAcceptNull($x);
    }
}
Loading history...
222
		$this->parserGroup->parseGroupUnlink($event, $circle, $group);
0 ignored issues
show
Bug introduced by
It seems like $group defined by \OCA\Circles\Model\Membe...mJSON($params['group']) on line 219 can be null; however, OCA\Circles\Activity\Pro...oup::parseGroupUnlink() does not accept null, maybe add an additional type check?

Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code:

/** @return stdClass|null */
function mayReturnNull() { }

function doesNotAcceptNull(stdClass $x) { }

// With potential error.
function withoutCheck() {
    $x = mayReturnNull();
    doesNotAcceptNull($x); // Potential error here.
}

// Safe - Alternative 1
function withCheck1() {
    $x = mayReturnNull();
    if ( ! $x instanceof stdClass) {
        throw new \LogicException('$x must be defined.');
    }
    doesNotAcceptNull($x);
}

// Safe - Alternative 2
function withCheck2() {
    $x = mayReturnNull();
    if ($x instanceof stdClass) {
        doesNotAcceptNull($x);
    }
}
Loading history...
223
		$this->parserGroup->parseGroupLevel($event, $circle, $group);
0 ignored issues
show
Bug introduced by
It seems like $group defined by \OCA\Circles\Model\Membe...mJSON($params['group']) on line 219 can be null; however, OCA\Circles\Activity\Pro...roup::parseGroupLevel() does not accept null, maybe add an additional type check?

Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code:

/** @return stdClass|null */
function mayReturnNull() { }

function doesNotAcceptNull(stdClass $x) { }

// With potential error.
function withoutCheck() {
    $x = mayReturnNull();
    doesNotAcceptNull($x); // Potential error here.
}

// Safe - Alternative 1
function withCheck1() {
    $x = mayReturnNull();
    if ( ! $x instanceof stdClass) {
        throw new \LogicException('$x must be defined.');
    }
    doesNotAcceptNull($x);
}

// Safe - Alternative 2
function withCheck2() {
    $x = mayReturnNull();
    if ($x instanceof stdClass) {
        doesNotAcceptNull($x);
    }
}
Loading history...
224
	}
225
226
227
	/**
228
	 * @param IEvent $event
229
	 * @param Circle $circle
230
	 * @param array $params
231
	 */
232 View Code Duplication
	private function parseMemberAsModerator(IEvent $event, Circle $circle, $params) {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
233
		if (!key_exists('member', $params)) {
234
			return;
235
		}
236
237
		$member = Member::fromJSON($params['member']);
238
239
		$this->parserMember->parseMemberInvited($event, $circle, $member);
0 ignored issues
show
Bug introduced by
It seems like $member defined by \OCA\Circles\Model\Membe...JSON($params['member']) on line 237 can be null; however, OCA\Circles\Activity\Pro...r::parseMemberInvited() does not accept null, maybe add an additional type check?

Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code:

/** @return stdClass|null */
function mayReturnNull() { }

function doesNotAcceptNull(stdClass $x) { }

// With potential error.
function withoutCheck() {
    $x = mayReturnNull();
    doesNotAcceptNull($x); // Potential error here.
}

// Safe - Alternative 1
function withCheck1() {
    $x = mayReturnNull();
    if ( ! $x instanceof stdClass) {
        throw new \LogicException('$x must be defined.');
    }
    doesNotAcceptNull($x);
}

// Safe - Alternative 2
function withCheck2() {
    $x = mayReturnNull();
    if ($x instanceof stdClass) {
        doesNotAcceptNull($x);
    }
}
Loading history...
240
		$this->parserMember->parseMemberLevel($event, $circle, $member);
0 ignored issues
show
Bug introduced by
It seems like $member defined by \OCA\Circles\Model\Membe...JSON($params['member']) on line 237 can be null; however, OCA\Circles\Activity\Pro...ber::parseMemberLevel() does not accept null, maybe add an additional type check?

Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code:

/** @return stdClass|null */
function mayReturnNull() { }

function doesNotAcceptNull(stdClass $x) { }

// With potential error.
function withoutCheck() {
    $x = mayReturnNull();
    doesNotAcceptNull($x); // Potential error here.
}

// Safe - Alternative 1
function withCheck1() {
    $x = mayReturnNull();
    if ( ! $x instanceof stdClass) {
        throw new \LogicException('$x must be defined.');
    }
    doesNotAcceptNull($x);
}

// Safe - Alternative 2
function withCheck2() {
    $x = mayReturnNull();
    if ($x instanceof stdClass) {
        doesNotAcceptNull($x);
    }
}
Loading history...
241
		$this->parserMember->parseMemberRequestInvitation($event, $circle, $member);
0 ignored issues
show
Bug introduced by
It seems like $member defined by \OCA\Circles\Model\Membe...JSON($params['member']) on line 237 can be null; however, OCA\Circles\Activity\Pro...mberRequestInvitation() does not accept null, maybe add an additional type check?

Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code:

/** @return stdClass|null */
function mayReturnNull() { }

function doesNotAcceptNull(stdClass $x) { }

// With potential error.
function withoutCheck() {
    $x = mayReturnNull();
    doesNotAcceptNull($x); // Potential error here.
}

// Safe - Alternative 1
function withCheck1() {
    $x = mayReturnNull();
    if ( ! $x instanceof stdClass) {
        throw new \LogicException('$x must be defined.');
    }
    doesNotAcceptNull($x);
}

// Safe - Alternative 2
function withCheck2() {
    $x = mayReturnNull();
    if ($x instanceof stdClass) {
        doesNotAcceptNull($x);
    }
}
Loading history...
242
		$this->parserMember->parseMemberOwner($event, $circle, $member);
0 ignored issues
show
Bug introduced by
It seems like $member defined by \OCA\Circles\Model\Membe...JSON($params['member']) on line 237 can be null; however, OCA\Circles\Activity\Pro...ber::parseMemberOwner() does not accept null, maybe add an additional type check?

Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code:

/** @return stdClass|null */
function mayReturnNull() { }

function doesNotAcceptNull(stdClass $x) { }

// With potential error.
function withoutCheck() {
    $x = mayReturnNull();
    doesNotAcceptNull($x); // Potential error here.
}

// Safe - Alternative 1
function withCheck1() {
    $x = mayReturnNull();
    if ( ! $x instanceof stdClass) {
        throw new \LogicException('$x must be defined.');
    }
    doesNotAcceptNull($x);
}

// Safe - Alternative 2
function withCheck2() {
    $x = mayReturnNull();
    if ($x instanceof stdClass) {
        doesNotAcceptNull($x);
    }
}
Loading history...
243
	}
244
245
246
	/**
247
	 * @param IEvent $event
248
	 * @param Circle $circle
249
	 * @param array $params
250
	 */
251
	private function parseLinkAsModerator(IEvent $event, Circle $circle, $params) {
252
253
		if (!key_exists('link', $params)) {
254
			return;
255
		}
256
257
		$remote = FederatedLink::fromJSON($params['link']);
258
259
		$this->parserLink->parseLinkRequestSent($event, $circle, $remote);
0 ignored issues
show
Bug introduced by
It seems like $remote defined by \OCA\Circles\Model\Feder...omJSON($params['link']) on line 257 can be null; however, OCA\Circles\Activity\Pro...:parseLinkRequestSent() does not accept null, maybe add an additional type check?

Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code:

/** @return stdClass|null */
function mayReturnNull() { }

function doesNotAcceptNull(stdClass $x) { }

// With potential error.
function withoutCheck() {
    $x = mayReturnNull();
    doesNotAcceptNull($x); // Potential error here.
}

// Safe - Alternative 1
function withCheck1() {
    $x = mayReturnNull();
    if ( ! $x instanceof stdClass) {
        throw new \LogicException('$x must be defined.');
    }
    doesNotAcceptNull($x);
}

// Safe - Alternative 2
function withCheck2() {
    $x = mayReturnNull();
    if ($x instanceof stdClass) {
        doesNotAcceptNull($x);
    }
}
Loading history...
260
		$this->parserLink->parseLinkRequestReceived($event, $circle, $remote);
0 ignored issues
show
Bug introduced by
It seems like $remote defined by \OCA\Circles\Model\Feder...omJSON($params['link']) on line 257 can be null; however, OCA\Circles\Activity\Pro...seLinkRequestReceived() does not accept null, maybe add an additional type check?

Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code:

/** @return stdClass|null */
function mayReturnNull() { }

function doesNotAcceptNull(stdClass $x) { }

// With potential error.
function withoutCheck() {
    $x = mayReturnNull();
    doesNotAcceptNull($x); // Potential error here.
}

// Safe - Alternative 1
function withCheck1() {
    $x = mayReturnNull();
    if ( ! $x instanceof stdClass) {
        throw new \LogicException('$x must be defined.');
    }
    doesNotAcceptNull($x);
}

// Safe - Alternative 2
function withCheck2() {
    $x = mayReturnNull();
    if ($x instanceof stdClass) {
        doesNotAcceptNull($x);
    }
}
Loading history...
261
		$this->parserLink->parseLinkRequestRejected($event, $circle, $remote);
0 ignored issues
show
Bug introduced by
It seems like $remote defined by \OCA\Circles\Model\Feder...omJSON($params['link']) on line 257 can be null; however, OCA\Circles\Activity\Pro...seLinkRequestRejected() does not accept null, maybe add an additional type check?

Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code:

/** @return stdClass|null */
function mayReturnNull() { }

function doesNotAcceptNull(stdClass $x) { }

// With potential error.
function withoutCheck() {
    $x = mayReturnNull();
    doesNotAcceptNull($x); // Potential error here.
}

// Safe - Alternative 1
function withCheck1() {
    $x = mayReturnNull();
    if ( ! $x instanceof stdClass) {
        throw new \LogicException('$x must be defined.');
    }
    doesNotAcceptNull($x);
}

// Safe - Alternative 2
function withCheck2() {
    $x = mayReturnNull();
    if ($x instanceof stdClass) {
        doesNotAcceptNull($x);
    }
}
Loading history...
262
		$this->parserLink->parseLinkRequestCanceled($event, $circle, $remote);
0 ignored issues
show
Bug introduced by
It seems like $remote defined by \OCA\Circles\Model\Feder...omJSON($params['link']) on line 257 can be null; however, OCA\Circles\Activity\Pro...seLinkRequestCanceled() does not accept null, maybe add an additional type check?

Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code:

/** @return stdClass|null */
function mayReturnNull() { }

function doesNotAcceptNull(stdClass $x) { }

// With potential error.
function withoutCheck() {
    $x = mayReturnNull();
    doesNotAcceptNull($x); // Potential error here.
}

// Safe - Alternative 1
function withCheck1() {
    $x = mayReturnNull();
    if ( ! $x instanceof stdClass) {
        throw new \LogicException('$x must be defined.');
    }
    doesNotAcceptNull($x);
}

// Safe - Alternative 2
function withCheck2() {
    $x = mayReturnNull();
    if ($x instanceof stdClass) {
        doesNotAcceptNull($x);
    }
}
Loading history...
263
		$this->parserLink->parseLinkRequestAccepted($event, $circle, $remote);
0 ignored issues
show
Bug introduced by
It seems like $remote defined by \OCA\Circles\Model\Feder...omJSON($params['link']) on line 257 can be null; however, OCA\Circles\Activity\Pro...seLinkRequestAccepted() does not accept null, maybe add an additional type check?

Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code:

/** @return stdClass|null */
function mayReturnNull() { }

function doesNotAcceptNull(stdClass $x) { }

// With potential error.
function withoutCheck() {
    $x = mayReturnNull();
    doesNotAcceptNull($x); // Potential error here.
}

// Safe - Alternative 1
function withCheck1() {
    $x = mayReturnNull();
    if ( ! $x instanceof stdClass) {
        throw new \LogicException('$x must be defined.');
    }
    doesNotAcceptNull($x);
}

// Safe - Alternative 2
function withCheck2() {
    $x = mayReturnNull();
    if ($x instanceof stdClass) {
        doesNotAcceptNull($x);
    }
}
Loading history...
264
		$this->parserLink->parseLinkRequestRemoved($event, $circle, $remote);
0 ignored issues
show
Bug introduced by
It seems like $remote defined by \OCA\Circles\Model\Feder...omJSON($params['link']) on line 257 can be null; however, OCA\Circles\Activity\Pro...rseLinkRequestRemoved() does not accept null, maybe add an additional type check?

Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code:

/** @return stdClass|null */
function mayReturnNull() { }

function doesNotAcceptNull(stdClass $x) { }

// With potential error.
function withoutCheck() {
    $x = mayReturnNull();
    doesNotAcceptNull($x); // Potential error here.
}

// Safe - Alternative 1
function withCheck1() {
    $x = mayReturnNull();
    if ( ! $x instanceof stdClass) {
        throw new \LogicException('$x must be defined.');
    }
    doesNotAcceptNull($x);
}

// Safe - Alternative 2
function withCheck2() {
    $x = mayReturnNull();
    if ($x instanceof stdClass) {
        doesNotAcceptNull($x);
    }
}
Loading history...
265
		$this->parserLink->parseLinkRequestCanceling($event, $circle, $remote);
0 ignored issues
show
Bug introduced by
It seems like $remote defined by \OCA\Circles\Model\Feder...omJSON($params['link']) on line 257 can be null; however, OCA\Circles\Activity\Pro...eLinkRequestCanceling() does not accept null, maybe add an additional type check?

Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code:

/** @return stdClass|null */
function mayReturnNull() { }

function doesNotAcceptNull(stdClass $x) { }

// With potential error.
function withoutCheck() {
    $x = mayReturnNull();
    doesNotAcceptNull($x); // Potential error here.
}

// Safe - Alternative 1
function withCheck1() {
    $x = mayReturnNull();
    if ( ! $x instanceof stdClass) {
        throw new \LogicException('$x must be defined.');
    }
    doesNotAcceptNull($x);
}

// Safe - Alternative 2
function withCheck2() {
    $x = mayReturnNull();
    if ($x instanceof stdClass) {
        doesNotAcceptNull($x);
    }
}
Loading history...
266
		$this->parserLink->parseLinkRequestAccepting($event, $circle, $remote);
0 ignored issues
show
Bug introduced by
It seems like $remote defined by \OCA\Circles\Model\Feder...omJSON($params['link']) on line 257 can be null; however, OCA\Circles\Activity\Pro...eLinkRequestAccepting() does not accept null, maybe add an additional type check?

Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code:

/** @return stdClass|null */
function mayReturnNull() { }

function doesNotAcceptNull(stdClass $x) { }

// With potential error.
function withoutCheck() {
    $x = mayReturnNull();
    doesNotAcceptNull($x); // Potential error here.
}

// Safe - Alternative 1
function withCheck1() {
    $x = mayReturnNull();
    if ( ! $x instanceof stdClass) {
        throw new \LogicException('$x must be defined.');
    }
    doesNotAcceptNull($x);
}

// Safe - Alternative 2
function withCheck2() {
    $x = mayReturnNull();
    if ($x instanceof stdClass) {
        doesNotAcceptNull($x);
    }
}
Loading history...
267
		$this->parserLink->parseLinkUp($event, $circle, $remote);
0 ignored issues
show
Bug introduced by
It seems like $remote defined by \OCA\Circles\Model\Feder...omJSON($params['link']) on line 257 can be null; however, OCA\Circles\Activity\Pro...jectLink::parseLinkUp() does not accept null, maybe add an additional type check?

Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code:

/** @return stdClass|null */
function mayReturnNull() { }

function doesNotAcceptNull(stdClass $x) { }

// With potential error.
function withoutCheck() {
    $x = mayReturnNull();
    doesNotAcceptNull($x); // Potential error here.
}

// Safe - Alternative 1
function withCheck1() {
    $x = mayReturnNull();
    if ( ! $x instanceof stdClass) {
        throw new \LogicException('$x must be defined.');
    }
    doesNotAcceptNull($x);
}

// Safe - Alternative 2
function withCheck2() {
    $x = mayReturnNull();
    if ($x instanceof stdClass) {
        doesNotAcceptNull($x);
    }
}
Loading history...
268
		$this->parserLink->parseLinkDown($event, $circle, $remote);
0 ignored issues
show
Bug introduced by
It seems like $remote defined by \OCA\Circles\Model\Feder...omJSON($params['link']) on line 257 can be null; however, OCA\Circles\Activity\Pro...ctLink::parseLinkDown() does not accept null, maybe add an additional type check?

Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code:

/** @return stdClass|null */
function mayReturnNull() { }

function doesNotAcceptNull(stdClass $x) { }

// With potential error.
function withoutCheck() {
    $x = mayReturnNull();
    doesNotAcceptNull($x); // Potential error here.
}

// Safe - Alternative 1
function withCheck1() {
    $x = mayReturnNull();
    if ( ! $x instanceof stdClass) {
        throw new \LogicException('$x must be defined.');
    }
    doesNotAcceptNull($x);
}

// Safe - Alternative 2
function withCheck2() {
    $x = mayReturnNull();
    if ($x instanceof stdClass) {
        doesNotAcceptNull($x);
    }
}
Loading history...
269
		$this->parserLink->parseLinkRemove($event, $circle, $remote);
0 ignored issues
show
Bug introduced by
It seems like $remote defined by \OCA\Circles\Model\Feder...omJSON($params['link']) on line 257 can be null; however, OCA\Circles\Activity\Pro...Link::parseLinkRemove() does not accept null, maybe add an additional type check?

Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code:

/** @return stdClass|null */
function mayReturnNull() { }

function doesNotAcceptNull(stdClass $x) { }

// With potential error.
function withoutCheck() {
    $x = mayReturnNull();
    doesNotAcceptNull($x); // Potential error here.
}

// Safe - Alternative 1
function withCheck1() {
    $x = mayReturnNull();
    if ( ! $x instanceof stdClass) {
        throw new \LogicException('$x must be defined.');
    }
    doesNotAcceptNull($x);
}

// Safe - Alternative 2
function withCheck2() {
    $x = mayReturnNull();
    if ($x instanceof stdClass) {
        doesNotAcceptNull($x);
    }
}
Loading history...
270
	}
271
272
273
}
274