|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2011-07-22 14:36 UTC] rasmus@php.net
-Status: Open
+Status: Bogus
[2011-07-22 14:36 UTC] rasmus@php.net
[2011-07-22 15:05 UTC] php-bugs at majkl578 dot cz
[2011-07-22 15:53 UTC] rasmus@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Nov 28 17:00:01 2025 UTC |
Description: ------------ It is not possible to use trait as a typehint in function declaration. Use case: Extending few different classes to use a trait in them where these classes doesn't have same parent. Then I want to specify typehint, because I require some methods which are declared by that trait. Test script: --------------- trait Foo {} class Bar { use Foo; } function test(Foo $obj) { echo 'hello'; } test(new Bar); Expected result: ---------------- hello Actual result: -------------- Catchable fatal error: Argument 1 passed to test() must be an instance of Foo, instance of Bar given...