How to assure that a function return will be an instance of string?
<p>I want to use the FILTER_VALIDADE_EMAIL but it gives me a warning saying that it expects an string. I am new to php, and i am having trouble trying to use OO with it.</p>

<pre><code>&lt;?php

Class User {

    private $id;
    private $login_name;
    private $hashed_password;
    private $email;


    public function __construct($login_name, $email){
        $this-&gt;login_name = $login_name;
        $this-&gt;email = $email;
    }

    public function getLoginName(){
        return $this-&gt;login_name;
    }

    public function setLoginName(String $login_name){
        $this-&gt;login_name = $login_name;
    }

    public function setEmail(String $email){
        $this-&gt;email = $email;
    }

    public function getEmail(String $email){
        return (string) $this-&gt;email;
    }
}?&gt;


&lt;?php

include("../lib/php/User.php");

class UserDAO {

    private $user;

    public function __construct(){
    }

    public function getUser(){
        return $this-&gt;user;
    }

    public function setUser(User $user){
        $this-&gt;user = $user;
    }


    public function insertUser(User $user){
        $email = $user-&gt;getEmail();
        $login_name = $user-&gt;getLoginName();
        //ver http://www.php.net/manual/en/function.filter-var.php
        if(filter_var($email, FILTER_VALIDATE_EMAIL) &amp;&amp; empty($login_name)){
            echo "valid user";
        }
    }
}

$user = new User("user","user@gmail.com");
$userDAO = new UserDAO();
$userDAO-&gt;insertUser($user); ?&gt;
</code></pre>

<p>The error returned is</p>

<p>PHP Catchable fatal error:  Argument 1 passed to User::getEmail() must be an instance of String, none given</p>
