Skip to content

Commit

Permalink
PHPCS - fix if(, foreach( and ){
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel O'Connor committed Sep 5, 2011
1 parent 60ded96 commit 6e41850
Show file tree
Hide file tree
Showing 59 changed files with 395 additions and 395 deletions.
6 changes: 3 additions & 3 deletions DAS/Relational.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public function ensureColumnSpecifierIsNullOrAnArrayContainingOnlyValidTableAndC
if (gettype($column_specifier) != 'array') {
throw new SDO_DAS_Relational_Exception('The column specifier passed to executeQuery must be an array');
}
foreach($column_specifier as $cs) {
foreach ($column_specifier as $cs) {
if (gettype($cs) != 'string') {
throw new SDO_DAS_Relational_Exception('Each entry in the column specifier must be a string');
}
Expand Down Expand Up @@ -248,7 +248,7 @@ public function normaliseResultSet($pdo_stmt, $column_specifier)
public function breakRowIntoObjectsUsingPDOColumnNames($row)
{
$parsed_row = array();
foreach($row as $col => $value) {
foreach ($row as $col => $value) {
$table_names_with_this_column = $this->object_model->getTypesByColumnNameIgnoreCase($col);
switch (count($table_names_with_this_column)) {
case 0:
Expand Down Expand Up @@ -360,7 +360,7 @@ private static function displayChangeSummary($cs)
{
$changed_data_objects = $cs->getChangedDataObjects();
echo "Change Summary contains " . count($changed_data_objects) . " objects:\n";
foreach($changed_data_objects as $cdo) {
foreach ($changed_data_objects as $cdo) {
echo ' Object of type ' . SDO_DAS_Relational_DataObjectHelper::getApplicationType($cdo) . "\n";
$change_type = $cs->getChangeType($cdo);
switch ($change_type) {
Expand Down
18 changes: 9 additions & 9 deletions DAS/Relational/ContainmentReference.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
/*
/*
+----------------------------------------------------------------------+
| (c) Copyright IBM Corporation 2005. |
| All Rights Reserved. |
Expand All @@ -25,12 +25,12 @@

/**
* Encapsulates one SDO containment reference
*
*
* has a parent, a child
*
* TODO could have a name if the user wants to specify a different name for the reference. For now it is the name of the
* child.
*/
* TODO could have a name if the user wants to specify a different name for the reference. For now it is the name of the
* child.
*/


class SDO_DAS_Relational_ContainmentReference {
Expand All @@ -46,7 +46,7 @@ public function __construct($ref_metadata)
/*
* Check metadata specifies a parent field
*/
if (array_key_exists('parent', $ref_metadata)){
if (array_key_exists('parent', $ref_metadata)) {
$this->parent = $ref_metadata['parent'];
} else {
throw new SDO_DAS_Relational_Exception('The metadata for a reference did not contain a parent field.');
Expand All @@ -55,14 +55,14 @@ public function __construct($ref_metadata)
/*
* Check parent is a string
*/
if (gettype($this->parent) != 'string'){
if (gettype($this->parent) != 'string') {
throw new SDO_DAS_Relational_Exception('The metadata for a reference specified a parent field ' . $this->parent . ' that was not a string.');
}

/*
* Check metadata specifies a child field
*/
if (array_key_exists('child', $ref_metadata)){
if (array_key_exists('child', $ref_metadata)) {
$this->child = $ref_metadata['child'];
} else {
throw new SDO_DAS_Relational_Exception('The metadata for a reference with parent field '.$this->parent.' did not contain a child field.');
Expand All @@ -71,7 +71,7 @@ public function __construct($ref_metadata)
/*
* Check parent is a string
*/
if (gettype($this->child) != 'string'){
if (gettype($this->child) != 'string') {
throw new SDO_DAS_Relational_Exception('The metadata for a reference specified a child field ' . $this->child . ' that was not a string.');
}

Expand Down
6 changes: 3 additions & 3 deletions DAS/Relational/DataObjectHelper.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
/*
/*
+----------------------------------------------------------------------+
| (c) Copyright IBM Corporation 2005, 2006. |
| All Rights Reserved. |
Expand All @@ -22,7 +22,7 @@
*/

/**
* Helper routines for use on or with an SDO data object. These are logically instance methods on a data object
* Helper routines for use on or with an SDO data object. These are logically instance methods on a data object
* but since we do not own the implementation of the SDO Data Object we put them in this helper class
*/

Expand All @@ -33,7 +33,7 @@ public static function getCurrentPrimitiveSettings($data_object,$object_model)
{
$nvpairs = array();
$type = self::getApplicationType($data_object);
foreach($data_object as $prop => $value) {
foreach ($data_object as $prop => $value) {
if ($object_model->isPrimitive($type, $prop)) {
if (isset($data_object[$prop])) {
$nvpairs[$prop] = $data_object[$prop];
Expand Down
32 changes: 16 additions & 16 deletions DAS/Relational/DatabaseModel.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
/*
/*
+----------------------------------------------------------------------+
| (c) Copyright IBM Corporation 2005, 2007. |
| All Rights Reserved. |
Expand Down Expand Up @@ -39,7 +39,7 @@ class SDO_DAS_Relational_DatabaseModel {
private $tables = array(); // Set of SDO_DAS_Relational_Table
private $foreign_keys = array(); // Set of SDO_DAS_Relational_Table

public function __construct($database_metadata)
public function __construct($database_metadata)
{
foreach ($database_metadata as $tdef) {

Expand All @@ -55,28 +55,28 @@ public function __construct($database_metadata)
$this->checkFKsPointToValidTables();
}

private function checkFKsPointToValidTables()
private function checkFKsPointToValidTables()
{
foreach ($this->tables as $t) {
$all_table_names[] = $t->getTableName();
}
foreach ($this->foreign_keys as $fk) {
$to_table_name = $fk->getToTableName();
if (!in_array($to_table_name, $all_table_names)){
if (!in_array($to_table_name, $all_table_names)) {
throw new SDO_DAS_Relational_Exception('A foreign key specifies a to field of ' . $to_table_name . ', which is not a valid table name');
}
}
}
public function getAllTableNames()

public function getAllTableNames()
{
foreach ($this->tables as $t) {
$all_table_names[] = $t->getTableName();
}
return $all_table_names;
}

public function isValidTableName($name)
public function isValidTableName($name)
{
foreach ($this->tables as $table) {
if ($name == $table->getTableName()) {
Expand All @@ -85,7 +85,7 @@ public function isValidTableName($name)
}
return false;
}

public function getParentTable($table_name)
{
foreach ($this->foreign_keys as $fk) {
Expand All @@ -96,7 +96,7 @@ public function getParentTable($table_name)
return null;
}

public function isValidTableAndColumnPair($table_name, $column_name)
public function isValidTableAndColumnPair($table_name, $column_name)
{
$table = $this->getTableByName($table_name);
if ($table == null) return false;
Expand All @@ -105,7 +105,7 @@ public function isValidTableAndColumnPair($table_name, $column_name)
else return false;
}

public function getTableByName($name)
public function getTableByName($name)
{
foreach ($this->tables as $table) {
if ($table->getTableName() == $name) {
Expand All @@ -115,32 +115,32 @@ public function getTableByName($name)
return null;
}

public function getColumns($table_name)
public function getColumns($table_name)
{
foreach($this->tables as $table) {
foreach ($this->tables as $table) {
if ($table->getTableName() == $table_name) {
return $table->getColumns();
}
}
return null;
}

public function getForeignKeys()
public function getForeignKeys()
{
return $this->foreign_keys;
}

public function getForeignKeyByFromTableNameAndColumnName($table_name,$column_name)
public function getForeignKeyByFromTableNameAndColumnName($table_name,$column_name)
{
foreach($this->foreign_keys as $fk) {
foreach ($this->foreign_keys as $fk) {
if ($fk->getFromTableName() == $table_name && $fk->getFromColumnName() == $column_name) {
return $fk;
}
}
return null;
}

public function getPrimaryKeyFromTableName($table_name)
public function getPrimaryKeyFromTableName($table_name)
{
$table = $this->getTableByName($table_name);
assert($table != null);
Expand Down
8 changes: 4 additions & 4 deletions DAS/Relational/DeleteAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function __construct($object_model,$do, $old_values)
$type = SDO_DAS_Relational_DataObjectHelper::getApplicationType($do);

$old_values_of_any_changed_properties = SDO_DAS_Relational_SettingListHelper::getSettingsAsArray($old_values);
foreach($this->do as $prop => $value) {
foreach ($this->do as $prop => $value) {
if ($this->object_model->isContainmentReferenceProperty($type, $prop)) {
// We ignore containment references - any changes to them appear elsewhere in the C/S
continue;
Expand Down Expand Up @@ -82,7 +82,7 @@ public function execute($dbh)
public function convertNonContainmentReferencesFromObjectToPK()
{
$type = SDO_DAS_Relational_DataObjectHelper::getApplicationType($this->do);
foreach($this->settings_for_where_clause as $prop => $value) {
foreach ($this->settings_for_where_clause as $prop => $value) {
if ($value === null) continue;
if ($this->object_model->isNonContainmentReferenceProperty($type, $prop)) {
$pk = SDO_DAS_Relational_DataObjectHelper::getPrimaryKeyFromDataObject($this->object_model, $value);
Expand All @@ -94,7 +94,7 @@ public function convertNonContainmentReferencesFromObjectToPK()
public function buildValueList()
{
$value_list = array();
foreach($this->settings_for_where_clause as $name => $value) {
foreach ($this->settings_for_where_clause as $name => $value) {
if ($value === null) {
// no-op - don't add to value list as we will have put IS NULL in the UPDATE statement
} else {
Expand All @@ -115,7 +115,7 @@ public function toSQL()

private function constructWhereClauseFromOriginalValues($original_values_as_nv_pairs)
{
foreach($original_values_as_nv_pairs as $name => $value) {
foreach ($original_values_as_nv_pairs as $name => $value) {
$sql_compares[] = $this->makeAnSQLCompare($name, $value);
}
$where_clause = 'WHERE ';
Expand Down
16 changes: 8 additions & 8 deletions DAS/Relational/ForeignKey.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
/*
/*
+----------------------------------------------------------------------+
| (c) Copyright IBM Corporation 2005. |
| All Rights Reserved. |
Expand All @@ -23,7 +23,7 @@

/**
* ForeignKey encapsulates all the information about a foreign key
*
*
* 1 it has a from table name
* 2 it has a from column
* 3 it has a to table name (necessarily to the table's primary key)
Expand All @@ -34,7 +34,7 @@ class SDO_DAS_Relational_ForeignKey {
private $from_column_name;
private $to_table_name;

public function __construct($table_metadata)
public function __construct($table_metadata)
{

/**
Expand All @@ -55,7 +55,7 @@ public function __construct($table_metadata)
/*
* Check FK metadata is an array
*/
if (gettype($fk_metadata) != 'array'){
if (gettype($fk_metadata) != 'array') {
$msg = "The metadata for table ".$table_name." specified foreign key metadata that was not an array.";
throw new SDO_DAS_Relational_Exception($msg);
}
Expand Down Expand Up @@ -104,18 +104,18 @@ public function __construct($table_metadata)
*/

}
public function getToTableName()

public function getToTableName()
{
return $this->to_table_name;
}

public function getFromTableName()
public function getFromTableName()
{
return $this->from_table_name;
}

public function getFromColumnName()
public function getFromColumnName()
{
return $this->from_column_name;
}
Expand Down
22 changes: 11 additions & 11 deletions DAS/Relational/InsertAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@
/**
* Represent an insert of a row to the database
*
* Holds the name of the table into which we will insert, and an array of name=>value pairs to represent the
* Holds the name of the table into which we will insert, and an array of name=>value pairs to represent the
* columns that we want to set: the name is the name of the column and the value is that to which it must be set.
* When it comes to creating the SQL statement to insert the data, most values just need to be enclosed in double quotes.
* This works for strings, integers and floats.
* If the value is the PHP null value, an SQL NULL will be inserted.
* If the value is the PHP null value, an SQL NULL will be inserted.
* If the value is a PHP boolean true or false, it will be converted to "1" or "0".
*/

Expand Down Expand Up @@ -64,10 +64,10 @@ public function __construct($object_model,$do)
}
}

public function computeSettingsForInsert()
public function computeSettingsForInsert()
{
$type = SDO_DAS_Relational_DataObjectHelper::getApplicationType($this->do);
foreach($this->do as $prop => $value) {
foreach ($this->do as $prop => $value) {
if ($this->object_model->isContainmentReferenceProperty($type, $prop)) {
// We ignore containment references - updates to them will appear as creates or deletes elsewhere in the C/S
continue;
Expand All @@ -77,10 +77,10 @@ public function computeSettingsForInsert()
}

//TODO have three copies of this method in each of I/U/D. Not happy
public function convertNonContainmentReferencesFromObjectToPK()
public function convertNonContainmentReferencesFromObjectToPK()
{
$type = SDO_DAS_Relational_DataObjectHelper::getApplicationType($this->do);
foreach($this->settings_for_insert as $prop => $value) {
foreach ($this->settings_for_insert as $prop => $value) {
if ($value === null) continue;
if ($this->object_model->isNonContainmentReferenceProperty($type, $prop)) {
$pk = SDO_DAS_Relational_DataObjectHelper::getPrimaryKeyFromDataObject($this->object_model, $value);
Expand All @@ -107,9 +107,9 @@ public function execute($dbh)
return $this->spawned_actions;
}

public function buildValueList()
public function buildValueList()
{
foreach($this->settings_for_insert as $name => $value) {
foreach ($this->settings_for_insert as $name => $value) {
$this->value_list[] = $value;
}
}
Expand All @@ -131,7 +131,7 @@ private function spawnLaterUpdatesForNonContainmentReferences($do)
{
$spawned_actions = null;
$type = SDO_DAS_Relational_DataObjectHelper::getApplicationType($do);
foreach($do as $prop => $value) {
foreach ($do as $prop => $value) {
if ($this->object_model->isNonContainmentReferenceProperty($type, $prop)) {
if (isset($do[$prop])) {
// TODO handle null
Expand All @@ -147,7 +147,7 @@ private function spawnLaterUpdatesForNonContainmentReferences($do)

public function toSQL()
{
foreach($this->settings_for_insert as $name => $value) {
foreach ($this->settings_for_insert as $name => $value) {
$name_list[] = $name;
$placeholder_list[] = "?";
}
Expand All @@ -170,7 +170,7 @@ private function storeThisObjectsPrimaryKey($dbh)
$pdo_client_version = $dbh->getAttribute(SDO_DAS_Relational_PDO_ATTR_CLIENT_VERSION);
if (substr($pdo_client_version, 0, 4) == 'ODBC') {
// looks like DB2
foreach($dbh->query('values identity_val_local()') as $row) {
foreach ($dbh->query('values identity_val_local()') as $row) {
$last_insert_id = $row[1];
}
} else {
Expand Down
Loading

0 comments on commit 6e41850

Please sign in to comment.