|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Wikibase\Repo\ChangeOp; |
|
4
|
|
|
|
|
5
|
|
|
use Wikibase\DataModel\Entity\EntityDocument; |
|
6
|
|
|
use Wikibase\Lib\Summary; |
|
7
|
|
|
use Wikibase\Repo\Validators\TermValidatorFactory; |
|
8
|
|
|
|
|
9
|
|
|
/** |
|
10
|
|
|
* Decorator on ChangeOps for collecting and distinguishing a collection |
|
11
|
|
|
* of ChangeOp instances on entity fingerprint parts. |
|
12
|
|
|
* |
|
13
|
|
|
* @license GPL-2.0-or-later |
|
14
|
|
|
*/ |
|
15
|
|
|
class ChangeOpFingerprint extends ChangeOps { |
|
16
|
|
|
|
|
17
|
|
|
/** @var ChangeOps */ |
|
18
|
|
|
private $innerChangeOps; |
|
19
|
|
|
|
|
20
|
|
|
/** @var TermValidatorFactory */ |
|
21
|
|
|
private $termValidatorFactory; |
|
22
|
|
|
|
|
23
|
|
|
public function __construct( ChangeOps $innerChangeOps, TermValidatorFactory $termValidatorFactory ) { |
|
24
|
|
|
$this->innerChangeOps = $innerChangeOps; |
|
25
|
|
|
$this->termValidatorFactory = $termValidatorFactory; |
|
26
|
|
|
} |
|
27
|
|
|
|
|
28
|
|
|
public function add( $changeOps ) { |
|
29
|
|
|
$this->innerChangeOps->add( $changeOps ); |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
public function getChangeOps() { |
|
33
|
|
|
return $this->innerChangeOps->getChangeOps(); |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
public function validate( EntityDocument $entity ) { |
|
37
|
|
|
return $this->innerChangeOps->validate( $entity ); |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
public function getActions() { |
|
41
|
|
|
return $this->innerChangeOps->getActions(); |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
public function apply( EntityDocument $entity, Summary $summary = null ) { |
|
45
|
|
|
$result = $this->innerChangeOps->apply( $entity, $summary ); |
|
46
|
|
|
|
|
47
|
|
|
'@phan-var ChangeOpsResult $result'; |
|
48
|
|
|
return new ChangeOpFingerprintResult( $result, $this->termValidatorFactory ); |
|
|
|
|
|
|
49
|
|
|
} |
|
50
|
|
|
} |
|
51
|
|
|
|
This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.
Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.