Wikibase
MediaWiki Wikibase extension
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 (... $statements)
 
 getPropertyIds ()
 Returns the property ids used by the statements. More...
 
 addStatement (Statement $statement, $index=null)
 
 addNewStatement (Snak $mainSnak, $qualifiers=null, $references=null, $guid=null)
 
 removeStatementsWithGuid ( $guid)
 
 getWithUniqueMainSnaks ()
 Statements that have a main snak already in the list are filtered out. More...
 
 getByPropertyId (PropertyId $id)
 
 getByRank ( $acceptableRanks)
 
 getBestStatements ()
 Returns the so called "best statements". More...
 
 getAllSnaks ()
 Returns a list of all Snaks on this StatementList. More...
 
 getMainSnaks ()
 
 getIterator ()
 
 toArray ()
 
 count ()
 
 equals ( $target)
 
 isEmpty ()
 
 getFirstStatementWithGuid ( $statementGuid)
 
 filter (StatementFilter $filter)
 
 clear ()
 Removes all statements from this list. More...
 
 __clone ()
 

Private Member Functions

 statementsEqual (array $statements)
 

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 (   $statements)
Parameters
Statement...$statements (passing a single Statement[] or Traversable is still supported but deprecated)
Exceptions
InvalidArgumentException

Member Function Documentation

◆ __clone()

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

◆ addNewStatement()

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

◆ addStatement()

Wikibase\DataModel\Statement\StatementList::addStatement ( Statement  $statement,
  $index = null 
)
Since
1.0, setting an index is supported since 6.1
See also
ReferenceList::addReference
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 (   $statementGuid)
Since
3.0
See also
StatementByGuidMap
Parameters
string | null$statementGuid
Returns
Statement|null 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 (   $guid)
Since
3.0
Parameters
string | null$guid

◆ 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: