Changed the signature of methods to avoid strict messages.

This commit is contained in:
Juan Basso 2011-07-30 19:17:20 -04:00
parent 39b4032820
commit e4a1816557
9 changed files with 44 additions and 32 deletions

View file

@ -45,7 +45,7 @@ class XcacheEngine extends CacheEngine {
* @param array $settings array of setting for the engine
* @return boolean True if the engine has been successfully initialized, false if not
*/
public function init($settings) {
public function init($settings = array()) {
parent::init(array_merge(array(
'engine' => 'Xcache',
'prefix' => Inflector::slug(APP_DIR) . '_',

View file

@ -682,7 +682,7 @@ class App {
* @param boolean $parent whether to load the class parent or not
* @return boolean true indicating the successful load and existence of the class
*/
private function _loadClass($name, $plugin, $type, $originalType, $parent) {
private static function _loadClass($name, $plugin, $type, $originalType, $parent) {
if ($type == 'Console/Command' && $name == 'Shell') {
$type = 'Console';
} else if (isset(self::$types[$originalType]['suffix'])) {

View file

@ -292,7 +292,7 @@ class Mysql extends DboSource {
* @param Model $model Name of database table to inspect or model instance
* @return array Fields in table. Keys are name and type
*/
public function describe($model) {
public function describe(Model $model) {
$cache = parent::describe($model);
if ($cache != null) {
return $cache;
@ -339,7 +339,7 @@ class Mysql extends DboSource {
* @param mixed $conditions
* @return array
*/
public function update($model, $fields = array(), $values = null, $conditions = null) {
public function update(Model $model, $fields = array(), $values = null, $conditions = null) {
if (!$this->_useAlias) {
return parent::update($model, $fields, $values, $conditions);
}
@ -381,7 +381,7 @@ class Mysql extends DboSource {
* @param mixed $conditions
* @return boolean Success
*/
public function delete($model, $conditions = null) {
public function delete(Model $model, $conditions = null) {
if (!$this->_useAlias) {
return parent::delete($model, $conditions);
}

View file

@ -319,9 +319,10 @@ class DboOracle extends DboSource {
* Returns number of rows in previous resultset. If no previous resultset exists,
* this returns false.
*
* @param mixed $source
* @return integer Number of rows in resultset
*/
public function lastNumRows() {
public function lastNumRows($source = null) {
return $this->_numRows;
}
@ -329,9 +330,11 @@ class DboOracle extends DboSource {
* Executes given SQL statement. This is an overloaded method.
*
* @param string $sql SQL statement
* @param array $params list of params to be bound to query
* @param array $prepareOptions Options to be used in the prepare statement
* @return resource Result resource identifier or null
*/
protected function _execute($sql) {
protected function _execute($sql, $params = array(), $prepareOptions = array()) {
$this->_statementId = @ociparse($this->connection, $sql);
if (!$this->_statementId) {
$this->_setError($this->connection);
@ -375,10 +378,10 @@ class DboOracle extends DboSource {
/**
* Fetch result row
*
* @param string $sql
* @return array
* @access public
*/
public function fetchRow() {
public function fetchRow($sql = null) {
if ($this->_currentRow >= $this->_numRows) {
ocifreestatement($this->_statementId);
$this->_map = null;
@ -452,9 +455,10 @@ class DboOracle extends DboSource {
* Returns an array of tables in the database. If there are no tables, an error is
* raised and the application exits.
*
* @param mixed $source
* @return array tablenames in the database
*/
public function listSources() {
public function listSources($source = null) {
$cache = parent::listSources();
if ($cache != null) {
return $cache;
@ -479,7 +483,7 @@ class DboOracle extends DboSource {
* @param Model $model instance of a model to inspect
* @return array Fields in table. Keys are name and type
*/
public function describe($model) {
public function describe(Model $model) {
$table = $this->fullTableName($model, false);
if (!empty($model->sequence)) {
@ -885,7 +889,7 @@ class DboOracle extends DboSource {
* @param string $source
* @return integer|boolean
*/
public function lastInsertId($source) {
public function lastInsertId($source = null) {
$sequence = $this->_sequenceMap[$source];
$sql = "SELECT $sequence.currval FROM dual";
@ -902,18 +906,20 @@ class DboOracle extends DboSource {
/**
* Returns a formatted error message from previous database operation.
*
* @param PDOStatement $query the query to extract the error from if any
* @return string Error message with error number
*/
public function lastError() {
public function lastError(PDOStatement $query = null) {
return $this->_error;
}
/**
* Returns number of affected rows in previous database operation. If no previous operation exists, this returns false.
*
* @param mixed $source
* @return int Number of affected rows
*/
public function lastAffected() {
public function lastAffected($source = null) {
return $this->_statementId ? ocirowcount($this->_statementId): false;
}

View file

@ -185,7 +185,7 @@ class Postgres extends DboSource {
* @param Model $model Name of database table to inspect
* @return array Fields in table. Keys are name and type
*/
public function describe($model) {
public function describe(Model $model) {
$fields = parent::describe($model);
$table = $this->fullTableName($model, false);
$this->_sequenceMap[$table] = array();
@ -267,7 +267,7 @@ class Postgres extends DboSource {
* @param string $field Name of the ID database field. Defaults to "id"
* @return integer
*/
public function lastInsertId($source, $field = 'id') {
public function lastInsertId($source = null, $field = 'id') {
$seq = $this->getSequence($source, $field);
return $this->_connection->lastInsertId($seq);
}

View file

@ -162,7 +162,7 @@ class Sqlite extends DboSource {
* @param Model $model
* @return array Fields in table. Keys are name and type
*/
public function describe($model) {
public function describe(Model $model) {
$cache = parent::describe($model);
if ($cache != null) {
return $cache;
@ -204,7 +204,7 @@ class Sqlite extends DboSource {
* @return array
* @access public
*/
public function update($model, $fields = array(), $values = null, $conditions = null) {
public function update(Model $model, $fields = array(), $values = null, $conditions = null) {
if (empty($values) && !empty($fields)) {
foreach ($fields as $field => $value) {
if (strpos($field, $model->alias . '.') !== false) {

View file

@ -169,9 +169,10 @@ class Sqlserver extends DboSource {
/**
* Returns an array of sources (tables) in the database.
*
* @param mixed $data
* @return array Array of tablenames in the database
*/
public function listSources() {
public function listSources($data = null) {
$cache = parent::listSources();
if ($cache !== null) {
return $cache;
@ -200,7 +201,7 @@ class Sqlserver extends DboSource {
* @param Model $model Model object to describe
* @return array Fields in table. Keys are name and type
*/
public function describe($model) {
public function describe(Model $model) {
$cache = parent::describe($model);
if ($cache != null) {
return $cache;
@ -330,7 +331,7 @@ class Sqlserver extends DboSource {
* @param array $values
* @return array
*/
public function create($model, $fields = null, $values = null) {
public function create(Model $model, $fields = null, $values = null) {
if (!empty($values)) {
$fields = array_combine($fields, $values);
}
@ -360,7 +361,7 @@ class Sqlserver extends DboSource {
* @param mixed $conditions
* @return array
*/
public function update($model, $fields = array(), $values = null, $conditions = null) {
public function update(Model $model, $fields = array(), $values = null, $conditions = null) {
if (!empty($values)) {
$fields = array_combine($fields, $values);
}
@ -595,7 +596,7 @@ class Sqlserver extends DboSource {
* @param integer $recursive
* @return array Array of resultset rows, or false if no rows matched
*/
public function read($model, $queryData = array(), $recursive = null) {
public function read(Model $model, $queryData = array(), $recursive = null) {
$results = parent::read($model, $queryData, $recursive);
$this->_fieldMappings = array();
return $results;
@ -733,9 +734,10 @@ class Sqlserver extends DboSource {
* Returns number of affected rows in previous database operation. If no previous operation exists,
* this returns false.
*
* @param mixed $source
* @return integer Number of affected rows
*/
public function lastAffected() {
public function lastAffected($source = null) {
$affected = parent::lastAffected();
if ($affected === null && $this->_lastAffected !== false) {
return $this->_lastAffected;

View file

@ -503,9 +503,10 @@ class DboSource extends DataSource {
* Returns number of affected rows in previous database operation. If no previous operation exists,
* this returns false.
*
* @param mixed $source
* @return integer Number of affected rows
*/
public function lastAffected() {
public function lastAffected($source = null) {
if ($this->hasResult()) {
return $this->_result->rowCount();
}
@ -516,9 +517,10 @@ class DboSource extends DataSource {
* Returns number of rows in previous resultset. If no previous resultset exists,
* this returns false.
*
* @param mixed $source Not used
* @return integer Number of rows in resultset
*/
public function lastNumRows() {
public function lastNumRows($source = null) {
return $this->lastAffected();
}
@ -990,7 +992,7 @@ class DboSource extends DataSource {
* be used to generate values.
* @return boolean Success
*/
public function create($model, $fields = null, $values = null) {
public function create(Model $model, $fields = null, $values = null) {
$id = null;
if ($fields == null) {
@ -1037,7 +1039,7 @@ class DboSource extends DataSource {
* @param integer $recursive Number of levels of association
* @return mixed boolean false on error/failure. An array of results on success.
*/
public function read($model, $queryData = array(), $recursive = null) {
public function read(Model $model, $queryData = array(), $recursive = null) {
$queryData = $this->__scrubQueryData($queryData);
$null = null;
@ -1809,7 +1811,7 @@ class DboSource extends DataSource {
* @param mixed $conditions
* @return boolean Success
*/
public function update($model, $fields = array(), $values = null, $conditions = null) {
public function update(Model $model, $fields = array(), $values = null, $conditions = null) {
if ($values == null) {
$combined = $fields;
} else {
@ -1886,7 +1888,7 @@ class DboSource extends DataSource {
* @param mixed $conditions
* @return boolean Success
*/
public function delete($model, $conditions = null) {
public function delete(Model $model, $conditions = null) {
$alias = $joins = null;
$table = $this->fullTableName($model);
$conditions = $this->_matchRecords($model, $conditions);
@ -2131,7 +2133,7 @@ class DboSource extends DataSource {
* @param string $assoc
* @return string
*/
public function resolveKey($model, $key, $assoc = null) {
public function resolveKey(Model $model, $key, $assoc = null) {
if (empty($assoc)) {
$assoc = $model->alias;
}

View file

@ -86,9 +86,11 @@ class MediaView extends View {
/**
* Display or download the given file
*
* @param string $view Not used
* @param string $layout Not used
* @return mixed
*/
public function render() {
public function render($view = null, $layout = null) {
$name = $download = $extension = $id = $modified = $path = $cache = $mimeType = $compress = null;
extract($this->viewVars, EXTR_OVERWRITE);