Req #66927 [NEW]: Request new type operator "exhibits"

From: Date: Tue, 18 Mar 2014 17:29:14 +0000
Subject: Req #66927 [NEW]: Request new type operator "exhibits"
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-184825@lists.php.net to get a copy of this message
From: rdanner at gmail dot com Operating system: Ubuntu 12.04 LTS PHP version: 5.4.26 Package: *General Issues Bug Type: Feature/Change Request Bug description:Request new type operator "exhibits" Description: ------------ Much like the "instanceof" operator can be used to evaluate if a class is and instance of (or descendant of) a particular class, an "exhibits" keyword would be useful for evaluating if a class exhibits a particular trait: if ($baz exhibits someTrait) {} Test script: --------------- //Currently, this can be done with something along the lines of $ob = new someClass; // see if $ob is an instance of a class that exhibits the "neato" trait if (class_exists('someClass') and in_array('neato', class_uses($ob)) { // it does! } //but this would be much cleaner as: if ($ob exhibits neato) { // yup! } -- Edit bug report at https://bugs.php.net/bug.php?id=66927&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=66927&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=66927&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=66927&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=66927&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=66927&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=66927&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=66927&r=needscript Try newer version: https://bugs.php.net/fix.php?id=66927&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=66927&r=support Expected behavior: https://bugs.php.net/fix.php?id=66927&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=66927&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=66927&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=66927&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=66927&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=66927&r=dst IIS Stability: https://bugs.php.net/fix.php?id=66927&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=66927&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=66927&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=66927&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=66927&r=mysqlcfg

« previous php.bugs (#184825) next »