note 111353 added to class.callbackfilteriterator

From: Date: Mon, 11 Feb 2013 08:32:19 +0000
Subject: note 111353 added to class.callbackfilteriterator
Groups: php.notes 
Request: Send a blank email to php-notes+get-193596@lists.php.net to get a copy of this message
@dave1010, you posted an example for the CallbackFilterClass, it a good example, but if you googled you would also have found this link http://www.php.net/~helly/php/ext/spl/callbackfilteriterator_8inc_source.html which is a the PHP version of what has been implemented in php 5.4 BTW here is my extended version of the above link with the abillity to switch the filter on the fly using the reflector class <?php final class ExtendedCallbackFilterIterator extends \CallbackFilterIterator { /** * Set or change the callback function * @param callback $callback The (new) function to use as callback * @throws \InvalidArgumentException when $callback isn't valid */ public function setCallback( $callback ) { if ( !is_callable( $callback ) ) { throw new \InvalidArgumentException( 'Argument 1 passed to '.__CLASS__.'::'.__METHOD__.' must be a valid callback.' ); } $rf = new \ReflectionProperty( 'CallbackFilterIterator', 'callback' ); $rf->setAccessible(true); $rf->setValue($this, $callback); } } ?> ---- Server IP: 69.147.83.199 Probable Submitter: 80.113.17.205 ---- Manual Page -- http://php.net/manual/en/class.callbackfilteriterator.php Edit -- https://master.php.net/note/edit/111353 Del: integrated -- https://master.php.net/note/delete/111353/integrated Del: useless -- https://master.php.net/note/delete/111353/useless Del: bad code -- https://master.php.net/note/delete/111353/bad+code Del: spam -- https://master.php.net/note/delete/111353/spam Del: non-english -- https://master.php.net/note/delete/111353/non-english Del: in docs -- https://master.php.net/note/delete/111353/in+docs Del: other reasons-- https://master.php.net/note/delete/111353 Reject -- https://master.php.net/note/reject/111353 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#193596) next »