Wikibase
MediaWiki Wikibase extension
Loading...
Searching...
No Matches
Wikibase\DataModel\Statement\StatementList Class Reference

Ordered and non-unique collection of Statement objects. More...

+ Inheritance diagram for Wikibase\DataModel\Statement\StatementList:
+ Collaboration diagram for Wikibase\DataModel\Statement\StatementList:

Public Member Functions

 __construct (Statement ... $statements)
 
 getPropertyIds ()
 Returns the property ids used by the statements.
 
 addStatement (Statement $statement, int $index=null)
 
 addNewStatement (Snak $mainSnak, $qualifiers=null, $references=null, string $guid=null)
 
 removeStatementsWithGuid (?string $guid)
 
 replaceStatement (StatementGuid $statementGuid, Statement $newStatement)
 
 getWithUniqueMainSnaks ()
 Statements that have a main snak already in the list are filtered out.
 
 getByPropertyId (PropertyId $id)
 
 getByRank ( $acceptableRanks)
 
 getBestStatements ()
 Returns the so called "best statements".
 
 getAllSnaks ()
 Returns a list of all Snaks on this StatementList.
 
 getMainSnaks ()
 
 getIterator ()
 
 toArray ()
 
 count ()
 
 equals ( $target)
 
 isEmpty ()
 
 getFirstStatementWithGuid (?string $statementGuid)
 
 filter (StatementFilter $filter)
 
 clear ()
 Removes all statements from this list.
 
 __clone ()
 

Private Member Functions

 statementsEqual (array $statements)
 
 getIndexOfFirstStatementWithGuid (?string $statementGuid)
 

Private Attributes

 $statements
 

Detailed Description

Ordered and non-unique collection of Statement objects.

Provides various filter operations.

Does not do any indexing by default. Does not provide complex modification functionality.

Since
1.0
Author
Jeroen De Dauw < jeroe.nosp@m.nded.nosp@m.auw@g.nosp@m.mail.nosp@m..com >
Bene* < benes.nosp@m.tar..nosp@m.wikim.nosp@m.edia.nosp@m.@gmai.nosp@m.l.co.nosp@m.m >
Thiemo Kreuz

Constructor & Destructor Documentation

◆ __construct()

Wikibase\DataModel\Statement\StatementList::__construct ( Statement ... $statements)
Parameters
Statement...$statements

Member Function Documentation

◆ __clone()

Wikibase\DataModel\Statement\StatementList::__clone ( )

◆ addNewStatement()

Wikibase\DataModel\Statement\StatementList::addNewStatement ( Snak $mainSnak,
$qualifiers = null,
$references = null,
string $guid = null )
Parameters
Snak$mainSnak
Snak[] | SnakList | null$qualifiers
Reference[] | ReferenceList | null$references
string | null$guid

◆ addStatement()

Wikibase\DataModel\Statement\StatementList::addStatement ( Statement $statement,
int $index = null )
See also
ReferenceList::addReference
Since
1.0, setting an index is supported since 6.1
Parameters
Statement$statement
int | null$indexNew position of the added statement, or null to append.
Exceptions
InvalidArgumentException

◆ clear()

Wikibase\DataModel\Statement\StatementList::clear ( )

Removes all statements from this list.

Since
7.0

◆ count()

Wikibase\DataModel\Statement\StatementList::count ( )
See also
Countable::count
Returns
int

◆ equals()

Wikibase\DataModel\Statement\StatementList::equals ( $target)
Parameters
mixed$target
Returns
bool

◆ filter()

Wikibase\DataModel\Statement\StatementList::filter ( StatementFilter $filter)
Since
4.1
Parameters
StatementFilter$filter
Returns
self

◆ getAllSnaks()

Wikibase\DataModel\Statement\StatementList::getAllSnaks ( )

Returns a list of all Snaks on this StatementList.

This includes at least the main snaks of all statements, the snaks from qualifiers, and the snaks from references.

This is a convenience method for use in code that needs to operate on all snaks, e.g. to find all referenced Entities.

Since
1.1
Returns
Snak[] Numerically indexed (non-sparse) array.

◆ getBestStatements()

Wikibase\DataModel\Statement\StatementList::getBestStatements ( )

Returns the so called "best statements".

If there are preferred statements, then this is all the preferred statements. If there are no preferred statements, then this is all normal statements.

Since
2.4
Returns
self

◆ getByPropertyId()

Wikibase\DataModel\Statement\StatementList::getByPropertyId ( PropertyId $id)
Since
3.0
Parameters
PropertyId$id
Returns
self

◆ getByRank()

Wikibase\DataModel\Statement\StatementList::getByRank ( $acceptableRanks)
Since
3.0
Parameters
int | int[]$acceptableRanks
Returns
self

◆ getFirstStatementWithGuid()

Wikibase\DataModel\Statement\StatementList::getFirstStatementWithGuid ( ?string $statementGuid)
See also
StatementByGuidMap
Since
3.0
Parameters
string | null$statementGuid
Returns
Statement|null The first statement with the given GUID or null if not found.

◆ getIndexOfFirstStatementWithGuid()

Wikibase\DataModel\Statement\StatementList::getIndexOfFirstStatementWithGuid ( ?string $statementGuid)
private
Parameters
string | null$statementGuid
Returns
int|null The index of the first statement with the given GUID or null if not found.

◆ getIterator()

Wikibase\DataModel\Statement\StatementList::getIterator ( )
Returns
Iterator|Statement[]

◆ getMainSnaks()

Wikibase\DataModel\Statement\StatementList::getMainSnaks ( )
Since
2.3
Returns
Snak[] Numerically indexed (non-sparse) array.

◆ getPropertyIds()

Wikibase\DataModel\Statement\StatementList::getPropertyIds ( )

Returns the property ids used by the statements.

The keys of the returned array hold the serializations of the property ids.

Returns
PropertyId[] Array indexed by property id serialization.

◆ getWithUniqueMainSnaks()

Wikibase\DataModel\Statement\StatementList::getWithUniqueMainSnaks ( )

Statements that have a main snak already in the list are filtered out.

The last occurrences are retained.

Since
1.0
Returns
self

◆ isEmpty()

Wikibase\DataModel\Statement\StatementList::isEmpty ( )
Returns
bool

◆ removeStatementsWithGuid()

Wikibase\DataModel\Statement\StatementList::removeStatementsWithGuid ( ?string $guid)
Since
3.0
Parameters
string | null$guid

◆ replaceStatement()

Wikibase\DataModel\Statement\StatementList::replaceStatement ( StatementGuid $statementGuid,
Statement $newStatement )
Parameters
StatementGuid$statementGuidThe GUID of the Statement to be replaced
Statement$newStatementThe new Statement
Exceptions
StatementNotFoundExceptionif the Statement with $statementGuid can't be found
StatementGuidChangedExceptionif the $newStatement has a different StatementGuid
PropertyChangedExceptionif the $newStatement has a different MainSnak Property

◆ statementsEqual()

Wikibase\DataModel\Statement\StatementList::statementsEqual ( array $statements)
private

◆ toArray()

Wikibase\DataModel\Statement\StatementList::toArray ( )
Returns
Statement[] Numerically indexed (non-sparse) array.

Member Data Documentation

◆ $statements

Wikibase\DataModel\Statement\StatementList::$statements
private

The documentation for this class was generated from the following file: