Darghon Posted June 6, 2012 Share Posted June 6, 2012 Hi all, I seem to be encountering the title error every time I initiate an object that extends my BusinessLayer object. The error means that I attempt to re-declare a final method, and that's not allowed, but I'm not redeclaring anything. Are there any potential other reasons that this error is triggered? The following 3 objects are the objects that I construct. User: <?php /** * This class is the user control for User. * Any custom actions to this database object need to be specified here. * * @author Darghon */ class User extends baseUser{ } ?> baseUser: <?php class baseUser extends BusinessLayer{ /** * Public get function that retrieves the ID * @return integer $ID */ public function getID(){ return $this->data->ID; } /** * Public set function that sets the ID * @param integer $ID */ public function setID($val){ $this->data->ID = $val; } /** * Public get function that retrieves the Name * @return string $Name */ public function getName(){ return $this->data->Name; } /** * Public set function that sets the Name * @param string $Name */ public function setName($val){ $this->data->Name = $val; } /** more getters and setters here, but have been cropped **/ /** * Public get function that retrieves the Record_Version * @return integer $Record_Version */ public function getRecordVersion(){ return $this->data->Record_Version; } /** * Public set function that sets the Record_Version * @param integer $Record_Version */ public function setRecordVersion($val){ $this->data->Record_Version = $val; } /** * Public get function that retrieves the Delflag * @return boolean $Delflag */ public function getDelflag(){ return $this->data->Delflag; } /** * Public set function that sets the Delflag * @param boolean $Delflag */ public function setDelflag($val){ $this->data->Delflag = $val; } /** * Magic to string method * @return String */ public function __toString(){ return $this->data->Name; } /** * Object validator, if this class returns true, the object can is valid and can be saved. * @return Boolean */ public function validate(){ return parent::validate(); } /** * Public Destructor, unset every used valiable * @return String */ public function __destroy(){ foreach($this as $key => $val) unset($this->$key); unset($this); } } ?> BusinessLayer: <?php abstract class BusinessLayer { /** * Dataobject that is embedded within the business object * @var DataLayer */ protected $data = null; /** * New objects require a new instance of */ public function __construct($data = null) { $class = 'D' . get_class($this); if (get_class($data) == $class) { $this->data = $data; } else { $this->data = new $class(); } } public function _set($var, $value) { $this->$var = $value; } public function fromArray($arr) { foreach ($arr as $field => $value) { $fun = "set" . Tools::strtocamelcase($field, true); if ($fun == "setId") $fun = "setID"; if (!method_exists($this, $fun)) continue; if (strpos($fun, "ID") > -1) { $this->$fun((int) $value); } else { $this->$fun($value); } } } public function toArray() { $result = array(); $fields = $this->data->getFields(); foreach ($fields as $field => $changed) { $result[$field] = $this->data->$field; } return $result; } public function validate() { return true; } /** MORE CODE CROPPING HERE **/ /** * Static function that creates a "Find" static function to each business object, which in turn is basicly a shortkey to get The Findertype, or when an ID is passed, to get the object by that ID * @return Finder */ final public static function & Find($id = null) { $caller = function_exists('get_called_class') ? get_called_class() : Tools::getCaller(); if ($id !== null) { $return = &Database::Find($caller)->byID($id); } else { $return = &Database::Find($caller); } return $return; } public static function is_a($class_name) { return (__CLASS__ == $class_name) ? true : false; } } ?> As you can see, the function isn't re-declared, so I have no clue why it triggers the error now... Using Ubuntu 12.04 and php 5.3 Thx for any help Link to comment https://forums.phpfreaks.com/topic/263764-fatal-error-cannot-override-final-method-businesslayerfind/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.