????JFIF??x?x????'
Server IP : 79.136.114.73 / Your IP : 3.145.45.170 Web Server : Apache/2.4.7 (Ubuntu) PHP/5.5.9-1ubuntu4.29 OpenSSL/1.0.1f System : Linux b8009 3.13.0-170-generic #220-Ubuntu SMP Thu May 9 12:40:49 UTC 2019 x86_64 User : www-data ( 33) PHP Version : 5.5.9-1ubuntu4.29 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /proc/self/root/home/b8009/php-5.6.22/ext/spl/tests/ |
Upload File : |
--TEST-- SPL: CachingIterator and __toString --FILE-- <?php function test($ar, $flags) { echo "===$flags===\n"; $it = new CachingIterator($ar, 0); try { $it->setFlags($flags); } catch (Exception $e) { echo 'Exception: ' . $e->getMessage() . "\n"; var_dump($it->getFlags()); return; } var_dump($it->getFlags()); try { foreach($it as $v) { var_dump((string)$it); } } catch (Exception $e) { echo 'Exception: ' . $e->getMessage() . "\n"; } } class MyItem { function __construct($value) { $this->value = $value; } function __toString() { return (string)$this->value; } } class MyArrayIterator extends ArrayIterator { function __toString() { return $this->key() . ':' . $this->current(); } } $ar = new MyArrayIterator(array(1, 2, 3)); test($ar, CachingIterator::CALL_TOSTRING); test($ar, CachingIterator::TOSTRING_USE_KEY); test($ar, CachingIterator::TOSTRING_USE_CURRENT); $ar = new MyArrayIterator(array(new MyItem(1), new MyItem(2), new MyItem(3))); test($ar, CachingIterator::TOSTRING_USE_INNER); test($ar, CachingIterator::CALL_TOSTRING | CachingIterator::TOSTRING_USE_KEY); test($ar, CachingIterator::CALL_TOSTRING | CachingIterator::TOSTRING_USE_CURRENT); test($ar, CachingIterator::CALL_TOSTRING | CachingIterator::TOSTRING_USE_INNER); test($ar, CachingIterator::TOSTRING_USE_KEY | CachingIterator::TOSTRING_USE_CURRENT); test($ar, CachingIterator::TOSTRING_USE_KEY | CachingIterator::TOSTRING_USE_INNER); echo "===X===\n"; try { $it = new CachingIterator($ar, CachingIterator::CALL_TOSTRING); $it->setFlags(0); } catch (Exception $e) { echo 'Exception: ' . $e->getMessage() . "\n"; } try { $it = new CachingIterator($ar, CachingIterator::TOSTRING_USE_INNER); $it->setFlags(0); } catch (Exception $e) { echo 'Exception: ' . $e->getMessage() . "\n"; } ?> ===DONE=== --EXPECTF-- ===1=== int(1) string(1) "1" string(1) "2" string(1) "3" ===2=== int(2) string(1) "0" string(1) "1" string(1) "2" ===4=== int(4) string(1) "1" string(1) "2" string(1) "3" ===8=== int(8) string(3) "0:1" string(3) "1:2" string(3) "2:3" ===3=== Exception: Flags must contain only one of CALL_TOSTRING, TOSTRING_USE_KEY, TOSTRING_USE_CURRENT, TOSTRING_USE_INNER int(0) ===5=== Exception: Flags must contain only one of CALL_TOSTRING, TOSTRING_USE_KEY, TOSTRING_USE_CURRENT, TOSTRING_USE_INNER int(0) ===9=== Exception: Flags must contain only one of CALL_TOSTRING, TOSTRING_USE_KEY, TOSTRING_USE_CURRENT, TOSTRING_USE_INNER int(0) ===6=== Exception: Flags must contain only one of CALL_TOSTRING, TOSTRING_USE_KEY, TOSTRING_USE_CURRENT, TOSTRING_USE_INNER int(0) ===10=== Exception: Flags must contain only one of CALL_TOSTRING, TOSTRING_USE_KEY, TOSTRING_USE_CURRENT, TOSTRING_USE_INNER int(0) ===X=== Exception: Unsetting flag CALL_TO_STRING is not possible Exception: Unsetting flag TOSTRING_USE_INNER is not possible ===DONE===