From dc76cfdcf0521552667d44395a2290a5c8e48281 Mon Sep 17 00:00:00 2001 From: Fabio Bas Date: Mon, 29 Feb 2016 22:14:08 +0100 Subject: Fixed 10 "critical" issues found by scrutinizer * create function => closures * removed var_dump from tests --- tests/unit/Data/ActiveRecord/ActiveRecordDynamicCallTest.php | 1 - 1 file changed, 1 deletion(-) (limited to 'tests/unit') diff --git a/tests/unit/Data/ActiveRecord/ActiveRecordDynamicCallTest.php b/tests/unit/Data/ActiveRecord/ActiveRecordDynamicCallTest.php index 8c6b9789..a472e546 100644 --- a/tests/unit/Data/ActiveRecord/ActiveRecordDynamicCallTest.php +++ b/tests/unit/Data/ActiveRecord/ActiveRecordDynamicCallTest.php @@ -74,6 +74,5 @@ class ActiveRecordDynamicCallTest extends PHPUnit_Framework_TestCase function assertDeleteSql($sender, $param) { - var_dump($param); } } -- cgit v1.2.3 From 64d458715b1018b039d1bafca3cf9dcec511074f Mon Sep 17 00:00:00 2001 From: Fabio Bas Date: Wed, 9 Mar 2016 11:26:56 +0100 Subject: Removed deprecated code --- buildscripts/classtree/DWExtension.php | 2 +- framework/Collections/TList.php | 73 +--------------------- framework/Collections/TMap.php | 72 +-------------------- framework/Collections/TPagedList.php | 2 +- framework/I18N/core/TCache_Lite.php | 7 --- framework/Util/TCallChain.php | 4 +- framework/Web/THttpRequest.php | 2 +- .../Web/UI/ActiveControls/TCallbackClientSide.php | 10 +-- framework/Web/UI/WebControls/TDataGrid.php | 2 +- framework/Xml/TXmlDocument.php | 2 +- tests/unit/Web/THttpRequestTest.php | 2 +- 11 files changed, 13 insertions(+), 165 deletions(-) (limited to 'tests/unit') diff --git a/buildscripts/classtree/DWExtension.php b/buildscripts/classtree/DWExtension.php index a7a1ca30..8df8ed94 100644 --- a/buildscripts/classtree/DWExtension.php +++ b/buildscripts/classtree/DWExtension.php @@ -217,7 +217,7 @@ class PradoTagChooser protected function prepareDocument() { - $this->_document->standalone = true; + $this->_document->xmlStandalone = true; $this->_document->formatOutput = true; $tclibrary = $this->_document->createElement('tclibrary'); $tclibrary->setAttribute('name','PRADO tags'); 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..99ec9b81 100644 --- a/framework/Collections/TMap.php +++ b/framework/Collections/TMap.php @@ -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); } } diff --git a/framework/I18N/core/TCache_Lite.php b/framework/I18N/core/TCache_Lite.php index 94061526..b42bf1f9 100644 --- a/framework/I18N/core/TCache_Lite.php +++ b/framework/I18N/core/TCache_Lite.php @@ -533,18 +533,11 @@ class TCache_Lite // because the filesize can be cached by PHP itself... clearstatcache(); $length = @filesize($this->_file); - if(version_compare(PHP_VERSION, '5.3.0', 'lt')) - { - $mqr = get_magic_quotes_runtime(); - set_magic_quotes_runtime(0); - } if ($this->_readControl) { $hashControl = @fread($fp, 32); $length = $length - 32; } $data = @fread($fp, $length); - if(isset($mqr)) - set_magic_quotes_runtime($mqr); if ($this->_fileLocking) @flock($fp, LOCK_UN); @fclose($fp); if ($this->_readControl) { diff --git a/framework/Util/TCallChain.php b/framework/Util/TCallChain.php index 4e9e23f7..49891641 100644 --- a/framework/Util/TCallChain.php +++ b/framework/Util/TCallChain.php @@ -19,7 +19,7 @@ class TCallChain extends TList implements IDynamicMethods { /** - * @var {@link TListIterator} for moving through the chained method calls + * @var {@link ArrayIterator} for moving through the chained method calls */ private $_iterator=null; @@ -97,7 +97,7 @@ class TCallChain extends TList implements IDynamicMethods if(!$this->_iterator) { $chain_array=array_reverse($this->toArray()); - $this->_iterator=new TListIterator($chain_array); + $this->_iterator=new ArrayIterator($chain_array); } if($this->_iterator->valid()) do { diff --git a/framework/Web/THttpRequest.php b/framework/Web/THttpRequest.php index 2a5b812d..926cfa46 100644 --- a/framework/Web/THttpRequest.php +++ b/framework/Web/THttpRequest.php @@ -816,7 +816,7 @@ class THttpRequest extends TApplicationComponent implements IteratorAggregate,Ar */ public function getIterator() { - return new TMapIterator($this->_items); + return new ArrayIterator($this->_items); } /** diff --git a/framework/Web/UI/ActiveControls/TCallbackClientSide.php b/framework/Web/UI/ActiveControls/TCallbackClientSide.php index 113b35ce..4cb482ad 100644 --- a/framework/Web/UI/ActiveControls/TCallbackClientSide.php +++ b/framework/Web/UI/ActiveControls/TCallbackClientSide.php @@ -240,8 +240,7 @@ class TCallbackClientSide extends TClientSideOptions */ public function getHasPriority() { - $option = $this->getOption('HasPriority'); - return ($option===null) ? true : $option; + return true; } /** @@ -252,9 +251,8 @@ class TCallbackClientSide extends TClientSideOptions */ public function setHasPriority($value) { - $hasPriority = TPropertyValue::ensureBoolean($value); - $this->setOption('HasPriority', $hasPriority); - if(!$hasPriority) + // mimic the old behavior + if(!$value) $this->setEnablePageStateUpdate(false); } @@ -268,8 +266,6 @@ class TCallbackClientSide extends TClientSideOptions { $enabled = TPropertyValue::ensureBoolean($value); $this->setOption('EnablePageStateUpdate', $enabled); - if($enabled) - $this->setHasPriority(true); } /** diff --git a/framework/Web/UI/WebControls/TDataGrid.php b/framework/Web/UI/WebControls/TDataGrid.php index 9403fa45..2f338d22 100644 --- a/framework/Web/UI/WebControls/TDataGrid.php +++ b/framework/Web/UI/WebControls/TDataGrid.php @@ -1162,7 +1162,7 @@ class TDataGrid extends TBaseDataList implements INamingContainer $param=new TDataGridItemEventParameter($item); if($dataBind) { - $item->setDataItem($dataItem); + $item->setData($dataItem); $this->onItemCreated($param); $this->getControls()->add($item); $item->dataBind(); diff --git a/framework/Xml/TXmlDocument.php b/framework/Xml/TXmlDocument.php index 75122986..92d8961b 100644 --- a/framework/Xml/TXmlDocument.php +++ b/framework/Xml/TXmlDocument.php @@ -384,7 +384,7 @@ class TXmlDocument extends TXmlElement return false; $this->setEncoding($doc->encoding); - $this->setVersion($doc->version); + $this->setVersion($doc->xmlVersion); $element=$doc->documentElement; $this->setTagName($element->tagName); diff --git a/tests/unit/Web/THttpRequestTest.php b/tests/unit/Web/THttpRequestTest.php index 314cce0a..a4e679d8 100644 --- a/tests/unit/Web/THttpRequestTest.php +++ b/tests/unit/Web/THttpRequestTest.php @@ -328,7 +328,7 @@ class THttpRequestTest extends PHPUnit_Framework_TestCase { public function testGetIterator() { $request = new THttpRequest (); $request->init(null); - self::assertInstanceOf ('TMapIterator', $request->getIterator()); + self::assertInstanceOf ('ArrayIterator', $request->getIterator()); } public function testGetCount() { -- cgit v1.2.3