Merge pull request #275 from halkyon/e_strict_support

First round of fixes for E_STRICT compliance
This commit is contained in:
Ingo Schommer 2012-03-28 02:42:26 -07:00
commit f0ee711f52
31 changed files with 93 additions and 85 deletions

View File

@ -322,7 +322,7 @@ class LeftAndMain extends Controller implements PermissionProvider {
SSViewer::set_theme(null);
}
function handleRequest($request, DataModel $model) {
function handleRequest(SS_HTTPRequest $request, DataModel $model = null) {
$title = $this->Title();
$response = parent::handleRequest($request, $model);

View File

@ -113,7 +113,7 @@ abstract class ModelAdmin extends LeftAndMain {
Requirements::javascript(SAPPHIRE_ADMIN_DIR . '/javascript/ModelAdmin.js');
}
function getEditForm($id = null) {
function getEditForm($id = null, $fields = null) {
$list = $this->getList();
$exportButton = new GridFieldExportButton();
$exportButton->setExportColumns($this->getExportFields());

View File

@ -85,4 +85,4 @@ class SS_ClassLoader {
return class_exists($class, false) || $this->getManifest()->getItemPath($class);
}
}
}

View File

@ -319,7 +319,7 @@ class File extends DataObject {
* Returns the fields to power the edit screen of files in the CMS
* @return FieldList
*/
function getCMSFields() {
function getCMSFields($params = null) {
// Preview
if($this instanceof Image) {
$formattedImage = $this->getFormattedImage('SetWidth', Image::$asset_preview_width);
@ -816,8 +816,8 @@ class File extends DataObject {
}
}
public function flushCache() {
parent::flushCache();
public function flushCache($persistant = true) {
parent::flushCache($persistant);
self::$cache_file_fields = null;
}

View File

@ -406,7 +406,7 @@ class Folder extends File {
* You can modify this FieldList by subclassing folder, or by creating a {@link DataExtension}
* and implemeting updateCMSFields(FieldList $fields) on that extension.
*/
function getCMSFields() {
function getCMSFields($param = null) {
// Hide field on root level, which can't be renamed
if(!$this->ID || $this->ID === "root") {
$titleField = new HiddenField("Name");

View File

@ -343,7 +343,7 @@ class TreeDropdownField extends FormField {
class TreeDropdownField_Readonly extends TreeDropdownField {
protected $readonly = true;
function Field() {
function Field($properties = array()) {
$fieldName = $this->labelField;
if($this->value) {
$keyObj = $this->objectForKey($this->value);
@ -361,4 +361,4 @@ class TreeDropdownField_Readonly extends TreeDropdownField {
$field->setForm($this->form);
return $field->Field();
}
}
}

View File

@ -90,7 +90,7 @@ class Aggregate extends ViewableData {
* This gets the aggregate function
*
*/
public function XML_val($name, $args) {
public function XML_val($name, $args = null, $cache = false) {
$func = strtoupper( strpos($name, 'get') === 0 ? substr($name, 3) : $name );
$attribute = $args ? $args[0] : 'ID';

View File

@ -131,7 +131,7 @@ abstract class DataExtension extends Extension {
* @return array Returns a map where the keys are db, has_one, etc, and
* the values are additional fields/relations to be defined.
*/
function extraStatics($class=null, $extension=null) {
function extraStatics($class = null, $extension = null) {
return array();
}

View File

@ -2654,7 +2654,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
* When false will just clear session-local cached data
*
*/
public function flushCache($persistant=true) {
public function flushCache($persistant = true) {
if($persistant) Aggregate::flushCache($this->class);
if($this->class == 'DataObject') {
@ -3342,4 +3342,4 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
}
}
}
}

View File

@ -674,12 +674,12 @@ class Hierarchy extends DataExtension {
self::$expanded = array();
self::$treeOpened = array();
}
function reset() {
public static function reset() {
self::$marked = array();
self::$expanded = array();
self::$treeOpened = array();
}
}

View File

@ -73,8 +73,8 @@ class Image extends File {
parent::defineMethods();
}
function getCMSFields() {
$fields = parent::getCMSFields();
function getCMSFields($params = null) {
$fields = parent::getCMSFields($params);
$urlLink = "<div class='field readonly'>";
$urlLink .= "<label class='left'>"._t('AssetTableField.URL','URL')."</label>";

View File

@ -554,7 +554,7 @@ class SQLQuery {
* Return the number of rows in this query if the limit were removed. Useful in paged data sets.
* @return int
*/
function unlimitedRowCount( $column = null) {
function unlimitedRowCount($column = null) {
// we can't clear the select if we're relying on its output by a HAVING clause
if(count($this->having)) {
$records = $this->execute();

View File

@ -132,7 +132,7 @@ class Versioned extends DataExtension {
* Augment the the SQLQuery that is created by the DataQuery
* @todo Should this all go into VersionedDataQuery?
*/
function augmentSQL(SQLQuery &$query, DataQuery &$dataQuery) {
function augmentSQL(SQLQuery &$query, DataQuery &$dataQuery = null) {
$baseTable = ClassInfo::baseDataClass($dataQuery->dataClass());
switch($dataQuery->getQueryParam('Versioned.mode')) {

View File

@ -41,7 +41,7 @@ class Currency extends Decimal {
else return $val;
}
function setValue($value) {
function setValue($value, $record = null) {
$matches = null;
if(is_numeric($value)) {
$this->value = $value;

View File

@ -20,7 +20,7 @@
*/
class Date extends DBField {
function setValue($value) {
function setValue($value, $record = null) {
if($value === false || $value === null || (is_string($value) && !strlen($value))) {
// don't try to evaluate empty values with strtotime() below, as it returns "1970-01-01" when it should be saved as NULL in database
$this->value = null;

View File

@ -25,7 +25,7 @@
*/
class SS_Datetime extends Date {
function setValue($value) {
function setValue($value, $record = null) {
if($value === false || $value === null || (is_string($value) && !strlen($value))) {
// don't try to evaluate empty values with strtotime() below, as it returns "1970-01-01" when it should be saved as NULL in database
$this->value = null;

View File

@ -136,7 +136,7 @@ class HTMLText extends Text {
return new HtmlEditorField($this->name, $title);
}
public function scaffoldSearchField($title = null) {
public function scaffoldSearchField($title = null, $params = null) {
return new TextField($this->name, $title);
}

View File

@ -37,9 +37,8 @@ abstract class Authenticator extends Object {
* @return bool|Member Returns FALSE if authentication fails, otherwise
* the member object
*/
public abstract static function authenticate($RAW_data,
Form $form = null);
public static function authenticate($RAW_data, Form $form = null) {
}
/**
* Method that creates the login form for this authentication method
@ -49,7 +48,8 @@ abstract class Authenticator extends Object {
* @return Form Returns the login form to use with this authentication
* method
*/
public abstract static function get_login_form(Controller $controller);
public static function get_login_form(Controller $controller) {
}
/**
@ -57,7 +57,8 @@ abstract class Authenticator extends Object {
*
* @return string Returns the name of the authentication method.
*/
public abstract static function get_name();
public static function get_name() {
}
public static function register($authenticator) {
self::register_authenticator($authenticator);

View File

@ -59,7 +59,7 @@ class Group extends DataObject {
*
* @return FieldList
*/
public function getCMSFields() {
public function getCMSFields($params = null) {
Requirements::javascript(SAPPHIRE_DIR . '/javascript/PermissionCheckboxSetField.js');
$fields = new FieldList(

View File

@ -1084,7 +1084,7 @@ class Member extends DataObject implements TemplateGlobalProvider {
* @return FieldList Return a FieldList of fields that would appropriate for
* editing this member.
*/
public function getCMSFields() {
public function getCMSFields($params = null) {
require_once('Zend/Date.php');
$fields = parent::getCMSFields();

View File

@ -33,8 +33,8 @@ class PermissionRole extends DataObject {
static $plural_name = 'Roles';
function getCMSFields() {
$fields = parent::getCMSFields();
function getCMSFields($params = null) {
$fields = parent::getCMSFields($params);
$fields->removeFieldFromTab('Root', 'Codes');
$fields->removeFieldFromTab('Root', 'Groups');

View File

@ -329,7 +329,7 @@ class RequestHandlingTest_Controller extends Controller implements TestOnly {
$this->httpError(404, 'This page does not exist.');
}
public function getViewer(){
public function getViewer($action) {
return new SSViewer('BlankPage');
}
}
@ -384,7 +384,7 @@ class RequestHandlingTest_FormActionController extends Controller {
return 'formactionInAllowedActions';
}
public function getViewer(){
public function getViewer($action = null) {
return new SSViewer('BlankPage');
}

View File

@ -128,11 +128,13 @@ class FormScaffolderTest_ArticleExtension extends DataExtension implements TestO
static $db = array(
'ExtendedField' => 'Varchar'
);
function updateCMSFields(&$fields) {
function updateCMSFields(FieldList $fields) {
$fields->addFieldToTab('Root.Main',
new TextField('AddedExtensionField')
);
}
}
DataObject::add_extension('FormScaffolderTest_Article', 'FormScaffolderTest_ArticleExtension');

View File

@ -468,7 +468,7 @@ class FormTest_Controller extends Controller implements TestOnly {
return $this->redirectBack();
}
function getViewer(){
function getViewer($action = null) {
return new SSViewer('BlankPage');
}
@ -505,7 +505,7 @@ class FormTest_ControllerWithSecurityToken extends Controller implements TestOnl
return $this->redirectBack();
}
function getViewer(){
function getViewer($action = null) {
return new SSViewer('BlankPage');
}
}

View File

@ -140,8 +140,8 @@ class GridFieldDetailFormTest_Person extends DataObject implements TestOnly {
'Categories' => 'GridFieldDetailFormTest_Category'
);
function getCMSFields() {
$fields = parent::getCMSFields();
function getCMSFields($params = null) {
$fields = parent::getCMSFields($params);
// TODO No longer necessary once FormScaffolder uses GridField
$fields->replaceField('Categories',
Object::create('GridField', 'Categories', 'Categories',
@ -162,8 +162,8 @@ class GridFieldDetailFormTest_PeopleGroup extends DataObject implements TestOnly
'People' => 'GridFieldDetailFormTest_Person'
);
function getCMSFields() {
$fields = parent::getCMSFields();
function getCMSFields($params = null) {
$fields = parent::getCMSFields($params);
// TODO No longer necessary once FormScaffolder uses GridField
$fields->replaceField('People',
Object::create('GridField', 'People', 'People',
@ -184,8 +184,8 @@ class GridFieldDetailFormTest_Category extends DataObject implements TestOnly {
'People' => 'GridFieldDetailFormTest_Person'
);
function getCMSFields() {
$fields = parent::getCMSFields();
function getCMSFields($params = null) {
$fields = parent::getCMSFields($params);
// TODO No longer necessary once FormScaffolder uses GridField
$fields->replaceField('People',
Object::create('GridField', 'People', 'People',

View File

@ -567,21 +567,21 @@ static $many_many = array(
class UploadFieldTest_FileExtension extends DataExtension implements TestOnly {
function extraStatics() {
function extraStatics($class = null, $extension = null) {
return array(
'has_one' => array('Record' => 'UploadFieldTest_Record')
);
}
function canDelete() {
function canDelete($member = null) {
if($this->owner->Name == 'nodelete.txt') return false;
}
function canEdit() {
function canEdit($member = null) {
if($this->owner->Name == 'noedit.txt') return false;
}
function canView() {
function canView($member = null) {
if($this->owner->Name == 'noview.txt') return false;
}
}
@ -655,4 +655,4 @@ class UploadFieldTest_Controller extends Controller implements TestOnly {
}
}
}

View File

@ -73,13 +73,15 @@ class AggregateTest extends SapphireTest {
* Test basic aggregation on a passed type
*/
function testTypeSpecifiedAggregate() {
$foo = $this->objFromFixture('AggregateTest_Foo', 'foo1');
// Template style access
$this->assertEquals(DataObject::Aggregate('AggregateTest_Foo')->XML_val('Max', array('Foo')), 9);
$this->assertEquals(DataObject::Aggregate('AggregateTest_Fab')->XML_val('Max', array('Fab')), 3);
$this->assertEquals($foo->Aggregate('AggregateTest_Foo')->XML_val('Max', array('Foo')), 9);
$this->assertEquals($foo->Aggregate('AggregateTest_Fab')->XML_val('Max', array('Fab')), 3);
// PHP style access
$this->assertEquals(DataObject::Aggregate('AggregateTest_Foo')->Max('Foo'), 9);
$this->assertEquals(DataObject::Aggregate('AggregateTest_Fab')->Max('Fab'), 3);
$this->assertEquals($foo->Aggregate('AggregateTest_Foo')->Max('Foo'), 9);
$this->assertEquals($foo->Aggregate('AggregateTest_Fab')->Max('Fab'), 3);
}
/* */
@ -90,7 +92,7 @@ class AggregateTest extends SapphireTest {
function testAutoTypeAggregate() {
$foo = $this->objFromFixture('AggregateTest_Foo', 'foo1');
$fab = $this->objFromFixture('AggregateTest_Fab', 'fab1');
// Template style access
$this->assertEquals($foo->Aggregate()->XML_val('Max', array('Foo')), 9);
$this->assertEquals($fab->Aggregate()->XML_val('Max', array('Fab')), 3);
@ -106,13 +108,15 @@ class AggregateTest extends SapphireTest {
* @return unknown_type
*/
function testBaseFieldAggregate() {
$foo = $this->objFromFixture('AggregateTest_Foo', 'foo1');
$this->assertEquals(
$this->formatDate(DataObject::Aggregate('AggregateTest_Foo')->Max('LastEdited')),
$this->formatDate($foo->Aggregate('AggregateTest_Foo')->Max('LastEdited')),
$this->formatDate(DataObject::get_one('AggregateTest_Foo', '', '', '"LastEdited" DESC')->LastEdited)
);
$this->assertEquals(
$this->formatDate(DataObject::Aggregate('AggregateTest_Foo')->Max('Created')),
$this->formatDate($foo->Aggregate('AggregateTest_Foo')->Max('Created')),
$this->formatDate(DataObject::get_one('AggregateTest_Foo', '', '', '"Created" DESC')->Created)
);
}
@ -122,13 +126,14 @@ class AggregateTest extends SapphireTest {
* Test aggregation takes place on the passed type & it's children only
*/
function testChildAggregate() {
$foo = $this->objFromFixture('AggregateTest_Foo', 'foo1');
// For base classes, aggregate is calculcated on it and all children classes
$this->assertEquals(DataObject::Aggregate('AggregateTest_Foo')->Max('Foo'), 9);
$this->assertEquals($foo->Aggregate('AggregateTest_Foo')->Max('Foo'), 9);
// For subclasses, aggregate is calculated for that subclass and it's children only
$this->assertEquals(DataObject::Aggregate('AggregateTest_Fab')->Max('Foo'), 9);
$this->assertEquals(DataObject::Aggregate('AggregateTest_Fac')->Max('Foo'), 6);
$this->assertEquals($foo->Aggregate('AggregateTest_Fab')->Max('Foo'), 9);
$this->assertEquals($foo->Aggregate('AggregateTest_Fac')->Max('Foo'), 6);
}
/* */
@ -145,35 +150,35 @@ class AggregateTest extends SapphireTest {
* Test cache is correctly flushed on write
*/
function testCacheFlushing() {
$foo = $this->objFromFixture('AggregateTest_Foo', 'foo1');
$fab = $this->objFromFixture('AggregateTest_Fab', 'fab1');
// For base classes, aggregate is calculcated on it and all children classes
$this->assertEquals(DataObject::Aggregate('AggregateTest_Foo')->Max('Foo'), 9);
$this->assertEquals($fab->Aggregate('AggregateTest_Foo')->Max('Foo'), 9);
// For subclasses, aggregate is calculated for that subclass and it's children only
$this->assertEquals(DataObject::Aggregate('AggregateTest_Fab')->Max('Foo'), 9);
$this->assertEquals(DataObject::Aggregate('AggregateTest_Fac')->Max('Foo'), 6);
$foo = $this->objFromFixture('AggregateTest_Foo', 'foo1');
$this->assertEquals($fab->Aggregate('AggregateTest_Fab')->Max('Foo'), 9);
$this->assertEquals($fab->Aggregate('AggregateTest_Fac')->Max('Foo'), 6);
$foo->Foo = 12;
$foo->write();
// For base classes, aggregate is calculcated on it and all children classes
$this->assertEquals(DataObject::Aggregate('AggregateTest_Foo')->Max('Foo'), 12);
$this->assertEquals($fab->Aggregate('AggregateTest_Foo')->Max('Foo'), 12);
// For subclasses, aggregate is calculated for that subclass and it's children only
$this->assertEquals(DataObject::Aggregate('AggregateTest_Fab')->Max('Foo'), 9);
$this->assertEquals(DataObject::Aggregate('AggregateTest_Fac')->Max('Foo'), 6);
$this->assertEquals($fab->Aggregate('AggregateTest_Fab')->Max('Foo'), 9);
$this->assertEquals($fab->Aggregate('AggregateTest_Fac')->Max('Foo'), 6);
$fab = $this->objFromFixture('AggregateTest_Fab', 'fab1');
$fab->Foo = 15;
$fab->write();
// For base classes, aggregate is calculcated on it and all children classes
$this->assertEquals(DataObject::Aggregate('AggregateTest_Foo')->Max('Foo'), 15);
$this->assertEquals($fab->Aggregate('AggregateTest_Foo')->Max('Foo'), 15);
// For subclasses, aggregate is calculated for that subclass and it's children only
$this->assertEquals(DataObject::Aggregate('AggregateTest_Fab')->Max('Foo'), 15);
$this->assertEquals(DataObject::Aggregate('AggregateTest_Fac')->Max('Foo'), 6);
$this->assertEquals($fab->Aggregate('AggregateTest_Fab')->Max('Foo'), 15);
$this->assertEquals($fab->Aggregate('AggregateTest_Fac')->Max('Foo'), 6);
}
/* */

View File

@ -62,8 +62,8 @@ class DataDifferencerTest_Object extends DataObject implements TestOnly {
'HasOneRelation' => 'DataDifferencerTest_HasOneRelationObject'
);
function getCMSFields() {
$fields = parent::getCMSFields();
function getCMSFields($params = null) {
$fields = parent::getCMSFields($params);
$choices = array(
'a' => 'a',
'b' => 'b',
@ -103,4 +103,4 @@ class DataDifferencerTest_MockImage extends Image implements TestOnly {
// Skip aktual generation
return $gd;
}
}
}

View File

@ -132,7 +132,7 @@ class GroupTest extends FunctionalTest {
class GroupTest_Member extends Member implements TestOnly {
function getCMSFields() {
function getCMSFields($params = null) {
$groups = DataObject::get('Group');
$groupsMap = ($groups) ? $groups->map() : false;
$fields = new FieldList(

View File

@ -591,29 +591,29 @@ class MemberTest extends FunctionalTest {
}
class MemberTest_ViewingAllowedExtension extends DataExtension implements TestOnly {
public function canView() {
public function canView($member = null) {
return true;
}
}
class MemberTest_ViewingDeniedExtension extends DataExtension implements TestOnly {
public function canView() {
public function canView($member = null) {
return false;
}
}
class MemberTest_EditingAllowedDeletingDeniedExtension extends DataExtension implements TestOnly {
public function canView() {
public function canView($member = null) {
return true;
}
public function canEdit() {
public function canEdit($member = null) {
return true;
}
public function canDelete() {
public function canDelete($member = null) {
return false;
}

View File

@ -930,7 +930,7 @@ class SSViewerTestFixture extends ViewableData {
}
function XML_val($fieldName, $arguments = null) {
function XML_val($fieldName, $arguments = null, $cache = false) {
if(preg_match('/NotSet/i', $fieldName)) {
return '';
} else if(preg_match('/Raw/i', $fieldName)) {
@ -940,7 +940,7 @@ class SSViewerTestFixture extends ViewableData {
}
}
function hasValue($fieldName, $arguments = null) {
function hasValue($fieldName, $arguments = null, $cache = true) {
return (bool)$this->XML_val($fieldName, $arguments);
}
}
@ -1021,4 +1021,4 @@ class SSViewerTest_GlobalProvider implements TemplateGlobalProvider, TestOnly {
return 'z' . implode(':', $args) . 'z';
}
}
}