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
 [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-2019 The PHP Group
All rights reserved.
Last updated: Sat May 25 21:01:27 2019 UTC