Created
November 11, 2012 12:59
-
-
Save suin/4054833 to your computer and use it in GitHub Desktop.
PHPは引数型のダウンキャストができないなと思ったら。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PHPは引数型のダウンキャストができないなと思ったら、 | |
Javaでダウンキャストできるのは間違いで、たんにオーバーロードだった件 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Test { | |
public static void main(String[] args) { | |
UserRepository userRepository = new UserRepository(); | |
userRepository.persist(new Object()); | |
userRepository.persist(new User()); | |
} | |
} | |
class Repository | |
{ | |
public void persist(Object entity) | |
{ | |
System.out.println("Repository"); | |
} | |
} | |
class User | |
{ | |
} | |
class UserRepository extends Repository | |
{ | |
public void persist(User user) | |
{ | |
System.out.println("UserRepository"); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Repository | |
{ | |
public function persist($entity) | |
{ | |
} | |
} | |
class User | |
{ | |
} | |
class UserRepository extends Repository | |
{ | |
public function persist(User $user) | |
{ | |
} | |
} | |
// Strict standards: Declaration of UserRepository::persist() should be compatible with Repository::persist($entity) in Untitled.php on line 22 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment