Skip to content
Permalink
Browse files

BUG Fix missing use statements

BUG Fix incorrect method visibility on SS_Database
BUG Fix obvious PHPDoc errors in SilverStripe\ORM\FieldType
BUG Fix incorrect case on some method invocations
API Remove some deprecated code
  • Loading branch information
Damian Mooyman
Damian Mooyman committed Jul 1, 2016
1 parent 80d4af6 commit efef0250277b83484536546763931c6646cb852d
@@ -46,7 +46,7 @@ abstract class DBSchemaManager {
/**
* Injector injection point for database controller
*
* @param SS_Database $connector
* @param SS_Database $database
*/
public function setDatabase(SS_Database $database) {
$this->database = $database;
@@ -127,6 +127,7 @@ public function schemaUpdate($callback) {
// Clear update list for client code to mess around with
$this->schemaUpdateTransaction = array();
/** @var Exception $error */
$error = null;
try {
@@ -302,8 +303,8 @@ protected function transInitTable($table) {
* - array('fields' => array('A','B','C'), 'type' => 'index/unique/fulltext'): This gives you full
* control over the index.
* @param boolean $hasAutoIncPK A flag indicating that the primary key on this table is an autoincrement type
* @param string $options SQL statement to append to the CREATE TABLE call.
* @param array $extensions List of extensions
* @param string|array $options SQL statement to append to the CREATE TABLE call.
* @param array|bool $extensions List of extensions
*/
public function requireTable($table, $fieldSchema = null, $indexSchema = null, $hasAutoIncPK = true,
$options = array(), $extensions = false
@@ -539,6 +540,7 @@ protected function parseIndexSpec($name, $spec) {
* @see parseIndexSpec() for approximate inverse
*
* @param string|array $indexSpec
* @return string
*/
protected function convertIndexSpec($indexSpec) {
// Return already converted spec
@@ -551,7 +553,7 @@ protected function convertIndexSpec($indexSpec) {
/**
* Returns true if the given table is exists in the current database
*
* @param string $table Name of table to check
* @param string $tableName Name of table to check
* @return boolean Flag indicating existence of table
*/
abstract public function hasTable($tableName);
@@ -879,7 +881,7 @@ public function alterationMessage($message, $type = "") {
* @param array $options An map of additional options. The available keys are as follows:
* - 'MSSQLDatabase'/'MySQLDatabase'/'PostgreSQLDatabase' - database-specific options such as "engine" for MySQL.
* - 'temporary' - If true, then a temporary table will be created
* @param $advancedOptions Advanced creation options
* @param array $advancedOptions Advanced creation options
* @return string The table name generated. This may be different from the table name, for example with temporary
* tables.
*/
@@ -940,8 +942,7 @@ public function alterationMessage($message, $type = "") {
* This allows the cached values for a table's field list to be erased.
* If $tablename is empty, then the whole cache is erased.
*
* @param string $tableName
*
* @param string|bool $tableName
* @return boolean
*/
public function clearCachedFieldlist($tableName = false) {
@@ -26,10 +26,10 @@ abstract class SS_Database {
* @var DBConnector
*/
protected $connector = null;
/**
* Amount of queries executed, for debugging purposes.
*
*
* @var int
*/
protected $queryCount = 0;
@@ -560,7 +560,7 @@ public function withTransaction(
* @return boolean Flag indicating support for all of the above
* @todo Write test cases
*/
protected function supportsExtensions($extensions) {
public function supportsExtensions($extensions) {
return false;
}
@@ -9,6 +9,7 @@
use LogicException;
use Cookie;
use Injector;
use SilverStripe\ORM\Connect\DBSchemaManager;
use SilverStripe\ORM\Queries\SQLExpression;
use SilverStripe\ORM\Connect\SS_Database;
@@ -5,6 +5,7 @@
use Object;
use SilverStripe\ORM\DataObject;
use SilverStripe\ORM\DB;
use SilverStripe\ORM\Queries\SQLSelect;
/**
@@ -127,7 +128,7 @@ public function exists() {
public function requireField() {
foreach($this->compositeDatabaseFields() as $field => $spec){
$key = $this->getName() . $field;
DB::requireField($this->tableName, $key, $spec);
DB::require_field($this->tableName, $key, $spec);
}
}
@@ -239,7 +240,8 @@ public function setField($field, $value, $markChanged = true) {
// Set bound object
if($this->record instanceof DataObject) {
$key = $this->getName() . $field;
return $this->record->setField($key, $value);
$this->record->setField($key, $value);
return;
}
// Set local record
@@ -272,8 +274,7 @@ public function castingHelper($field) {
return $fields[$field];
}
parent::castingHelper($field);
return parent::castingHelper($field);
}
}
@@ -2,8 +2,6 @@
namespace SilverStripe\ORM\FieldType;
use Deprecation;
/**
* Represents a decimal field containing a currency amount.
* The currency class only supports single currencies. For multi-currency support, use {@link Money}
@@ -63,15 +61,5 @@ public function setValue($value, $record = null, $markChanged = true) {
$this->value = 0;
}
}
/**
* @deprecated 4.0 Use the "Currency.currency_symbol" config setting instead
* @param [type] $value [description]
*/
public static function setCurrencySymbol($value) {
Deprecation::notice('4.0', 'Use the "Currency.currency_symbol" config setting instead');
DBCurrency::config()->currency_symbol = $value;
}
}
@@ -67,7 +67,7 @@ public function setValue($value, $record = null, $markChanged = true) {
} elseif(is_string($value)) {
try{
$date = new DateTime($value);
$this->value = $date->Format('Y-m-d');
$this->value = $date->format('Y-m-d');
return;
}catch(Exception $e){
$this->value = null;
@@ -120,7 +120,7 @@ public function ShortMonth() {
/**
* Returns the day of the month.
* @param boolean $includeOrdinals Include ordinal suffix to day, e.g. "th" or "rd"
* @param bool $includeOrdinal Include ordinal suffix to day, e.g. "th" or "rd"
* @return string
*/
public function DayOfMonth($includeOrdinal = false) {
@@ -154,7 +154,7 @@ public function Full() {
public function Format($format) {
if($this->value){
$date = new DateTime($this->value);
return $date->Format($format);
return $date->format($format);
}
}
@@ -163,6 +163,9 @@ public function Format($format) {
*
* strftime obeys the current LC_TIME/LC_ALL when printing lexical values
* like day- and month-names
*
* @param string $formattingString
* @return string
*/
public function FormatI18N($formattingString) {
if($this->value) {
@@ -192,10 +195,11 @@ public function FormatFromSettings($member = null) {
return $zendDate->toString($formatD);
}
/*
/**
* Return a string in the form "12 - 16 Sept" or "12 Aug - 16 Sept"
* @param Date $otherDateObj Another date object specifying the end of the range
* @param boolean $includeOrdinals Include ordinal suffix to day, e.g. "th" or "rd"
*
* @param DBDate $otherDateObj Another date object specifying the end of the range
* @param bool $includeOrdinals Include ordinal suffix to day, e.g. "th" or "rd"
* @return string
*/
public function RangeString($otherDateObj, $includeOrdinals = false) {
@@ -3,6 +3,7 @@
namespace SilverStripe\ORM\FieldType;
use Convert;
use Exception;
use Member;
use DatetimeField;
use Zend_Date;
@@ -59,12 +60,11 @@ public function setValue($value, $record = null, $markChanged = true) {
if(is_numeric($value)) {
$this->value = date('Y-m-d H:i:s', $value);
} elseif(is_string($value)) {
// $this->value = date('Y-m-d H:i:s', strtotime($value));
try{
try {
$date = new DateTime($value);
$this->value = $date->Format('Y-m-d H:i:s');
$this->value = $date->format('Y-m-d H:i:s');
return;
}catch(Exception $e){
} catch(Exception $e) {
$this->value = null;
return;
}
@@ -3,6 +3,7 @@
namespace SilverStripe\ORM\FieldType;
use NumericField;
use SilverStripe\ORM\DataObject;
use SilverStripe\ORM\DB;
/**
@@ -21,7 +22,7 @@ class DBDecimal extends DBField {
* @param string $name
* @param int $wholeSize
* @param int $decimalSize
* @param float $defaultValue
* @param float|int $defaultValue
*/
public function __construct($name = null, $wholeSize = 9, $decimalSize = 2, $defaultValue = 0) {
$this->wholeSize = is_int($wholeSize) ? $wholeSize : 9;
@@ -50,9 +50,10 @@ class DBEnum extends DBString {
* "MyField" => "Enum(array('Val1', 'Val2', 'Val3'), 'Val1')"
* </code>
*
* @param enum: A string containing a comma separated list of options or an
* @param string $name
* @param string|array $enum A string containing a comma separated list of options or an
* array of Vals.
* @param string The default option, which is either NULL or one of the
* @param string $default The default option, which is either NULL or one of the
* items in the enumeration.
*/
public function __construct($name = null, $enum = NULL, $default = NULL) {
@@ -2,6 +2,10 @@
namespace SilverStripe\ORM\FieldType;
use FormField;
use SearchFilter;
use SilverStripe\ORM\Connect\SS_Query;
use SilverStripe\ORM\DataObject;
use ViewableData;
use Convert;
use Object;
@@ -151,7 +155,7 @@ public function getValue() {
*
* @param mixed $value
* @param DataObject|array $record An array or object that this field is part of
* @param boolean $markChanged Indicate wether this field should be marked changed.
* @param bool $markChanged Indicate wether this field should be marked changed.
* Set to FALSE if you are initializing this field after construction, rather
* than setting a new value.
*/
@@ -348,6 +352,7 @@ public function scaffoldSearchField($title = null) {
* search filters (note: parameter hack now in place to pass in the required full path - using $this->name
* won't work)
*
* @param string|bool $name
* @return SearchFilter
*/
public function defaultSearchFilter($name = false) {
@@ -2,6 +2,8 @@
namespace SilverStripe\ORM\FieldType;
use File;
use Image;
use UploadField;
use DropdownField;
use NumericField;
@@ -2,6 +2,7 @@
namespace SilverStripe\ORM\FieldType;
use FormField;
use i18n;
use Zend_Currency;
use MoneyField;
@@ -75,6 +76,7 @@ public function Nice($options = array()) {
}
/**
* @param array $options
* @return string
*/
public function NiceWithShortname($options = array()){
@@ -83,6 +85,7 @@ public function NiceWithShortname($options = array()){
}
/**
* @param array $options
* @return string
*/
public function NiceWithName($options = array()){
@@ -98,7 +101,8 @@ public function getCurrency() {
}
/**
* @param string
* @param string $currency
* @param bool $markChanged
*/
public function setCurrency($currency, $markChanged = true) {
$this->setField('Currency', $currency, $markChanged);
@@ -113,6 +117,7 @@ public function getAmount() {
/**
* @param float $amount
* @param bool $markChanged
*/
public function setAmount($amount, $markChanged = true) {
$this->setField('Amount', (float)$amount, $markChanged);
@@ -149,6 +154,8 @@ public function getLocale() {
}
/**
* @param string $currency
* @param string $locale
* @return string
*/
public function getSymbol($currency = null, $locale = null) {
@@ -160,6 +167,8 @@ public function getSymbol($currency = null, $locale = null) {
}
/**
* @param string $currency
* @param string $locale
* @return string
*/
public function getShortName($currency = null, $locale = null) {
@@ -170,6 +179,8 @@ public function getShortName($currency = null, $locale = null) {
}
/**
* @param string $currency
* @param string $locale
* @return string
*/
public function getCurrencyName($currency = null, $locale = null) {
@@ -3,6 +3,7 @@
namespace SilverStripe\ORM\FieldType;
use CheckboxSetField;
use Config;
use SilverStripe\ORM\DB;
/**
@@ -31,6 +32,7 @@ public function __construct($name, $enum = NULL, $default = NULL) {
}
public function requireField(){
// @todo: Remove mysql-centric logic from this
$charset = Config::inst()->get('SilverStripe\ORM\Connect\MySQLDatabase', 'charset');
$collation = Config::inst()->get('SilverStripe\ORM\Connect\MySQLDatabase', 'collation');
$values=array(
@@ -20,6 +20,9 @@ class DBPercentage extends DBDecimal {
/**
* Create a new Decimal field.
*
* @param string $name
* @param int $precision
*/
public function __construct($name = null, $precision = 4) {
if(!$precision) $precision = 4;

0 comments on commit efef025

Please sign in to comment.
You can’t perform that action at this time.