27use Wikimedia\Assert\Assert;
53 Assert::parameterType(
'array|callable',
$slots,
'$slots' );
55 if ( is_callable(
$slots ) ) {
66 Assert::parameterElementType( SlotRecord::class,
$slots,
'$slots' );
71 foreach (
$slots as $slot ) {
72 $role = $slot->getRole();
73 $this->slots[$role] = $slot;
83 throw new LogicException( __CLASS__ .
' is not serializable.' );
103 return $this->
getSlot( $role )->getContent()->copy();
119 if ( isset(
$slots[$role] ) ) {
136 return isset(
$slots[$role] );
147 return array_keys(
$slots );
160 return $accu + $slot->
getSize();
174 if ( is_callable( $this->slots ) ) {
175 $slots = call_user_func( $this->slots );
177 Assert::postcondition(
179 'Slots info callback should return an array of objects'
209 return $accu ===
null
259 if ( $other === $this ) {
269 if ( array_keys( $aSlots ) !== array_keys( $bSlots ) ) {
273 foreach ( $aSlots as $role =>
$s ) {
276 if ( !
$s->hasSameContent(
$t ) ) {
294 if ( $other === $this ) {
304 $different = array_keys( array_merge(
305 array_diff_key( $aSlots, $bSlots ),
306 array_diff_key( $bSlots, $aSlots )
310 $common = array_intersect_key( $aSlots, $bSlots );
312 foreach ( $common as $role =>
$s ) {
315 if ( !
$s->hasSameContent(
$t ) ) {
316 $different[] = $role;
329class_alias( RevisionSlots::class,
'MediaWiki\Storage\RevisionSlots' );
Base interface for content objects.