Skip to content

Commit

Permalink
EZP-27804: Constructor refactoring (PHP4 to PHP5 __construct()) (#1233)
Browse files Browse the repository at this point in the history
* Removed empty constructors

* Added __construct() constructor for popular classes

… and marked the old style constructors as deprecated. This is done to not break third party extensions that don't call the parent constructor with parent::__construct()

* Removed constructors that just call the parent constructor

* Replaced PHP4 constructors and calls with PHP5 constructors

* Fix broken UTF-8 chars

* Rename forgotten PHP4 constructor

* Restory empty constructors
  • Loading branch information
jeromegamez authored and andrerom committed Sep 25, 2017
1 parent a4a0470 commit 4316b42
Show file tree
Hide file tree
Showing 452 changed files with 1,449 additions and 2,199 deletions.
7 changes: 2 additions & 5 deletions benchmarks/classes/ezbenchmark.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,9 @@

class eZBenchmark extends eZBenchmarkUnit
{
/*!
Initializes the benchmark with the name \a $name.
*/
function eZBenchmark( $name )
function __construct( $name = false )
{
$this->eZBenchmarkUnit( $name );
parent::__construct( $name );
}

function addMark( &$mark )
Expand Down
9 changes: 3 additions & 6 deletions benchmarks/classes/ezbenchmarkcase.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class MyTest extends eZBenchmarkCase
{
function MyTest()
{
$this->eZBenchmarkCase( 'My test case' );
parent::__construct( 'My test case' );
$this->addmark( 'markFunctionA', 'Addition mark' );
$this->addFunctionTest( 'MyFunctionMark', 'Addition mark 2' );
}
Expand All @@ -64,12 +64,9 @@ function MyFunctionMark( &$tr, $parameter )

class eZBenchmarkCase extends eZBenchmarkUnit
{
/*!
Constructor
*/
function eZBenchmarkCase( $name = false )
function __construct( $name = false )
{
$this->eZBenchmarkUnit( $name );
parent::__construct( $name );
}

function addMark( $method, $name, $parameter = false )
Expand Down
7 changes: 2 additions & 5 deletions benchmarks/classes/ezbenchmarkclirunner.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,9 @@

class eZBenchmarkCLIRunner extends eZBenchmarkRunner
{
/*!
Constructor
*/
function eZBenchmarkCLIRunner()
public function __construct()
{
$this->eZBenchmarkRunner();
parent::__construct();
$this->MaxMap = false;
}

Expand Down
8 changes: 4 additions & 4 deletions benchmarks/classes/ezbenchmarkrunner.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@

class eZBenchmarkrunner
{
/*!
Constructor
*/
function eZBenchmarkrunner()
/**
* Constructor
*/
public function __construct()
{
$this->Results = array();
$this->CurrentResult = false;
Expand Down
10 changes: 6 additions & 4 deletions benchmarks/classes/ezbenchmarkunit.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@

class eZBenchmarkUnit
{
/*!
Constructor
*/
function eZBenchmarkUnit( $name = false )
/**
* Initializes the benchmark
*
* @param bool|string $name
*/
function __construct( $name = false )
{
if ( !$name )
$name = get_class( $this );
Expand Down
7 changes: 2 additions & 5 deletions benchmarks/eztemplate/ezmarktemplatecompiler.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,9 @@

class eZMarkTemplateCompiler extends eZBenchmarkCase
{
/*!
Constructor
*/
function eZMarkTemplateCompiler( $name )
public function __construct( $name = false )
{
$this->eZBenchmarkCase( $name );
parent::__construct( $name );
$this->addMark( 'markProcess', 'Processed template mark' );
$this->addMark( 'markCompilation', 'Compiled template mark' );
}
Expand Down
7 changes: 2 additions & 5 deletions benchmarks/hashing/ezmarkhashing.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,9 @@

class eZMarkHashing extends eZBenchmarkCase
{
/*!
Constructor
*/
function eZMarkHashing( $name )
public function __construct( $name = false )
{
$this->eZBenchmarkCase( $name );
parent::__construct( $name );
$this->addMark( 'markMD5', 'MD5 hash', array( 'repeat_count' => 1000 ) );
$this->addMark( 'markCRC32', 'CRC32 hash', array( 'repeat_count' => 1000 ) );
}
Expand Down
4 changes: 0 additions & 4 deletions extension/ezjscore/autoloads/ezjscaccesstemplatefunctions.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,6 @@

class ezjscAccessTemplateFunctions
{
function ezjscAccessTemplateFunctions()
{
}

function operatorList()
{
return array( 'has_access_to_limitation' );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,6 @@

class ezjscEncodingTemplateFunctions
{
function ezjscEncodingTemplateFunctions()
{
}

function operatorList()
{
return array( 'json_encode',
Expand Down
4 changes: 0 additions & 4 deletions extension/ezjscore/autoloads/ezjscpackertemplatefunctions.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,6 @@

class ezjscPackerTemplateFunctions
{
function ezjscPackerTemplateFunctions()
{
}

function operatorList()
{
return array( 'ezscript', 'ezscript_require', 'ezscript_load', 'ezscriptfiles', 'ezcss', 'ezcss_require', 'ezcss_load', 'ezcssfiles' );
Expand Down
2 changes: 1 addition & 1 deletion extension/ezjscore/classes/ezjscserverrouter.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class ezjscServerRouter
protected $functionArguments = array();
protected $isTemplateFunction = false;

protected function ezjscServerRouter( $className, $functionName = 'call', array $functionArguments = array(), $isTemplateFunction = false )
protected function __construct( $className, $functionName = 'call', array $functionArguments = array(), $isTemplateFunction = false )
{
$this->className = $className;
$this->functionName = $functionName;
Expand Down
4 changes: 0 additions & 4 deletions extension/ezoe/autoloads/ezoetemplateutils.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@

class eZOETemplateUtils
{
function eZOETemplateUtils()
{
}

function operatorList()
{
return array( 'ezoe_ini_section' );
Expand Down
4 changes: 2 additions & 2 deletions extension/ezoe/ezxmltext/handlers/input/ezoeinputparser.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,12 +178,12 @@ class eZOEInputParser extends eZXMLInputParser
* @param bool $parseLineBreaks flag if line breaks should be given meaning or not
* @param bool $removeDefaultAttrs signal if attributes of default value should not be saved.
*/
function eZOEInputParser( $validateErrorLevel = eZXMLInputParser::ERROR_NONE,
public function __construct( $validateErrorLevel = eZXMLInputParser::ERROR_NONE,
$detectErrorLevel = eZXMLInputParser::ERROR_NONE,
$parseLineBreaks = false,
$removeDefaultAttrs = false )
{
$this->eZXMLInputParser( $validateErrorLevel,
parent::__construct( $validateErrorLevel,
$detectErrorLevel,
$parseLineBreaks,
$removeDefaultAttrs );
Expand Down
12 changes: 2 additions & 10 deletions extension/ezoe/ezxmltext/handlers/input/ezoexmlinput.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,9 @@
*/
class eZOEXMLInput extends eZXMLInputHandler
{
/**
* Constructor
* For more info see {@link eZXMLInputHandler::eZXMLInputHandler()}
*
* @param string $xmlData
* @param string $aliasedType
* @param eZContentObjectAttribute $contentObjectAttribute
*/
function eZOEXMLInput( $xmlData, $aliasedType, $contentObjectAttribute )
public function __construct( $xmlData, $aliasedType, $contentObjectAttribute )
{
$this->eZXMLInputHandler( $xmlData, $aliasedType, $contentObjectAttribute );
parent::__construct( $xmlData, $aliasedType, $contentObjectAttribute );

$contentIni = eZINI::instance( 'content.ini' );
if ( $contentIni->hasVariable( 'header', 'UseStrictHeaderRule' ) === true )
Expand Down
7 changes: 0 additions & 7 deletions kernel/class/ezclassfunctioncollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,6 @@

class eZClassFunctionCollection
{
/*!
Constructor
*/
function eZClassFunctionCollection()
{
}

function fetchClassListByGroups( $groupFilter, $groupFilterType = 'include' )
{
$notIn = ( $groupFilterType == 'exclude' );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,6 @@

class eZDefaultBasketInfoHandler
{
/*!
Constructor
*/
function eZDefaultBasketInfoHandler()
{
}

/*!
Calculate additional information about vat and prices for items in the basket.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ class eZFilePassthroughHandler extends eZBinaryFileHandler
{
const HANDLER_ID = 'ezfilepassthrough';

function eZFilePassthroughHandler()
public function __construct()
{
$this->eZBinaryFileHandler( self::HANDLER_ID, "PHP passthrough", eZBinaryFileHandler::HANDLE_DOWNLOAD );
parent::__construct( self::HANDLER_ID, "PHP passthrough", eZBinaryFileHandler::HANDLE_DOWNLOAD );
}

function handleFileDownload( $contentObject, $contentObjectAttribute, $type,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

class eZMySQLBackendError
{
function eZMySQLBackendError( $value, $text )
public function __construct( $value, $text )
{
$this->errorValue = $value;
$this->errorText = $text;
Expand Down
4 changes: 2 additions & 2 deletions kernel/classes/clusterfilehandlers/ezfsfilehandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ class eZFSFileHandler implements eZClusterFileHandlerInterface
/**
* Constructor.
*
* $filePath File path. If specified, file metadata is fetched in the constructor.
* @param bool $filePath File path. If specified, file metadata is fetched in the constructor.
*/
function eZFSFileHandler( $filePath = false )
public function __construct( $filePath = false )
{
eZDebugSetting::writeDebug( 'kernel-clustering', "fs::instance( '$filePath' )", __METHOD__ );
$this->Mutex = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,17 @@ class eZApproveCollaborationHandler extends eZCollaborationItemHandler
/// The contentobject was deferred and will be a draft again for reediting.
const STATUS_DEFERRED = 3;

/*!
Initializes the handler
*/
function eZApproveCollaborationHandler()
public function __construct()
{
$this->eZCollaborationItemHandler( 'ezapprove',
ezpI18n::tr( 'kernel/classes', 'Approval' ),
array( 'use-messages' => true,
'notification-types' => true,
'notification-collection-handling' => eZCollaborationItemHandler::NOTIFICATION_COLLECTION_PER_PARTICIPATION_ROLE ) );
parent::__construct(
'ezapprove',
ezpI18n::tr( 'kernel/classes', 'Approval' ),
array(
'use-messages' => true,
'notification-types' => true,
'notification-collection-handling' => eZCollaborationItemHandler::NOTIFICATION_COLLECTION_PER_PARTICIPATION_ROLE
)
);
}

function title( $collaborationItem )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,6 @@

class eZDefaultConfirmOrderHandler
{
/*!
Constructor
*/
function eZDefaultConfirmOrderHandler()
{
}

function execute( $params = array() )
{
$ini = eZINI::instance();
Expand Down
2 changes: 1 addition & 1 deletion kernel/classes/datatypes/ezauthor/ezauthor.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

class eZAuthor
{
function eZAuthor( )
public function __construct( )
{
$this->Authors = array();
$this->AuthorCount = 0;
Expand Down
4 changes: 2 additions & 2 deletions kernel/classes/datatypes/ezauthor/ezauthortype.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ class eZAuthorType extends eZDataType
{
const DATA_TYPE_STRING = "ezauthor";

function eZAuthorType()
public function __construct()
{
$this->eZDataType( self::DATA_TYPE_STRING, ezpI18n::tr( 'kernel/classes/datatypes', "Authors", 'Datatype name' ),
parent::__construct( self::DATA_TYPE_STRING, ezpI18n::tr( 'kernel/classes/datatypes', "Authors", 'Datatype name' ),
array( 'serialize_supported' => true ) );
}

Expand Down
5 changes: 0 additions & 5 deletions kernel/classes/datatypes/ezbinaryfile/ezbinaryfile.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,6 @@

class eZBinaryFile extends eZPersistentObject
{
function eZBinaryFile( $row )
{
$this->eZPersistentObject( $row );
}

static function definition()
{
static $definition = array( 'fields' => array( 'contentobject_attribute_id' => array( 'name' => 'ContentObjectAttributeID',
Expand Down
4 changes: 2 additions & 2 deletions kernel/classes/datatypes/ezbinaryfile/ezbinaryfiletype.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ class eZBinaryFileType extends eZDataType

const DATA_TYPE_STRING = "ezbinaryfile";

function eZBinaryFileType()
public function __construct()
{
$this->eZDataType( self::DATA_TYPE_STRING, ezpI18n::tr( 'kernel/classes/datatypes', "File", 'Datatype name' ),
parent::__construct( self::DATA_TYPE_STRING, ezpI18n::tr( 'kernel/classes/datatypes', "File", 'Datatype name' ),
array( 'serialize_supported' => true ) );
}

Expand Down
4 changes: 2 additions & 2 deletions kernel/classes/datatypes/ezboolean/ezbooleantype.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ class eZBooleanType extends eZDataType
{
const DATA_TYPE_STRING = "ezboolean";

function eZBooleanType()
public function __construct()
{
$this->eZDataType( self::DATA_TYPE_STRING, ezpI18n::tr( 'kernel/classes/datatypes', "Checkbox", 'Datatype name' ),
parent::__construct( self::DATA_TYPE_STRING, ezpI18n::tr( 'kernel/classes/datatypes', "Checkbox", 'Datatype name' ),
array( 'serialize_supported' => true,
'object_serialize_map' => array( 'data_int' => 'value' ) ) );
}
Expand Down
4 changes: 2 additions & 2 deletions kernel/classes/datatypes/ezcountry/ezcountrytype.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ class eZCountryType extends eZDataType

const MULTIPLE_CHOICE_FIELD = 'data_int1';

function eZCountryType()
public function __construct()
{
$this->eZDataType( self::DATA_TYPE_STRING, ezpI18n::tr( 'kernel/classes/datatypes', 'Country', 'Datatype name' ),
parent::__construct( self::DATA_TYPE_STRING, ezpI18n::tr( 'kernel/classes/datatypes', 'Country', 'Datatype name' ),
array( 'serialize_supported' => true,
'object_serialize_map' => array( 'data_text' => 'country' ) ) );
}
Expand Down
4 changes: 2 additions & 2 deletions kernel/classes/datatypes/ezdate/ezdatetype.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ class eZDateType extends eZDataType

const DEFAULT_CURRENT_DATE = 1;

function eZDateType()
public function __construct()
{
$this->eZDataType( self::DATA_TYPE_STRING, ezpI18n::tr( 'kernel/classes/datatypes', "Date", 'Datatype name' ),
parent::__construct( self::DATA_TYPE_STRING, ezpI18n::tr( 'kernel/classes/datatypes', "Date", 'Datatype name' ),
array( 'serialize_supported' => true ) );
}

Expand Down
4 changes: 2 additions & 2 deletions kernel/classes/datatypes/ezdatetime/ezdatetimetype.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ class eZDateTimeType extends eZDataType

const DEFAULT_ADJUSTMENT = 2;

function eZDateTimeType()
public function __construct()
{
$this->eZDataType( self::DATA_TYPE_STRING, ezpI18n::tr( 'kernel/classes/datatypes', "Date and time", 'Datatype name' ),
parent::__construct( self::DATA_TYPE_STRING, ezpI18n::tr( 'kernel/classes/datatypes', "Date and time", 'Datatype name' ),
array( 'serialize_supported' => true ) );
}

Expand Down
Loading

0 comments on commit 4316b42

Please sign in to comment.