Skip to content

Commit

Permalink
Varien_ - DOC block update (1) (#703)
Browse files Browse the repository at this point in the history
* Varien_ - DOC block update (1)

- Varien_Data_
- Varien_Event_
- Varien_Object

* Varien - fixes

- reverts change from review
- reverts some code style changes
- adds/fixed some methods/return types

* Doc update

* Fixed return types

Co-authored-by: Colin Mollenhour <colin@mollenhour.com>
  • Loading branch information
sreichel and colinmollenhour authored Jun 9, 2020
1 parent 8ca6fd9 commit 3c01888
Show file tree
Hide file tree
Showing 52 changed files with 895 additions and 199 deletions.
84 changes: 60 additions & 24 deletions lib/Varien/Data/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,9 @@ public function __construct()
* Add collection filter
*
* @param string $field
* @param string $value
* @param string|array $value
* @param string $type and|or|string
* @return $this
*/
public function addFilter($field, $value, $type = 'and')
{
Expand Down Expand Up @@ -188,8 +189,8 @@ public function isLoaded()
/**
* Set collection loading status flag
*
* @param unknown_type $flag
* @return unknown
* @param bool $flag
* @return $this
*/
protected function _setIsLoaded($flag = true)
{
Expand Down Expand Up @@ -344,7 +345,7 @@ public function getItemsByColumnValue($column, $value)
*
* @param string $column
* @param mixed $value
* @return Varien_Object || null
* @return Varien_Object|null
*/
public function getItemByColumnValue($column, $value)
{
Expand All @@ -362,7 +363,7 @@ public function getItemByColumnValue($column, $value)
* Adding item to item array
*
* @param Varien_Object $item
* @return Varien_Data_Collection
* @return $this
*/
public function addItem(Varien_Object $item)
{
Expand All @@ -383,7 +384,7 @@ public function addItem(Varien_Object $item)
* Add item that has no id to collection
*
* @param Varien_Object $item
* @return Varien_Data_Collection
* @return $this
*/
protected function _addItem($item)
{
Expand Down Expand Up @@ -420,7 +421,7 @@ public function getAllIds()
* Remove item from collection by item key
*
* @param mixed $key
* @return Varien_Data_Collection
* @return $this
*/
public function removeItemByKey($key)
{
Expand All @@ -433,7 +434,7 @@ public function removeItemByKey($key)
/**
* Clear collection
*
* @return Varien_Data_Collection
* @return $this
*/
public function clear()
{
Expand All @@ -448,11 +449,11 @@ public function clear()
*
* Returns array with results of callback for each item
*
* @param string $method
* @param string $callback
* @param array $args
* @return array
*/
public function walk($callback, array $args=array())
public function walk($callback, array $args = array())
{
$results = array();
$useItemCallback = is_string($callback) && strpos($callback, '::')===false;
Expand All @@ -468,7 +469,11 @@ public function walk($callback, array $args=array())
return $results;
}

public function each($obj_method, $args=array())
/**
* @param string $obj_method
* @param array $args
*/
public function each($obj_method, $args = array())
{
foreach ($args->_items as $k => $item) {
$args->_items[$k] = call_user_func($obj_method, $item);
Expand All @@ -480,7 +485,7 @@ public function each($obj_method, $args=array())
*
* @param mixed $key
* @param mixed $value
* @return Varien_Data_Collection
* @return $this
*/
public function setDataToAll($key, $value=null)
{
Expand All @@ -500,7 +505,7 @@ public function setDataToAll($key, $value=null)
* Set current page
*
* @param int $page
* @return Varien_Data_Collection
* @return $this
*/
public function setCurPage($page)
{
Expand All @@ -512,7 +517,7 @@ public function setCurPage($page)
* Set collection page size
*
* @param int $size
* @return Varien_Data_Collection
* @return $this
*/
public function setPageSize($size)
{
Expand All @@ -525,7 +530,7 @@ public function setPageSize($size)
*
* @param string $field
* @param string $direction
* @return Varien_Data_Collection
* @return $this
*/
public function setOrder($field, $direction = self::SORT_ORDER_DESC)
{
Expand All @@ -537,7 +542,7 @@ public function setOrder($field, $direction = self::SORT_ORDER_DESC)
* Set collection item class name
*
* @param string $className
* @return Varien_Data_Collection
* @return $this
*/
function setItemObjectClass($className)
{
Expand Down Expand Up @@ -596,6 +601,7 @@ protected function _renderLimit()
* Set select distinct
*
* @param bool $flag
* @return $this
*/
public function distinct($flag)
{
Expand All @@ -605,7 +611,9 @@ public function distinct($flag)
/**
* Load data
*
* @return Varien_Data_Collection
* @param bool $printQuery
* @param bool $logQuery
* @return $this
*/
public function loadData($printQuery = false, $logQuery = false)
{
Expand All @@ -615,7 +623,9 @@ public function loadData($printQuery = false, $logQuery = false)
/**
* Load data
*
* @return Varien_Data_Collection
* @param bool $printQuery
* @param bool $logQuery
* @return $this
*/
public function load($printQuery = false, $logQuery = false)
{
Expand Down Expand Up @@ -645,6 +655,7 @@ public function toXml()
/**
* Convert collection to array
*
* @param array $arrRequiredFields
* @return array
*/
public function toArray($arrRequiredFields = array())
Expand All @@ -670,12 +681,14 @@ public function toArray($arrRequiredFields = array())
* )
* )
*
* @param string $valueField
* @param string $labelField
* @return array
* @param string $valueField
* @param string $labelField
* @param array $additional
* @return array
*/
protected function _toOptionArray($valueField='id', $labelField='name', $additional=array())
protected function _toOptionArray($valueField='id', $labelField='name', $additional = array())
{
$data = array();
$res = array();
$additional['value'] = $valueField;
$additional['label'] = $labelField;
Expand All @@ -689,11 +702,17 @@ protected function _toOptionArray($valueField='id', $labelField='name', $additio
return $res;
}

/**
* @return array
*/
public function toOptionArray()
{
return $this->_toOptionArray();
}

/**
* @return array
*/
public function toOptionHash()
{
return $this->_toOptionHash();
Expand Down Expand Up @@ -722,7 +741,7 @@ protected function _toOptionHash($valueField='id', $labelField='name')
* Retrieve item by id
*
* @param mixed $idValue
* @return Varien_Object
* @return Varien_Object|null
*/
public function getItemById($idValue)
{
Expand Down Expand Up @@ -753,28 +772,45 @@ public function count()
return count($this->_items);
}

/**
* @param string $key
* @return $this
*/
public function setCacheKey($key)
{
$this->_cacheKey = $key;
return $this;
}

/**
* @return string
*/
public function getCacheKey()
{
return $this->_cacheKey;
}

/**
* @param array $tags
* @return $this
*/
public function setCacheTags($tags)
{
$this->_cacheTags = $tags;
return $this;
}

/**
* @return array
*/
public function getCacheTags()
{
return $this->_cacheTags;
}

/**
* @return int
*/
public function getCacheLifetime()
{
return $this->_cacheLifetime;
Expand All @@ -796,7 +832,7 @@ public function getFlag($flag)
*
* @param string $flag
* @param mixed $value
* @return Varien_Data_Collection
* @return $this
*/
public function setFlag($flag, $value = null)
{
Expand Down
Loading

0 comments on commit 3c01888

Please sign in to comment.