Jump to content

Fatal error: Cannot override final method BusinessLayer::Find()


Darghon

Recommended Posts

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.