Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> niezgodność typów argumentów metody, error: must be an instance of string, string given - wtf?
Can I
post
Post #1





Grupa: Zarejestrowani
Postów: 5
Pomógł: 0
Dołączył: 7.06.2006
Skąd: Coventry, UK

Ostrzeżenie: (0%)
-----


cześć,

mam interfejs:
  1. <?php
  2. interface UserDAO {
  3.  
  4. public function findUsersByFornameSurnameOrEmail( string $queryStr );
  5.  
  6. }
  7. ?>


i implementację w MySQLUserDAO. testuję to sobie i dostaję taki błąd:

Cytat
Argument 1 passed to MySQLUserDAO::findUsersByFornameSurnameOrEmail() must be an instance
of string, string given, called in (...)


wywołanie w teście wygląda tak:

  1. <?php
  2. $queryStr = "jan";
  3. $actualUsers = $this->dao->findUsersByFornameSurnameOrEmail( $queryStr );
  4. ?>


czy te typy argumentów to muszą być typy zdefiniowane przeze mnie, a nie wbudowane w PHP?

Ten post edytował Can I 20.04.2007, 19:18:53
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
Sedziwoj
post
Post #2





Grupa: Zarejestrowani
Postów: 793
Pomógł: 32
Dołączył: 23.11.2006
Skąd: Warszawa

Ostrzeżenie: (0%)
-----


I to jest w manualu, więc nie rozumiem czemu od razu nie odesłaliście...
http://www.php.net/manual/en/language.oop5.typehinting.php" title="Zobacz w manualu PHP" target="_manual

Cytat
PHP 5 introduces Type Hinting. Functions are now able to force parameters to be objects (by specifying the name of the class in the function prototype) or arrays (since PHP 5.1).
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 24.12.2025 - 10:15