php.net |  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 you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: k at webnfo dot com
New email:
PHP Version: OS:

 

 [2012-08-03 04:04 UTC] k at webnfo dot com
Description:
------------
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.


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-08-03 04:12 UTC] aharvey@php.net
-Status: Open +Status: Duplicate
 [2012-08-03 04:12 UTC] aharvey@php.net
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-2025 The PHP Group
All rights reserved.
Last updated: Tue Jul 01 20:01:36 2025 UTC