ChangeOpFingerprintResult::getChangeOpsResults()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Wikibase\Repo\ChangeOp;
4
5
use ValueValidators\Result;
6
use Wikibase\Repo\Validators\TermValidatorFactory;
7
8
/**
9
 * Decorator on ChangeOpsResult for collecting and distinguishing a collection
10
 * of ChangeOpResult instances on entity fingerprint parts.
11
 *
12
 * @license GPL-2.0-or-later
13
 */
14
class ChangeOpFingerprintResult extends ChangeOpsResult {
15
16
	/** @var ChangeOpsResult */
17
	private $innerChangeOpsResult;
18
19
	/** @var TermValidatorFactory */
20
	private $termValidatorFactory;
21
22
	public function __construct( ChangeOpsResult $changeOpsResult, TermValidatorFactory $termValidatorFactory ) {
23
		$this->innerChangeOpsResult = $changeOpsResult;
24
		$this->termValidatorFactory = $termValidatorFactory;
25
	}
26
27
	public function getChangeOpsResults() {
28
		return $this->innerChangeOpsResult->getChangeOpsResults();
29
	}
30
31
	public function getEntityId() {
32
		return $this->innerChangeOpsResult->getEntityId();
33
	}
34
35
	public function isEntityChanged() {
36
		return $this->innerChangeOpsResult->isEntityChanged();
37
	}
38
39
	public function validate(): Result {
40
		$result = $this->innerChangeOpsResult->validate();
41
42
		$fingerprintUniquenessValidator = $this->termValidatorFactory->getFingerprintUniquenessValidator(
43
			$this->getEntityId()->getEntityType()
44
		);
45
46
		if ( $fingerprintUniquenessValidator !== null ) {
47
			$result = Result::merge(
48
				$result,
0 ignored issues
show
Documentation introduced by
$result is of type object<ValueValidators\Result>, but the function expects a object<self>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
49
				$fingerprintUniquenessValidator->validate( $this )
0 ignored issues
show
Documentation introduced by
$fingerprintUniquenessValidator->validate($this) is of type object<ValueValidators\Result>, but the function expects a object<self>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
50
			);
51
		}
52
53
		return $result;
54
	}
55
56
}
57