diff options
author | ctrlaltca <ctrlaltca@gmail.com> | 2016-04-04 18:31:02 +0200 |
---|---|---|
committer | ctrlaltca <ctrlaltca@gmail.com> | 2016-04-04 18:31:02 +0200 |
commit | 7e255537404cb6ceb5465589c87897781358bc59 (patch) | |
tree | c6655e104b4be4ced6acaf914c2eee87452d3c4c /framework/Collections | |
parent | 0ec0d073c120a2db371dfd4cd6f2a81fd9068676 (diff) | |
parent | ba0b0923f7520d6cd35373679aed963d1318074a (diff) |
Merge pull request #578 from pradosoft/scrutinizer
Misc code fixes suggested by Scrutinizer
Diffstat (limited to 'framework/Collections')
-rw-r--r-- | framework/Collections/TAttributeCollection.php | 4 | ||||
-rw-r--r-- | framework/Collections/TList.php | 73 | ||||
-rw-r--r-- | framework/Collections/TMap.php | 76 | ||||
-rw-r--r-- | framework/Collections/TPagedList.php | 2 |
4 files changed, 7 insertions, 148 deletions
diff --git a/framework/Collections/TAttributeCollection.php b/framework/Collections/TAttributeCollection.php index 00d82a41..eb3cb29e 100644 --- a/framework/Collections/TAttributeCollection.php +++ b/framework/Collections/TAttributeCollection.php @@ -50,9 +50,9 @@ class TAttributeCollection extends TMap * Reimplement in derived classes to add new variables, but remember to also to call the parent * implementation first. */ - protected function __getZappableSleepProps(&$exprops) + protected function _getZappableSleepProps(&$exprops) { - parent::__getZappableSleepProps($exprops); + parent::_getZappableSleepProps($exprops); if ($this->_caseSensitive===false) $exprops[] = "\0TAttributeCollection\0_caseSensitive"; } diff --git a/framework/Collections/TList.php b/framework/Collections/TList.php index 14fc1c03..6e9e16f9 100644 --- a/framework/Collections/TList.php +++ b/framework/Collections/TList.php @@ -406,78 +406,7 @@ class TList extends TComponent implements IteratorAggregate,ArrayAccess,Countabl * @package System.Collections * @since 3.0 */ -class TListIterator implements Iterator +class TListIterator extends ArrayIterator { - /** - * @var array the data to be iterated through - */ - private $_d; - /** - * @var integer index of the current item - */ - private $_i; - /** - * @var integer count of the data items - */ - private $_c; - - /** - * Constructor. - * @param array the data to be iterated through - */ - public function __construct(&$data) - { - $this->_d=&$data; - $this->_i=0; - $this->_c=count($this->_d); - } - - /** - * Rewinds internal array pointer. - * This method is required by the interface Iterator. - */ - public function rewind() - { - $this->_i=0; - } - - /** - * Returns the key of the current array item. - * This method is required by the interface Iterator. - * @return integer the key of the current array item - */ - public function key() - { - return $this->_i; - } - - /** - * Returns the current array item. - * This method is required by the interface Iterator. - * @return mixed the current array item - */ - public function current() - { - return $this->_d[$this->_i]; - } - - /** - * Moves the internal pointer to the next array item. - * This method is required by the interface Iterator. - */ - public function next() - { - $this->_i++; - } - - /** - * Returns whether there is an item at current position. - * This method is required by the interface Iterator. - * @return boolean - */ - public function valid() - { - return $this->_i<$this->_c; - } } diff --git a/framework/Collections/TMap.php b/framework/Collections/TMap.php index 2a18b87d..017f70b8 100644 --- a/framework/Collections/TMap.php +++ b/framework/Collections/TMap.php @@ -47,9 +47,9 @@ class TMap extends TComponent implements IteratorAggregate,ArrayAccess,Countable * Reimplement in derived classes to add new variables, but remember to also to call the parent * implementation first. */ - protected function __getZappableSleepProps(&$exprops) + protected function _getZappableSleepProps(&$exprops) { - parent::__getZappableSleepProps($exprops); + parent::_getZappableSleepProps($exprops); if ($this->_d===array()) $exprops[] = "\0TMap\0_d"; if ($this->_r===false) @@ -290,76 +290,6 @@ class TMap extends TComponent implements IteratorAggregate,ArrayAccess,Countable * @package System.Collections * @since 3.0 */ -class TMapIterator implements Iterator +class TMapIterator extends ArrayIterator { - /** - * @var array the data to be iterated through - */ - private $_d; - /** - * @var array list of keys in the map - */ - private $_keys; - /** - * @var mixed current key - */ - private $_key; - - /** - * Constructor. - * @param array the data to be iterated through - */ - public function __construct(&$data) - { - $this->_d=&$data; - $this->_keys=array_keys($data); - } - - /** - * Rewinds internal array pointer. - * This method is required by the interface Iterator. - */ - public function rewind() - { - $this->_key=reset($this->_keys); - } - - /** - * Returns the key of the current array element. - * This method is required by the interface Iterator. - * @return mixed the key of the current array element - */ - public function key() - { - return $this->_key; - } - - /** - * Returns the current array element. - * This method is required by the interface Iterator. - * @return mixed the current array element - */ - public function current() - { - return $this->_d[$this->_key]; - } - - /** - * Moves the internal pointer to the next array element. - * This method is required by the interface Iterator. - */ - public function next() - { - $this->_key=next($this->_keys); - } - - /** - * Returns whether there is an element at current position. - * This method is required by the interface Iterator. - * @return boolean - */ - public function valid() - { - return $this->_key!==false; - } } diff --git a/framework/Collections/TPagedList.php b/framework/Collections/TPagedList.php index b7558002..a933b4e3 100644 --- a/framework/Collections/TPagedList.php +++ b/framework/Collections/TPagedList.php @@ -295,7 +295,7 @@ class TPagedList extends TList else { $data=$this->toArray(); - return new TListIterator($data); + return new ArrayIterator($data); } } |