* @file
* @ingroup Site
*
- * @license GNU GPL v2+
+ * @license GPL-2.0-or-later
* @author Jeroen De Dauw < jeroendedauw@gmail.com >
*/
class SiteList extends GenericArrayObject {
-
/**
* Internal site identifiers pointing to their sites offset value.
*
* @since 1.21
*
- * @var array of integer
+ * @var array Array of integer
*/
- protected $byInternalId = array();
+ protected $byInternalId = [];
/**
* Global site identifiers pointing to their sites offset value.
*
* @since 1.21
*
- * @var array of string
+ * @var array Array of string
*/
- protected $byGlobalId = array();
+ protected $byGlobalId = [];
/**
* Navigational site identifiers alias inter-language prefixes
*
* @since 1.23
*
- * @var array of string
+ * @var array Array of string
*/
- protected $byNavigationId = array();
+ protected $byNavigationId = [];
/**
* @see GenericArrayObject::getObjectType
* @return string
*/
public function getObjectType() {
- return 'Site';
+ return Site::class;
}
/**
* @param int|string $index
* @param Site $site
*
- * @return boolean
+ * @return bool
*/
protected function preSetElement( $index, $site ) {
if ( $this->hasSite( $site->getGlobalId() ) ) {
*
* @param string $globalSiteId
*
- * @return boolean
+ * @return bool
*/
public function hasSite( $globalSiteId ) {
return array_key_exists( $globalSiteId, $this->byGlobalId );
*
* @since 1.21
*
- * @return boolean
+ * @return bool
*/
public function isEmpty() {
- return $this->byGlobalId === array();
+ return $this->byGlobalId === [];
}
/**
* Returns if the list contains the site with the provided site id.
*
- * @param integer $id
+ * @param int $id
*
- * @return boolean
+ * @return bool
*/
public function hasInternalId( $id ) {
return array_key_exists( $id, $this->byInternalId );
*
* @since 1.21
*
- * @param integer $id
+ * @param int $id
*
* @return Site
*/
*
* @since 1.21
*
- * @param integer $id
+ * @param int $id
*/
public function removeSiteByInternalId( $id ) {
$this->offsetUnset( $this->byInternalId[$id] );
*
* @param string $id
*
- * @return boolean
+ * @return bool
*/
public function hasNavigationId( $id ) {
return array_key_exists( $id, $this->byNavigationId );
$group = new self();
/**
- * @var \Site $site
+ * @var Site $site
*/
foreach ( $this as $site ) {
if ( $site->getGroup() === $groupName ) {
* @var string A string uniquely identifying the version of the serialization structure,
* not including any sub-structures.
*/
- const SERIAL_VERSION_ID = '2013-02-07';
+ const SERIAL_VERSION_ID = '2014-03-17';
/**
* Returns the version ID that identifies the serialization structure used by
* @return array
*/
protected function getSerializationData() {
- //NOTE: When changing the structure, either implement unserialize() to handle the
+ // NOTE: When changing the structure, either implement unserialize() to handle the
// old structure too, or update SERIAL_VERSION_ID to kill any caches.
return array_merge(
parent::getSerializationData(),
- array(
+ [
'internalIds' => $this->byInternalId,
'globalIds' => $this->byGlobalId,
- )
+ 'navigationIds' => $this->byNavigationId
+ ]
);
}
$this->byInternalId = $serializationData['internalIds'];
$this->byGlobalId = $serializationData['globalIds'];
+ $this->byNavigationId = $serializationData['navigationIds'];
return $serializationData;
}
-
}
-
-/**
- * @deprecated
- */
-class SiteArray extends SiteList {}