1 | <?php |
||
12 | class Revisions { |
||
13 | |||
14 | /** |
||
15 | * @var Revision[] |
||
16 | */ |
||
17 | private $revisions; |
||
18 | |||
19 | /** |
||
20 | * @param Revisions[] $revisions |
||
21 | */ |
||
22 | 4 | public function __construct( $revisions = array() ) { |
|
26 | |||
27 | /** |
||
28 | * @param Revision[]|Revisions $revisions |
||
29 | * |
||
30 | * @throws InvalidArgumentException |
||
31 | */ |
||
32 | 4 | public function addRevisions( $revisions ) { |
|
33 | 4 | if( !is_array( $revisions ) && !$revisions instanceof Revisions ) { |
|
34 | throw new InvalidArgumentException( '$revisions needs to either be an array or a Revisions object' ); |
||
35 | } |
||
36 | 4 | if( $revisions instanceof Revisions ) { |
|
37 | 1 | $revisions = $revisions->toArray(); |
|
38 | 1 | } |
|
39 | 4 | foreach( $revisions as $revision ) { |
|
40 | 4 | $this->addRevision( $revision ); |
|
41 | 4 | } |
|
42 | 4 | } |
|
43 | |||
44 | /** |
||
45 | * @param Revision $revision |
||
46 | */ |
||
47 | 4 | public function addRevision( Revision $revision ) { |
|
50 | |||
51 | /** |
||
52 | * @param int $id |
||
53 | * |
||
54 | * @return bool |
||
55 | */ |
||
56 | public function hasRevisionWithId( $id ){ |
||
59 | |||
60 | /** |
||
61 | * @param Revision $revision |
||
62 | * |
||
63 | * @return bool |
||
64 | */ |
||
65 | public function hasRevision( Revision $revision ){ |
||
68 | |||
69 | /** |
||
70 | * @return Revision|null Revision or null if there is no revision |
||
71 | */ |
||
72 | public function getLatest() { |
||
78 | |||
79 | /** |
||
80 | * @param int $revid |
||
81 | * |
||
82 | * @throws RuntimeException |
||
83 | * @throws InvalidArgumentException |
||
84 | * @return Revision |
||
85 | */ |
||
86 | public function get( $revid ){ |
||
95 | |||
96 | /** |
||
97 | * @return Revision[] |
||
98 | */ |
||
99 | 4 | public function toArray() { |
|
102 | } |
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: