|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2017-08-04 23:00 UTC] stas@php.net
-Status: Open
+Status: Suspended
[2017-08-04 23:00 UTC] stas@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 21:00:01 2025 UTC |
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)