|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #72344 Allow the Splat Operator with InstanceOf
Submitted: 2016-06-06 15:28 UTC Modified: 2017-08-04 23:00 UTC
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:0 (0.0%)
From: chad dot sikorra at gmail dot com Assigned:
Status: Suspended Package: *General Issues
PHP Version: 7.0.7 OS: Irrelevant
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.
Block user comment
Status: Assign to:
Bug Type:
From: chad dot sikorra at gmail dot com
New email:
PHP Version: OS:


 [2016-06-06 15:28 UTC] chad dot sikorra at gmail dot com
With the addition of the splat operator in PHP 5.6 it became very useful to have an array of objects and pass them to a method and still have type checking (even when using splat, such as: foo(\DateTime ...$dates).

I'm not sure if this is practical/possible to implement, but it would be very useful to use that same sort of type checking with the splat operator for instanceof checks, such as: if (...$dates instanceof \DateTime). Currently that syntax produces "PHP Parse error:  syntax error, unexpected '...' (T_ELLIPSIS)".

Test script:
$foo = [ new \DateTime(), new \DateTime()];

if (...$foo instanceof \DateTime) {
    echo "DateTime";

Expected result:

Actual result:
PHP Parse error:  syntax error, unexpected '...' (T_ELLIPSIS)


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2017-08-04 23:00 UTC]
-Status: Open +Status: Suspended
 [2017-08-04 23:00 UTC]
Thank you for your interest in PHP and for submitting a feature request. Please be aware that due to the magnitude of change this request requires, it would be necessary to discuss it on PHP Internals list ( as an RFC. Please read the guide about creating RFCs here:
If you haven't had experience with writing RFCs before, it is advised to seek guidance on the Internals list ( and/or solicit help from one of the experienced developers. 

Please to not consider this comment as a negative view on the merits of your proposal - every proposal which requires changes of certain magnitude, even the very successful and widely supported ones, must be done through the RFC process. This helps make the process predictable, transparent and accessible to all developers.
PHP Copyright © 2001-2018 The PHP Group
All rights reserved.
Last updated: Tue Oct 23 09:01:26 2018 UTC