|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #62734 [Feature Request]Multiple typehint support
Submitted: 2012-08-03 04:04 UTC Modified: 2012-08-03 04:12 UTC
From: k at webnfo dot com Assigned:
Status: Duplicate Package: *General Issues
PHP Version: 5.4.5 OS:
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: k at webnfo dot com
New email:
PHP Version: OS:


 [2012-08-03 04:04 UTC] k at webnfo dot com
With Multiple typehint support, function arguments can accept multiple specific type of data.

The syntax would be like this:

function demo(TypeA|ClassA|Array $var){


Which will accept the one of those types: TypeA, ClassA, Array as valid argument.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2012-08-03 04:12 UTC]
-Status: Open +Status: Duplicate
 [2012-08-03 04:12 UTC]
Previously requested as request #31785. I don't think anything's changed, really: the stock advice of using an interface that defines the API you expect to be implemented stands, and I don't think the object-or-array case is important enough to merit this sort of change.
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Fri Oct 15 21:03:43 2021 UTC