Skip to content

Commit

Permalink
MDL-32003 standardise null case
Browse files Browse the repository at this point in the history
  • Loading branch information
skodak committed Jun 17, 2012
1 parent 2edc3fe commit 002252f
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 43 deletions.
20 changes: 10 additions & 10 deletions lib/xmldb/xmldb_field.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,12 @@ class xmldb_field extends xmldb_object {
* @param xmldb_object $previous
*/
public function __construct($name, $type=null, $precision=null, $unsigned=null, $notnull=null, $sequence=null, $default=null, $previous=null) {
$this->type = NULL;
$this->length = NULL;
$this->type = null;
$this->length = null;
$this->notnull = false;
$this->default = NULL;
$this->default = null;
$this->sequence = false;
$this->decimals = NULL;
$this->decimals = null;
parent::__construct($name);
$this->set_attributes($type, $precision, $unsigned, $notnull, $sequence, $default, $previous);
}
Expand Down Expand Up @@ -359,7 +359,7 @@ public function arr2xmldb_field($xmlarr) {
$this->setDefault(trim($xmlarr['@']['DEFAULT']));
}

$decimals = NULL;
$decimals = null;
if (isset($xmlarr['@']['DECIMALS'])) {
$decimals = trim($xmlarr['@']['DECIMALS']);
// Check for integer values
Expand Down Expand Up @@ -491,7 +491,7 @@ public function getXMLDBTypeName($type) {
*/
public function calculateHash($recursive = false) {
if (!$this->loaded) {
$this->hash = NULL;
$this->hash = null;
} else {
$key = $this->name . $this->type . $this->length .
$this->notnull . $this->sequence .
Expand All @@ -517,7 +517,7 @@ public function xmlOutput() {
$notnull = 'false';
}
$o.= ' NOTNULL="' . $notnull . '"';
if (!$this->sequence && $this->default !== NULL) {
if (!$this->sequence && $this->default !== null) {
$o.= ' DEFAULT="' . $this->default . '"';
}
if ($this->sequence) {
Expand All @@ -526,7 +526,7 @@ public function xmlOutput() {
$sequence = 'false';
}
$o.= ' SEQUENCE="' . $sequence . '"';
if ($this->decimals !== NULL) {
if ($this->decimals !== null) {
$o.= ' DECIMALS="' . $this->decimals . '"';
}
if ($this->comment) {
Expand Down Expand Up @@ -733,7 +733,7 @@ public function readableInfo() {
$o .= ' (' . $this->length;
if ($this->type == XMLDB_TYPE_NUMBER ||
$this->type == XMLDB_TYPE_FLOAT) {
if ($this->decimals !== NULL) {
if ($this->decimals !== null) {
$o .= ', ' . $this->decimals;
}
}
Expand All @@ -745,7 +745,7 @@ public function readableInfo() {
$o .= ' not null';
}
// default
if ($this->default !== NULL) {
if ($this->default !== null) {
$o .= ' default ';
if ($this->type == XMLDB_TYPE_CHAR ||
$this->type == XMLDB_TYPE_TEXT) {
Expand Down
2 changes: 1 addition & 1 deletion lib/xmldb/xmldb_file.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class xmldb_file extends xmldb_object {
public function __construct($path) {
parent::__construct($path);
$this->path = $path;
$this->xmldb_structure = NULL;
$this->xmldb_structure = null;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/xmldb/xmldb_index.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ public function arr2xmldb_index($xmlarr) {
*/
public function calculateHash($recursive = false) {
if (!$this->loaded) {
$this->hash = NULL;
$this->hash = null;
} else {
$key = $this->unique . implode (', ', $this->fields);
$this->hash = md5($key);
Expand Down
6 changes: 3 additions & 3 deletions lib/xmldb/xmldb_key.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ class xmldb_key extends xmldb_object {
* @param array $reffields an array of fieldnames in the FK table or null
*/
public function __construct($name, $type=null, $fields=array(), $reftable=null, $reffields=null) {
$this->type = NULL;
$this->type = null;
$this->fields = array();
$this->reftable = NULL;
$this->reftable = null;
$this->reffields = array();
parent::__construct($name);
$this->set_attributes($type, $fields, $reftable, $reffields);
Expand Down Expand Up @@ -355,7 +355,7 @@ public function getXMLDBKeyName($type) {
*/
public function calculateHash($recursive = false) {
if (!$this->loaded) {
$this->hash = NULL;
$this->hash = null;
} else {
$key = $this->type . implode(', ', $this->fields);
if ($this->type == XMLDB_KEY_FOREIGN ||
Expand Down
16 changes: 8 additions & 8 deletions lib/xmldb/xmldb_object.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,13 @@ class xmldb_object {
*/
public function __construct($name) {
$this->name = $name;
$this->comment = NULL;
$this->previous = NULL;
$this->next = NULL;
$this->hash = NULL;
$this->comment = null;
$this->previous = null;
$this->next = null;
$this->hash = null;
$this->loaded = false;
$this->changed = false;
$this->errormsg = NULL;
$this->errormsg = null;
}

/**
Expand Down Expand Up @@ -310,7 +310,7 @@ public function checkPreviousNextValues($arr) {
foreach($arr as $element) {
if ($element->getPrevious()) {
$i = $this->findObjectInArray($element->getPrevious(), $arr);
if ($i === NULL) {
if ($i === null) {
debugging('Object ' . $element->getName() . ' says PREVIOUS="' . $element->getPrevious() . '" but that other object does not exist.', DEBUG_DEVELOPER);
$result = false;
}
Expand All @@ -322,7 +322,7 @@ public function checkPreviousNextValues($arr) {
foreach($arr as $element) {
if ($element->getNext()) {
$i = $this->findObjectInArray($element->getNext(), $arr);
if ($i === NULL) {
if ($i === null) {
debugging('Object ' . $element->getName() . ' says NEXT="' . $element->getNext() . '" but that other object does not exist.', DEBUG_DEVELOPER);
$result = false;
}
Expand Down Expand Up @@ -389,7 +389,7 @@ public function orderElements($arr) {
// Create a new array
$newarr = array();
if (!empty($arr)) {
$currentelement = NULL;
$currentelement = null;
// Get the element without previous
foreach($arr as $key => $element) {
if (!$element->getPrevious()) {
Expand Down
14 changes: 7 additions & 7 deletions lib/xmldb/xmldb_structure.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ class xmldb_structure extends xmldb_object {
*/
public function __construct($name) {
parent::__construct($name);
$this->path = NULL;
$this->version = NULL;
$this->path = null;
$this->version = null;
$this->tables = array();
}

Expand All @@ -71,7 +71,7 @@ public function getVersion() {
*/
public function getTable($tablename) {
$i = $this->findTableInArray($tablename);
if ($i !== NULL) {
if ($i !== null) {
return $this->tables[$i];
}
return null;
Expand Down Expand Up @@ -127,11 +127,11 @@ public function setVersion($version) {
* @param xmldb_table $table
* @param mixed $after
*/
public function addTable($table, $after=NULL) {
public function addTable($table, $after=null) {

// Calculate the previous and next tables
$prevtable = NULL;
$nexttable = NULL;
$prevtable = null;
$nexttable = null;

if (!$after) {
if ($this->tables) {
Expand Down Expand Up @@ -307,7 +307,7 @@ public function arr2xmldb_structure($xmlarr) {
*/
public function calculateHash($recursive = false) {
if (!$this->loaded) {
$this->hash = NULL;
$this->hash = null;
} else {
$key = $this->name . $this->path . $this->comment;
if ($this->tables) {
Expand Down
26 changes: 13 additions & 13 deletions lib/xmldb/xmldb_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,16 @@ public function __construct($name) {
* @param xmldb_object $after
* @return xmldb_field
*/
public function addField($field, $after=NULL) {
public function addField($field, $after=null) {

// Detect duplicates first
if ($this->getField($field->getName())) {
throw new coding_exception('Duplicate field '.$field->getName().' specified in table '.$this->getName());
}

// Calculate the previous and next fields
$prevfield = NULL;
$nextfield = NULL;
$prevfield = null;
$nextfield = null;

if (!$after) {
$allfields = $this->getFields();
Expand Down Expand Up @@ -118,16 +118,16 @@ public function addField($field, $after=NULL) {
* @param xmldb_key $key
* @param xmldb_object $after
*/
public function addKey($key, $after=NULL) {
public function addKey($key, $after=null) {

// Detect duplicates first
if ($this->getKey($key->getName())) {
throw new coding_exception('Duplicate key '.$key->getName().' specified in table '.$this->getName());
}

// Calculate the previous and next keys
$prevkey = NULL;
$nextkey = NULL;
$prevkey = null;
$nextkey = null;

if (!$after) {
$allkeys = $this->getKeys();
Expand Down Expand Up @@ -170,16 +170,16 @@ public function addKey($key, $after=NULL) {
* @param xmldb_index $index
* @param xmldb_object $after
*/
public function addIndex($index, $after=NULL) {
public function addIndex($index, $after=null) {

// Detect duplicates first
if ($this->getIndex($index->getName())) {
throw new coding_exception('Duplicate index '.$index->getName().' specified in table '.$this->getName());
}

// Calculate the previous and next indexes
$previndex = NULL;
$nextindex = NULL;
$previndex = null;
$nextindex = null;

if (!$after) {
$allindexes = $this->getIndexes();
Expand Down Expand Up @@ -248,7 +248,7 @@ public function getIndexes() {
*/
public function getField($fieldname) {
$i = $this->findFieldInArray($fieldname);
if ($i !== NULL) {
if ($i !== null) {
return $this->fields[$i];
}
return null;
Expand Down Expand Up @@ -289,7 +289,7 @@ public function orderFields() {
*/
public function getKey($keyname) {
$i = $this->findKeyInArray($keyname);
if ($i !== NULL) {
if ($i !== null) {
return $this->keys[$i];
}
return null;
Expand Down Expand Up @@ -330,7 +330,7 @@ public function orderKeys() {
*/
public function getIndex($indexname) {
$i = $this->findIndexInArray($indexname);
if ($i !== NULL) {
if ($i !== null) {
return $this->indexes[$i];
}
return null;
Expand Down Expand Up @@ -668,7 +668,7 @@ public function arr2xmldb_table($xmlarr) {
*/
public function calculateHash($recursive = false) {
if (!$this->loaded) {
$this->hash = NULL;
$this->hash = null;
} else {
$key = $this->name . $this->comment;
if ($this->fields) {
Expand Down

0 comments on commit 002252f

Please sign in to comment.