Skip to content

Commit

Permalink
Merge pull request #4245 from beporter/cakeschema-style-guide-updates
Browse files Browse the repository at this point in the history
Improve docblock formatting.
  • Loading branch information
ADmad committed Aug 12, 2014
2 parents f1d0173 + 5c69ac5 commit c5d1bcf
Showing 1 changed file with 56 additions and 55 deletions.
111 changes: 56 additions & 55 deletions lib/Cake/Model/CakeSchema.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,49 +22,49 @@
App::uses('File', 'Utility');

/**
* Base Class for Schema management
* Base Class for Schema management.
*
* @package Cake.Model
*/
class CakeSchema extends Object {

/**
* Name of the schema
* Name of the schema.
*
* @var string
*/
public $name = null;

/**
* Path to write location
* Path to write location.
*
* @var string
*/
public $path = null;

/**
* File to write
* File to write.
*
* @var string
*/
public $file = 'schema.php';

/**
* Connection used for read
* Connection used for read.
*
* @var string
*/
public $connection = 'default';

/**
* plugin name.
* Plugin name.
*
* @var string
*/
public $plugin = null;

/**
* Set of tables
* Set of tables.
*
* @var array
*/
Expand All @@ -73,7 +73,7 @@ class CakeSchema extends Object {
/**
* Constructor
*
* @param array $options optional load object properties
* @param array $options Optional load object properties.
*/
public function __construct($options = array()) {
parent::__construct();
Expand All @@ -98,9 +98,9 @@ public function __construct($options = array()) {
}

/**
* Builds schema object properties
* Builds schema object properties.
*
* @param array $data loaded object properties
* @param array $data Loaded object properties.
* @return void
*/
public function build($data) {
Expand Down Expand Up @@ -129,29 +129,29 @@ public function build($data) {
}

/**
* Before callback to be implemented in subclasses
* Before callback to be implemented in subclasses.
*
* @param array $event schema object properties
* @return bool Should process continue
* @param array $event Schema object properties.
* @return bool Should process continue.
*/
public function before($event = array()) {
return true;
}

/**
* After callback to be implemented in subclasses
* After callback to be implemented in subclasses.
*
* @param array $event schema object properties
* @param array $event Schema object properties.
* @return void
*/
public function after($event = array()) {
}

/**
* Reads database and creates schema tables
* Reads database and creates schema tables.
*
* @param array $options schema object properties
* @return array Set of name and tables
* @param array $options Schema object properties.
* @return array Set of name and tables.
*/
public function load($options = array()) {
if (is_string($options)) {
Expand All @@ -178,16 +178,16 @@ public function load($options = array()) {
}

/**
* Reads database and creates schema tables
* Reads database and creates schema tables.
*
* Options
*
* - 'connection' - the db connection to use
* - 'name' - name of the schema
* - 'models' - a list of models to use, or false to ignore models
*
* @param array $options schema object properties
* @return array Array indexed by name and tables
* @param array $options Schema object properties.
* @return array Array indexed by name and tables.
*/
public function read($options = array()) {
extract(array_merge(
Expand Down Expand Up @@ -340,11 +340,11 @@ public function read($options = array()) {
}

/**
* Writes schema file from object or options
* Writes schema file from object or options.
*
* @param array|object $object schema object or options array
* @param array $options schema object properties to override object
* @return mixed false or string written to file
* @param array|object $object Schema object or options array.
* @param array $options Schema object properties to override object.
* @return mixed False or string written to file.
*/
public function write($object, $options = array()) {
if (is_object($object)) {
Expand Down Expand Up @@ -398,11 +398,11 @@ public function write($object, $options = array()) {

/**
* Generate the code for a table. Takes a table name and $fields array
* Returns a completed variable declaration to be used in schema classes
* Returns a completed variable declaration to be used in schema classes.
*
* @param string $table Table name you want returned.
* @param array $fields Array of field information to generate the table with.
* @return string Variable declaration for a schema class
* @return string Variable declaration for a schema class.
*/
public function generateTable($table, $fields) {
$out = "\tpublic \${$table} = array(\n";
Expand Down Expand Up @@ -442,11 +442,11 @@ public function generateTable($table, $fields) {
}

/**
* Compares two sets of schemas
* Compares two sets of schemas.
*
* @param array|object $old Schema object or array
* @param array|object $new Schema object or array
* @return array Tables (that are added, dropped, or changed)
* @param array|object $old Schema object or array.
* @param array|object $new Schema object or array.
* @return array Tables (that are added, dropped, or changed.)
*/
public function compare($old, $new = null) {
if (empty($new)) {
Expand Down Expand Up @@ -528,15 +528,15 @@ public function compare($old, $new = null) {
}

/**
* Extended array_diff_assoc noticing change from/to NULL values
* Extended array_diff_assoc noticing change from/to NULL values.
*
* It behaves almost the same way as array_diff_assoc except for NULL values: if
* one of the values is not NULL - change is detected. It is useful in situation
* where one value is strval('') ant other is strval(null) - in string comparing
* methods this results as EQUAL, while it is not.
*
* @param array $array1 Base array
* @param array $array2 Corresponding array checked for equality
* @param array $array1 Base array.
* @param array $array2 Corresponding array checked for equality.
* @return array Difference as array with array(keys => values) from input array
* where match was not found.
*/
Expand Down Expand Up @@ -568,10 +568,10 @@ protected function _arrayDiffAssoc($array1, $array2) {
}

/**
* Formats Schema columns from Model Object
* Formats Schema columns from Model Object.
*
* @param array $values options keys(type, null, default, key, length, extra)
* @return array Formatted values
* @param array $values Options keys(type, null, default, key, length, extra).
* @return array Formatted values.
*/
protected function _values($values) {
$vals = array();
Expand All @@ -596,10 +596,10 @@ protected function _values($values) {
}

/**
* Formats Schema columns from Model Object
* Formats Schema columns from Model Object.
*
* @param array &$Obj model object
* @return array Formatted columns
* @param array &$Obj model object.
* @return array Formatted columns.
*/
protected function _columns(&$Obj) {
$db = $Obj->getDataSource();
Expand Down Expand Up @@ -639,10 +639,10 @@ protected function _columns(&$Obj) {
}

/**
* Compare two schema files table Parameters
* Compare two schema files table Parameters.
*
* @param array $new New indexes
* @param array $old Old indexes
* @param array $new New indexes.
* @param array $old Old indexes.
* @return mixed False on failure, or an array of parameters to add & drop.
*/
protected function _compareTableParameters($new, $old) {
Expand All @@ -654,11 +654,11 @@ protected function _compareTableParameters($new, $old) {
}

/**
* Compare two schema indexes
* Compare two schema indexes.
*
* @param array $new New indexes
* @param array $old Old indexes
* @return mixed false on failure or array of indexes to add and drop
* @param array $new New indexes.
* @param array $old Old indexes.
* @return mixed False on failure or array of indexes to add and drop.
*/
protected function _compareIndexes($new, $old) {
if (!is_array($new) || !is_array($old)) {
Expand Down Expand Up @@ -705,22 +705,23 @@ protected function _compareIndexes($new, $old) {
}

/**
* Trim the table prefix from the full table name, and return the prefix-less table
* Trim the table prefix from the full table name, and return the prefix-less
* table.
*
* @param string $prefix Table prefix
* @param string $table Full table name
* @return string Prefix-less table name
* @param string $prefix Table prefix.
* @param string $table Full table name.
* @return string Prefix-less table name.
*/
protected function _noPrefixTable($prefix, $table) {
return preg_replace('/^' . preg_quote($prefix) . '/', '', $table);
}

/**
* Attempts to require the schema file specified
* Attempts to require the schema file specified.
*
* @param string $path Filesystem path to the file
* @param string $file Filesystem basename of the file
* @return bool True when a file was successfully included, false on failure
* @param string $path Filesystem path to the file.
* @param string $file Filesystem basename of the file.
* @return bool True when a file was successfully included, false on failure.
*/
protected function _requireFile($path, $file) {
if (file_exists($path . DS . $file) && is_file($path . DS . $file)) {
Expand Down

0 comments on commit c5d1bcf

Please sign in to comment.