Req #72344 [Opn->Sus]: Allow the Splat Operator with InstanceOf
| From: | stas@php.net | Date: | Fri, 04 Aug 2017 23:00:34 +0000 |
| Subject: | Req #72344 [Opn->Sus]: Allow the Splat Operator with InstanceOf | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-210495@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=72344&edit=1
ID: 72344
Updated by: stas@php.net
Reported by: chad dot sikorra at gmail dot com
Summary: Allow the Splat Operator with InstanceOf
-Status: Open
+Status: Suspended
Type: Feature/Change Request
Package: *General Issues
Operating System: Irrelevant
PHP Version: 7.0.7
Block user comment: N
Private report: N
New Comment:
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 (internals@lists.php.net) as an RFC. Please read the guide about creating RFCs here:
https://wiki.php.net/rfc/howto
If you haven't had experience with writing RFCs before, it is advised to seek guidance on the
Internals list (http://php.net/mailing-lists.php) 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.
Previous Comments:
------------------------------------------------------------------------
[2016-06-06 15:28:12] chad dot sikorra at gmail dot com
Description:
------------
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:
----------------
DateTime
Actual result:
--------------
PHP Parse error: syntax error, unexpected '...' (T_ELLIPSIS)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=72344&edit=1