Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 0.3.2

Bug #14512 dispatcher.php throws Notice about incorrect Array to String conversation
Submitted: 2008-08-18 01:53 UTC
From: alexmerz Assigned: cweiske
Status: Closed Package: Event_SignalEmitter (version 0.3.0)
PHP Version: Irrelevant OS:
Roadmaps: (Not assigned)    
Subscription  


 [2008-08-18 01:53 UTC] alexmerz (Alexander Merz)
Description: ------------ The example script docs/examples/dispatcher.php uses emit() with an array of signal parameters (line 27). The signal parameter is fetched by Logger:log(). log() just prints the parameter. Because the signal parameter is passed as array and packed in another array as parameter for log(). But log() just expects a flat array. So implode() produces a Notice and the output is just Array / signal message. To make it short: remote the array() call from line 27. Test script: --------------- See dispatcher.php: class Logger { public function log() { $args = func_get_args(); echo 'Log: ' . implode(' / ', $args) . "\n"; } } class Downloader { public function download($file) { .. for ($nA = 0; $nA < 100; $nA += 10) { $dp->emit('download-progress', array($file, $nA)); } ... } } Expected result: ---------------- No Notice schould be thrown, correct log message output. Log: http://some.where/over/the/rainbow.htm / begin download Beginning download Log: http://some.where/over/the/rainbow.htm / 0 / progress Log: http://some.where/over/the/rainbow.htm / 10 / progress Log: http://some.where/over/the/rainbow.htm / 20 / progress Log: http://some.where/over/the/rainbow.htm / 30 / progress Log: http://some.where/over/the/rainbow.htm / 40 / progress Log: http://some.where/over/the/rainbow.htm / 50 / progress Log: http://some.where/over/the/rainbow.htm / 60 / progress Log: http://some.where/over/the/rainbow.htm / 70 / progress Log: http://some.where/over/the/rainbow.htm / 80 / progress Log: http://some.where/over/the/rainbow.htm / 90 / progress Log: http://some.where/over/the/rainbow.htm / download complete Actual result: -------------- Log: http://some.where/over/the/rainbow.htm / begin download Beginning download PHP Notice: Array to string conversion in C:\PHP5.2.3\dispatcher.php on line 16 Notice: Array to string conversion in C:\PHP5.2.3\dispatcher.php on line 16 Log: Array / progress PHP Notice: Array to string conversion in C:\PHP5.2.3\dispatcher.php on line 16 ....

Comments

 [2008-08-18 08:33 UTC] cweiske (Christian Weiske)
That's because I changed the emit() api and didn't update the example. Bad me.
 [2008-08-23 13:25 UTC] cweiske (Christian Weiske)
Thank you for your bug report. This issue has been fixed in the latest released version of the package, which you can download at http://pear.php.net/get/Event_SignalEmitter