p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   BOOK: Professional PHP 5 ISBN: 978-0-7645-7282-1 (http://p2p.wrox.com/forumdisplay.php?f=152)
-   -   [CH04] Interfaces (http://p2p.wrox.com/showthread.php?t=25255)

Norm 2782 February 8th, 2005 08:11 AM

[CH04] Interfaces
I just got to chapter 4 and got to the abstract_widget.php file.
It returned the following error:

Fatal error: Declaration of Widget::update() must be compatible with that of Observer::update() in C:\server\www\prophp\ch04\abstract_widget.php on line 6

I solved it by replacing the interface used in the example by the following one:


interface Observer {
    public function update(Observable $observable);

Is this 'legit' user of interfaces? Or is this a dirty solution to a (maybe very simple) problem?

Norm 2782, why are you here?
- Normality

tnlinh May 30th, 2005 01:04 AM

I encountered the same problem and did exactly the same.

nitram June 15th, 2005 08:13 PM

Yep, another one. Good one Norm2782.
I still don't see the benefit of this example or pattern for a web application. Anyone?

Nice Widgets, but that's about it.

As stated on p. 85, a redraw is not an option unless you reload the page.... so why putting Observers on data?

Nimmit June 16th, 2005 04:56 AM

can someone please clarify whether or not the previous example is a valid use for interfaces or not?

I had the same problem in chapter two!!


interface Musician {
     public function addInstrument();
     public function getInstruments();

     public function assignToBand();
     public function getMusicianType();

Gave me this error
Fatal error: Declaration of Guitarist::addInstrument() must be compatible with that of Musician::addInstrument()


interface Musician {
     public function addInstrument(Instrument $instument);
     public function getInstruments();

     public function assignToBand(Band $band);
     public function getMusicianType();

Seems to work

Is this correct ??



All times are GMT -4. The time now is 01:11 AM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.