Skip to content

Commit

Permalink
MDL-32003 more xmldb phpdocs and PHP4-ism cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
skodak committed Jun 17, 2012
1 parent 85d6dd3 commit aaddfac
Show file tree
Hide file tree
Showing 7 changed files with 177 additions and 181 deletions.
51 changes: 26 additions & 25 deletions lib/xmldb/xmldb_field.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class xmldb_field extends xmldb_object {
* @param mixed $default meaningful default o null (or false)
* @param xmldb_object $previous
*/
function __construct($name, $type=null, $precision=null, $unsigned=null, $notnull=null, $sequence=null, $default=null, $previous=null) {
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->notnull = false;
Expand All @@ -114,7 +114,7 @@ function __construct($name, $type=null, $precision=null, $unsigned=null, $notnul
* @param mixed $default meaningful default o null (or false)
* @param xmldb_object $previous
*/
function set_attributes($type, $precision=null, $unsigned=null, $notnull=null, $sequence=null, $default=null, $previous=null) {
public function set_attributes($type, $precision=null, $unsigned=null, $notnull=null, $sequence=null, $default=null, $previous=null) {
$this->type = $type;
/// Try to split the precision into length and decimals and apply
/// each one as needed
Expand Down Expand Up @@ -142,31 +142,31 @@ function set_attributes($type, $precision=null, $unsigned=null, $notnull=null, $
* Get the type
* @return int
*/
function getType() {
public function getType() {
return $this->type;
}

/**
* Get the length
* @return int
*/
function getLength() {
public function getLength() {
return $this->length;
}

/**
* Get the decimals
* @return string
*/
function getDecimals() {
public function getDecimals() {
return $this->decimals;
}

/**
* Get the notnull
* @return bool
*/
function getNotNull() {
public function getNotNull() {
return $this->notnull;
}

Expand All @@ -175,47 +175,47 @@ function getNotNull() {
* @deprecated since moodle 2.3
* @return bool
*/
function getUnsigned() {
public function getUnsigned() {
return false;
}

/**
* Get the sequence
* @return bool
*/
function getSequence() {
public function getSequence() {
return $this->sequence;
}

/**
* Get the default
* @return mixed
*/
function getDefault() {
public function getDefault() {
return $this->default;
}

/**
* Set the field type
* @param int $type
*/
function setType($type) {
public function setType($type) {
$this->type = $type;
}

/**
* Set the field length
* @param int $length
*/
function setLength($length) {
public function setLength($length) {
$this->length = $length;
}

/**
* Set the field decimals
* @param string
*/
function setDecimals($decimals) {
public function setDecimals($decimals) {
$this->decimals = $decimals;
}

Expand All @@ -224,30 +224,30 @@ function setDecimals($decimals) {
* @deprecated since moodle 2.3
* @param bool $unsigned
*/
function setUnsigned($unsigned=true) {
public function setUnsigned($unsigned=true) {
}

/**
* Set the field notnull
* @param bool $notnull
*/
function setNotNull($notnull=true) {
public function setNotNull($notnull=true) {
$this->notnull = $notnull;
}

/**
* Set the field sequence
* @param bool $sequence
*/
function setSequence($sequence=true) {
public function setSequence($sequence=true) {
$this->sequence = $sequence;
}

/**
* Set the field default
* @param mixed $default
*/
function setDefault($default) {
public function setDefault($default) {
// Check, warn and auto-fix '' (empty) defaults for CHAR NOT NULL columns, changing them
// to NULL so XMLDB will apply the proper default
if ($this->type == XMLDB_TYPE_CHAR && $this->notnull && $default === '') {
Expand All @@ -267,8 +267,9 @@ function setDefault($default) {
/**
* Load data from XML to the table
* @param array $xmlarr
* @return mixed
*/
function arr2xmldb_field($xmlarr) {
public function arr2xmldb_field($xmlarr) {

$result = true;

Expand Down Expand Up @@ -415,7 +416,7 @@ function arr2xmldb_field($xmlarr) {
* @param string $type
* @return int
*/
function getXMLDBFieldType($type) {
public function getXMLDBFieldType($type) {

$result = XMLDB_TYPE_INCORRECT;

Expand Down Expand Up @@ -452,7 +453,7 @@ function getXMLDBFieldType($type) {
* @param int $type
* @return string
*/
function getXMLDBTypeName($type) {
public function getXMLDBTypeName($type) {

$result = "";

Expand Down Expand Up @@ -488,7 +489,7 @@ function getXMLDBTypeName($type) {
* @param bool $recursive
* @return void, modifies $this->hash
*/
function calculateHash($recursive = false) {
public function calculateHash($recursive = false) {
if (!$this->loaded) {
$this->hash = NULL;
} else {
Expand All @@ -503,7 +504,7 @@ function calculateHash($recursive = false) {
* This function will output the XML text for one field
* @return string
*/
function xmlOutput() {
public function xmlOutput() {
$o = '';
$o.= ' <FIELD NAME="' . $this->name . '"';
$o.= ' TYPE="' . $this->getXMLDBTypeName($this->type) . '"';
Expand Down Expand Up @@ -548,7 +549,7 @@ function xmlOutput() {
* @param string $adofield
* @return void, sets $this->type
*/
function setFromADOField($adofield) {
public function setFromADOField($adofield) {

// Calculate the XMLDB_TYPE
switch (strtolower($adofield->type)) {
Expand Down Expand Up @@ -636,7 +637,7 @@ function setFromADOField($adofield) {
* @param bool $includeprevious
* @return string
*/
function getPHP($includeprevious=true) {
public function getPHP($includeprevious=true) {

$result = '';

Expand Down Expand Up @@ -719,7 +720,7 @@ function getPHP($includeprevious=true) {
* Shows info in a readable format
* @return string
*/
function readableInfo() {
public function readableInfo() {
$o = '';
// type
$o .= $this->getXMLDBTypeName($this->type);
Expand Down Expand Up @@ -770,7 +771,7 @@ function readableInfo() {
* @param xmldb_table $xmldb_table optional when object is table
* @return string null if ok, error message if problem found
*/
function validateDefinition(xmldb_table $xmldb_table=null) {
public function validateDefinition(xmldb_table $xmldb_table=null) {
if (!$xmldb_table) {
return 'Invalid xmldb_field->validateDefinition() call, $xmldb_table is required.';
}
Expand Down
20 changes: 10 additions & 10 deletions lib/xmldb/xmldb_file.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class xmldb_file extends xmldb_object {
* Constructor of the xmldb_file
* @param string $path
*/
function __construct($path) {
public function __construct($path) {
parent::__construct($path);
$this->path = $path;
$this->xmldb_structure = NULL;
Expand All @@ -54,7 +54,7 @@ function __construct($path) {
* Determine if the XML file exists
* @return bool
*/
function fileExists() {
public function fileExists() {
if (file_exists($this->path) && is_readable($this->path)) {
return true;
}
Expand All @@ -65,14 +65,14 @@ function fileExists() {
* Determine if the XML is writeable
* @return bool
*/
function fileWriteable() {
public function fileWriteable() {
if (is_writeable(dirname($this->path))) {
return true;
}
return false;
}

function getStructure() {
public function getStructure() {
return $this->xmldb_structure;
}

Expand All @@ -82,7 +82,7 @@ function getStructure() {
* (expat syntax checker or DOM schema validator
* @return true
*/
function validateXMLStructure() {
public function validateXMLStructure() {

// Create and load XML file
$parser = new DOMDocument();
Expand Down Expand Up @@ -134,7 +134,7 @@ function validateXMLStructure() {
* Load and the XMLDB structure from file
* @return true
*/
function loadXMLStructure() {
public function loadXMLStructure() {
if ($this->fileExists()) {
// Let's validate the XML file
if (!$this->validateXMLStructure()) {
Expand Down Expand Up @@ -167,7 +167,7 @@ function loadXMLStructure() {
* @param array $xmlarr
* @return xmldb_structure
*/
function arr2xmldb_structure ($xmlarr) {
public function arr2xmldb_structure ($xmlarr) {
$structure = new xmldb_structure($this->path);
$structure->arr2xmldb_structure($xmlarr);
return $structure;
Expand All @@ -177,23 +177,23 @@ function arr2xmldb_structure ($xmlarr) {
* This function sets the DTD of the XML file
* @param string
*/
function setDTD($path) {
public function setDTD($path) {
$this->dtd = $path;
}

/**
* This function sets the schema of the XML file
* @param string
*/
function setSchema($path) {
public function setSchema($path) {
$this->schema = $path;
}

/**
* This function saves the whole xmldb_structure to its file
* @return int|bool false on failure, number of written bytes on success
*/
function saveXMLFile() {
public function saveXMLFile() {

$structure = $this->getStructure();

Expand Down
Loading

0 comments on commit aaddfac

Please sign in to comment.