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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
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

Add a Patch

Pull Requests

Add a Pull Request

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-2020 The PHP Group
All rights reserved.
Last updated: Sun Sep 27 18:01:26 2020 UTC