r103623 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r103622‎ | r103623 | r103624 >
Date:23:00, 18 November 2011
Author:danwe
Status:deferred
Tags:
Comment:
public accessors improved
Modified paths:
  • /trunk/extensions/HashTables/HashTables.php (modified) (history)

Diff [purge]

Index: trunk/extensions/HashTables/HashTables.php
@@ -701,11 +701,11 @@
702702 * @return array|null
703703 */
704704 public function getHash( $hashId ) {
 705+ $hashId = trim( $hashId );
705706 if( $this->hashExists( $hashId ) ) {
706707 return $this->mHashTables[ $hashId ];
707 - } else {
708 - return null;
709708 }
 709+ return null;
710710 }
711711
712712 /**
@@ -718,26 +718,28 @@
719719 * @param string $hashId
720720 * @param array $hashTable
721721 */
722 - public function setHash( $hashId, $hashTable = array() ) {
 722+ public function setHash( $hashId, array $hashTable = array() ) {
723723 $hashTable = array_map( 'trim', $hashTable ); // make it all string and trim
724724 $this->mHashTables[ trim( $hashId ) ] = $hashTable;
725725 }
726726
727727 /**
728 - * Returns a value within a hash. If key or hash doesn't exist, this will return null
 728+ * Returns a value within a hash. If key or hash do not exist, this will return null
729729 * or another predefined default.
730730 *
731731 * @since 0.7
732732 *
733733 * @param string $hashId
734734 * @param string $key
735 - * @param mixed $default value to return in cas the value doesn't exist. null by default.
 735+ * @param mixed $default value to return in case the value doesn't exist. null by default.
736736 *
737737 * @return string
738738 */
739739 public function getHashValue( $hashId, $key, $default = null ) {
740740 $hashId = trim( $hashId );
741 - if( $this->hashExists( $hashId ) && array_key_exists( $key, $this->mHashTables[ $hashId ] ) ) {
 741+ if( $this->hashExists( $hashId )
 742+ && array_key_exists( $key, $this->mHashTables[ $hashId ] )
 743+ ) {
742744 return $this->mHashTables[ $hashId ][ $key ];
743745 } else {
744746 return $default;
@@ -753,7 +755,7 @@
754756 * @param type $key
755757 */
756758 public function unsetHashValue( $hashId, $key ) {
757 - unset( $this->mHashTables[ $hashId ][ $key ] );
 759+ unset( $this->mHashTables[ trim( $hashId ) ][ trim( $key ) ] );
758760 }
759761
760762 /**

Status & tagging log