r70677 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r70676‎ | r70677 | r70678 >
Date:08:14, 8 August 2010
Author:nikerabbit
Status:ok
Tags:
Comment:
Iterate over keys instead of messages directly
Modified paths:
  • /trunk/extensions/Translate/MessageCollection.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Translate/MessageCollection.php
@@ -451,7 +451,7 @@
452452 //
453453 /* ArrayAccess methods */
454454 public function offsetExists( $offset ) {
455 - return isset( $this->messages[$offset] );
 455+ return isset( $this->keys[$offset] );
456456 }
457457
458458 public function offsetGet( $offset ) {
@@ -463,7 +463,7 @@
464464 }
465465
466466 public function offsetUnset( $offset ) {
467 - unset( $this->messages[$offset] );
 467+ unset( $this->keys[$offset] );
468468 }
469469
470470 /* Fail fast */
@@ -478,27 +478,27 @@
479479
480480 /* Iterator methods */
481481 public function rewind() {
482 - reset( $this->messages );
 482+ reset( $this->keys );
483483 }
484484
485485 public function current() {
486 - if ( !count( $this->messages ) ) {
 486+ if ( !count( $this->keys ) ) {
487487 return false;
488488 }
489489
490 - return current( $this->messages );
 490+ return $this->messages[key( $this->keys )];
491491 }
492492
493493 public function key() {
494 - return key( $this->messages );
 494+ return key( $this->keys );
495495 }
496496
497497 public function next() {
498 - return next( $this->messages );
 498+ return next( $this->keys );
499499 }
500500
501501 public function valid() {
502 - return $this->current() !== false;
 502+ return isset( $this->messages[key( $this->keys )] );
503503 }
504504
505505 public function count() {

Status & tagging log