1

I'm new to PHPStorm and I imported an existing project in this IDE. Now I receive many warnings like

Method 'query' not found in class

I read about using PHPDoc-blocks in order to declare the origin of variables which are not defined in the current class, but I cannot get out how I should do it for this situation:

class loginModel extends Model{
  public function checkLogin(){
    [...]
    if($this->db->query($sql)){[...]} //Warning as stated above
    [...]
  }
}

$this->db itself is inheritated from class Model:

class Model{

  protected $db;     

  private function connect(){
    $this->db = new PGSQL();
  }
}

and therefore can access the public PGSQL method named query.
Maybe not that well designed, but how could I solve these messages without downgrading their severity?

1 Answer 1

5
class Model{

    /**
     * @var PGSQL
     */
    protected $db;

    private function connect(){
        $this->db = new PGSQL();
    }
}

Docblocks work on properties too

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.