Req #72344 [NEW]: Allow the Splat Operator with InstanceOf

From: Date: Mon, 06 Jun 2016 15:28:14 +0000
Subject: Req #72344 [NEW]: Allow the Splat Operator with InstanceOf
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-201480@lists.php.net to get a copy of this message
From: chad dot sikorra at gmail dot com Operating system: Irrelevant PHP version: 7.0.7 Package: *General Issues Bug Type: Feature/Change Request Bug description:Allow the Splat Operator with InstanceOf 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 bug report at https://bugs.php.net/bug.php?id=72344&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=72344&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=72344&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=72344&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=72344&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=72344&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=72344&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=72344&r=needscript Try newer version: https://bugs.php.net/fix.php?id=72344&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=72344&r=support Expected behavior: https://bugs.php.net/fix.php?id=72344&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=72344&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=72344&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=72344&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=72344&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=72344&r=dst IIS Stability: https://bugs.php.net/fix.php?id=72344&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=72344&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=72344&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=72344&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=72344&r=mysqlcfg

« previous php.bugs (#201480) next »