From 11d249e43b5c0603781e84b360d3adc8ab918b2f Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Sat, 21 May 2011 22:18:57 -0400 Subject: [PATCH] Updating PHPDoc and method visibility. --- lib/Cake/Model/Datasource/Database/Mssql.php | 39 +++++----- .../Model/Datasource/Database/MssqlTest.php | 72 +++++++------------ 2 files changed, 42 insertions(+), 69 deletions(-) diff --git a/lib/Cake/Model/Datasource/Database/Mssql.php b/lib/Cake/Model/Datasource/Database/Mssql.php index 5d967485e..b27b8cb18 100644 --- a/lib/Cake/Model/Datasource/Database/Mssql.php +++ b/lib/Cake/Model/Datasource/Database/Mssql.php @@ -93,7 +93,6 @@ class Mssql extends DboSource { * Index of basic SQL commands * * @var array - * @access protected */ protected $_commands = array( 'begin' => 'BEGIN TRANSACTION', @@ -105,7 +104,6 @@ class Mssql extends DboSource { * Define if the last query had error * * @var string - * @access private */ private $__lastQueryHadError = false; @@ -114,7 +112,7 @@ class Mssql extends DboSource { * * @return boolean True if the database could be connected, else false */ - function connect() { + public function connect() { $config = $this->config; $this->connected = false; try { @@ -180,7 +178,7 @@ class Mssql extends DboSource { * @param Model $model Model object to describe * @return array Fields in table. Keys are name and type */ - function describe($model) { + public function describe($model) { $cache = parent::describe($model); if ($cache != null) { return $cache; @@ -230,7 +228,7 @@ class Mssql extends DboSource { * @param boolean $safe Whether or not numeric data should be handled automagically if no column data is provided * @return string Quoted and escaped data */ - function value($data, $column = null, $safe = false) { + public function value($data, $column = null, $safe = false) { $parent = parent::value($data, $column, $safe); if ($column === 'float' && strpos($data, '.') !== false) { @@ -279,7 +277,7 @@ class Mssql extends DboSource { * @param mixed $fields * @return array */ - function fields($model, $alias = null, $fields = array(), $quote = true) { + public function fields($model, $alias = null, $fields = array(), $quote = true) { if (empty($alias)) { $alias = $model->alias; } @@ -345,7 +343,7 @@ class Mssql extends DboSource { * @param mixed $conditions * @return array */ - function create($model, $fields = null, $values = null) { + public function create($model, $fields = null, $values = null) { if (!empty($values)) { $fields = array_combine($fields, $values); } @@ -375,7 +373,7 @@ class Mssql extends DboSource { * @param mixed $conditions * @return array */ - function update($model, $fields = array(), $values = null, $conditions = null) { + public function update($model, $fields = array(), $values = null, $conditions = null) { if (!empty($values)) { $fields = array_combine($fields, $values); } @@ -395,7 +393,7 @@ class Mssql extends DboSource { * @param integer $offset Offset from which to start results * @return string SQL limit/offset statement */ - function limit($limit, $offset = null) { + public function limit($limit, $offset = null) { if ($limit) { $rt = ''; if (!strpos(strtolower($limit), 'top') || strpos(strtolower($limit), 'top') === 0) { @@ -416,7 +414,7 @@ class Mssql extends DboSource { * @param string $real Real database-layer column type (i.e. "varchar(255)") * @return string Abstract column type (i.e. "string") */ - function column($real) { + public function column($real) { if (is_array($real)) { $col = $real['name']; @@ -460,7 +458,7 @@ class Mssql extends DboSource { * * @param PDOStatement $results */ - function resultSet($results) { + public function resultSet($results) { $this->map = array(); $numFields = $results->columnCount(); $index = 0; @@ -492,7 +490,7 @@ class Mssql extends DboSource { * @param array $data Query data * @return string */ - function renderStatement($type, $data) { + public function renderStatement($type, $data) { switch (strtolower($type)) { case 'select': extract($data); @@ -542,9 +540,8 @@ class Mssql extends DboSource { * * @param string $order * @return string - * @access private */ - function __switchSort($order) { + private function __switchSort($order) { $order = preg_replace('/\s+ASC/i', '__tmp_asc__', $order); $order = preg_replace('/\s+DESC/i', ' ASC', $order); return preg_replace('/__tmp_asc__/', ' DESC', $order); @@ -555,9 +552,8 @@ class Mssql extends DboSource { * * @param string $sql A snippet of SQL representing an ORDER or WHERE statement * @return string The value of $sql with field names replaced - * @access private */ - function __mapFields($sql) { + private function __mapFields($sql) { if (empty($sql) || empty($this->_fieldMappings)) { return $sql; } @@ -576,7 +572,7 @@ class Mssql extends DboSource { * @param boolean $cache Enables returning/storing cached query results * @return array Array of resultset rows, or false if no rows matched */ - function read($model, $queryData = array(), $recursive = null) { + public function read($model, $queryData = array(), $recursive = null) { $results = parent::read($model, $queryData, $recursive); $this->_fieldMappings = array(); return $results; @@ -587,7 +583,7 @@ class Mssql extends DboSource { * * @return mixed */ - function fetchResult() { + public function fetchResult() { if ($row = $this->_result->fetch()) { $resultRow = array(); foreach ($this->map as $col => $meta) { @@ -633,7 +629,7 @@ class Mssql extends DboSource { * where options can be 'default', 'length', or 'key'. * @return string */ - function buildColumn($column) { + public function buildColumn($column) { $result = preg_replace('/(int|integer)\([0-9]+\)/i', '$1', parent::buildColumn($column)); if (strpos($result, 'DEFAULT NULL') !== false) { if (isset($column['default']) && $column['default'] === '') { @@ -654,7 +650,7 @@ class Mssql extends DboSource { * @param string $table * @return string */ - function buildIndex($indexes, $table = null) { + public function buildIndex($indexes, $table = null) { $join = array(); foreach ($indexes as $name => $value) { @@ -679,10 +675,9 @@ class Mssql extends DboSource { * Makes sure it will return the primary key * * @param mixed $model Model instance of table name - * @access protected * @return string */ - function _getPrimaryKey($model) { + protected function _getPrimaryKey($model) { if (!is_object($model)) { $model = new Model(false, $model); } diff --git a/lib/Cake/Test/Case/Model/Datasource/Database/MssqlTest.php b/lib/Cake/Test/Case/Model/Datasource/Database/MssqlTest.php index a77e3fc6a..7b6b27f15 100644 --- a/lib/Cake/Test/Case/Model/Datasource/Database/MssqlTest.php +++ b/lib/Cake/Test/Case/Model/Datasource/Database/MssqlTest.php @@ -31,7 +31,6 @@ class MssqlTestDb extends Mssql { * simulated property * * @var array - * @access public */ public $simulated = array(); @@ -39,7 +38,6 @@ class MssqlTestDb extends Mssql { * execute results stack * * @var array - * @access public */ public $executeResultsStack = array(); @@ -47,10 +45,9 @@ class MssqlTestDb extends Mssql { * execute method * * @param mixed $sql - * @access protected - * @return void + * @return mixed */ - function _execute($sql) { + protected function _execute($sql) { $this->simulated[] = $sql; return empty($this->executeResultsStack) ? null : array_pop($this->executeResultsStack); } @@ -59,20 +56,18 @@ class MssqlTestDb extends Mssql { * fetchAll method * * @param mixed $sql - * @access protected * @return void */ - function _matchRecords($model, $conditions = null) { + protected function _matchRecords($model, $conditions = null) { return $this->conditions(array('id' => array(1, 2))); } /** * getLastQuery method * - * @access public - * @return void + * @return string */ - function getLastQuery() { + public function getLastQuery() { return $this->simulated[count($this->simulated) - 1]; } @@ -80,20 +75,18 @@ class MssqlTestDb extends Mssql { * getPrimaryKey method * * @param mixed $model - * @access public - * @return void + * @return string */ - function getPrimaryKey($model) { + public function getPrimaryKey($model) { return parent::_getPrimaryKey($model); } /** * clearFieldMappings method * - * @access public * @return void */ - function clearFieldMappings() { + public function clearFieldMappings() { $this->_fieldMappings = array(); } @@ -101,10 +94,9 @@ class MssqlTestDb extends Mssql { * describe method * * @param object $model - * @access public * @return void */ - function describe($model) { + public function describe($model) { return empty($this->describe) ? parent::describe($model) : $this->describe; } } @@ -120,7 +112,6 @@ class MssqlTestModel extends Model { * name property * * @var string 'MssqlTestModel' - * @access public */ public $name = 'MssqlTestModel'; @@ -128,7 +119,6 @@ class MssqlTestModel extends Model { * useTable property * * @var bool false - * @access public */ public $useTable = false; @@ -136,7 +126,6 @@ class MssqlTestModel extends Model { * _schema property * * @var array - * @access protected */ protected $_schema = array( 'id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8', 'key' => 'primary'), @@ -163,7 +152,6 @@ class MssqlTestModel extends Model { * belongsTo property * * @var array - * @access public */ public $belongsTo = array( 'MssqlClientTestModel' => array( @@ -177,10 +165,9 @@ class MssqlTestModel extends Model { * @param mixed $fields * @param mixed $order * @param mixed $recursive - * @access public * @return void */ - function find($conditions = null, $fields = null, $order = null, $recursive = null) { + public function find($conditions = null, $fields = null, $order = null, $recursive = null) { return $conditions; } @@ -191,10 +178,9 @@ class MssqlTestModel extends Model { * @param mixed $fields * @param mixed $order * @param mixed $recursive - * @access public - * @return void + * @return array */ - function findAll($conditions = null, $fields = null, $order = null, $recursive = null) { + public function findAll($conditions = null, $fields = null, $order = null, $recursive = null) { return $conditions; } } @@ -209,21 +195,20 @@ class MssqlClientTestModel extends Model { * name property * * @var string 'MssqlAssociatedTestModel' - * @access public */ public $name = 'MssqlClientTestModel'; + /** * useTable property * * @var bool false - * @access public */ public $useTable = false; + /** * _schema property * * @var array - * @access protected */ protected $_schema = array( 'id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8', 'key' => 'primary'), @@ -243,7 +228,7 @@ class MssqlTestResultIterator extends ArrayIterator { /** * closeCursor method * - * @access public + * @return void */ public function closeCursor() {} } @@ -259,7 +244,6 @@ class MssqlTest extends CakeTestCase { * The Dbo instance to be tested * * @var DboSource - * @access public */ public $db = null; @@ -267,14 +251,13 @@ class MssqlTest extends CakeTestCase { * autoFixtures property * * @var bool false - * @access public */ public $autoFixtures = false; + /** * fixtures property * * @var array - * @access public */ public $fixtures = array('core.category'); @@ -294,21 +277,20 @@ class MssqlTest extends CakeTestCase { /** * tearDown method * - * @access public * @return void */ - function tearDown() { - unset($this->db->describe); + public function tearDown() { + unset($this->Dbo); + unset($this->db); unset($this->model); } /** * testQuoting method * - * @access public * @return void */ - function testQuoting() { + public function testQuoting() { $expected = "1.2"; $result = $this->db->value(1.2, 'float'); $this->assertIdentical($expected, $result); @@ -332,10 +314,9 @@ class MssqlTest extends CakeTestCase { /** * testFields method * - * @access public * @return void */ - function testFields() { + public function testFields() { $fields = array( '[MssqlTestModel].[id] AS [MssqlTestModel__0]', '[MssqlTestModel].[client_id] AS [MssqlTestModel__1]', @@ -387,10 +368,9 @@ class MssqlTest extends CakeTestCase { /** * testDistinctFields method * - * @access public * @return void */ - function testDistinctFields() { + public function testDistinctFields() { $result = $this->db->fields($this->model, null, array('DISTINCT Car.country_code')); $expected = array('DISTINCT [Car].[country_code] AS [Car__0]'); $this->assertEqual($expected, $result); @@ -403,10 +383,9 @@ class MssqlTest extends CakeTestCase { /** * testDistinctWithLimit method * - * @access public * @return void */ - function testDistinctWithLimit() { + public function testDistinctWithLimit() { $this->db->read($this->model, array( 'fields' => array('DISTINCT MssqlTestModel.city', 'MssqlTestModel.country'), 'limit' => 5 @@ -418,10 +397,9 @@ class MssqlTest extends CakeTestCase { /** * testDescribe method * - * @access public * @return void */ - function testDescribe() { + public function testDescribe() { $MssqlTableDescription = new MssqlTestResultIterator(array( (object) array( 'Default' => '((0))', @@ -448,7 +426,7 @@ class MssqlTest extends CakeTestCase { /** * testBuildColumn * - * @return unknown_type + * @return void */ public function testBuildColumn() { $column = array('name' => 'id', 'type' => 'integer', 'null' => false, 'default' => '', 'length' => '8', 'key' => 'primary');