1

My problem is Declaration error I read other some problem but none of them aren't solve my problem. I don't want hide this error notice.How I can do solve this error? My error notice is;

Strict Standards: Declaration of MyFilesPolicy::getFileList() should be compatible with MyFile::getFileList($area = false, $extra_filter = false, $order_by = false, $from = false, $num_elem = false) in /forum/lib/lib.myfiles.php on line ..

Class Myfile{

function getFileList($area = false, $extra_filter = false, $order_by = false, $from = false, $num_elem = false) {

    $query = "
    SELECT ".implode(', ', $this->arr_field)."
    FROM ".$this->getFilesTable()."
    WHERE owner = '".$this->id_user."'";
    if($area !== false) $query .= " AND area = '".$area."'";
    if($extra_filter !== false) $query .= $extra_filter;
    if($order_by !== false) $query .= " ORDER BY ".$this->arr_field[$order_by]."";
    else $query .= " ORDER BY title";

    if($from !== false) {
        $query .= " LIMIT ".$from.", ".$num_elem;
    }

    $re_query = $this->_query($query);
    return $re_query;
}
}

class MyFilesPolicy extends MyFile {

function getFileList($area = false, $order_by = false, $from = false, $num_elem = false) {

    $arr_policy = array( MF_POLICY_FREE );
    if($this->isViewerFriend() || $this->_viewer == $this->_id_user) {
        $arr_policy[] = MF_POLICY_FRIENDS;
        $arr_policy[] = MF_POLICY_TEACHER_AND_FRIENDS;
    }
    if($this->isViewerTeacher() || $this->_viewer == $this->_id_user) {
        $arr_policy[] = MF_POLICY_TEACHER;
        $arr_policy[] = MF_POLICY_TEACHER_AND_FRIENDS;
    }
    if($this->_viewer == $this->_id_user) $arr_policy = array(  MF_POLICY_FREE,MF_POLICY_NOONE );

    $query = "
    SELECT ".implode(', ', $this->arr_field)."
    FROM ".$this->getFilesTable()."
    WHERE owner = '".$this->_id_user."'
        AND ".$this->arr_field[MYFILE_POLICY]." IN ( ".implode(',', $arr_policy)." ) ";
    if($area !== false) $query .= " AND area = '".$area."'";
    if($order_by !== false) $query .= " ORDER BY ".$this->arr_field[$order_by]."";
    else $query .= " ORDER BY title";
    if($from !== false) {
        $query .= " LIMIT ".$from.", ".$num_elem;
    }

    $re_query = $this->_query($query);
    return $re_query;
}
}
shinemagin
  • 23
  • 7

2 Answers2

1

You missed out the parameter $extra_filter from the parameter list in the extended class

function getFileList($area = false, $order_by = false, $from = false, $num_elem = false) {

So add it like this

function getFileList($area = false, $extra_filter = false, $order_by = false, $from = false, $num_elem = false) {
RiggsFolly
  • 93,638
  • 21
  • 103
  • 149
0

spot the difference, I've given a slight hint for you:

Class Myfile

function getFileList($area = false, $extra_filter = false, $order_by = false, $from = false, $num_elem = false) {

Class MyFilesPolicy

function getFileList($area = false,                        $order_by = false, $from = false, $num_elem = false) {

as the error says:

MyFilesPolicy::getFileList() should be compatible with MyFile::getFileList()

Wee Zel
  • 1,294
  • 9
  • 11
  • I found it, thank you answer but I thought it would cause another mistake – shinemagin Sep 17 '17 at 18:41
  • duplicate post? maybe this will clarify https://stackoverflow.com/questions/3115388/declaration-of-methods-should-be-compatible-with-parent-methods-in-php – Wee Zel Sep 17 '17 at 19:09