I've just created the test case and reproduced the behaviour (I won't
say "problem" because I think perhaps what we recommend today might be
the real problem).  I tried something which I thought I'd already
attempted and it worked.  So here's the explanation.

It seems having interfaces changes when the class gets defined.  We
currently suggest the following code layout for a service
implementation:

/* includes for anything the service impl requires */
include 'stuff.php';

// this must be the last include
include 'SCA/SCA.php';

class MyService {}

This all works fine.  SCA::initComponent(...) runs in the include of
SCA.php and it tests for classexists('MyService'); and finds that it
does exist.

The problem comes when we add an interface, as shown below:

/* includes for anything the service impl requires */
include 'stuff.php';

// this must be the last include
include 'SCA/SCA.php';

interface MyServiceInterface {}

class MyService implements MyServiceInterface {}

In the above example, the test for classexists('MyService') fails.
Get_declared_classes() confirms it doesn't exist and
get_declared_interfaces() shows that the interface does exist.  The
simple/obvious fix, which I thought I'd tried last week, but clearly
hadn't is to move the include after the class declaration, as follows:

/* includes for anything the service impl requires */
include 'stuff.php';

interface MyServiceInterface {}

class MyService implements MyServiceInterface {}

// this must be the last include
include 'SCA/SCA.php';

I need to turn my tests into phpunit tests and merge with the latest
in pecl.  I'm hoping I'll be able to do that tonight.

Graham.

On 10 Sep, 16:14, Caroline Maynard <[EMAIL PROTECTED]> wrote:
> Graham Charters wrote:
> > Just a quick status update...
>
> > I've done the code to optionally allow an interface to be specified
> > and tested this independent of a protocol binding and all works fine.
> > Unfortunately, when called from a remote invocation, the classexists
> > tests for the service implementation fails.  Get_declared_classes()
> > confirms that it does not have the definition and
> > get_declared_interfaces() confirms that it knows about the
> > interfaces.  Removing the interfaces makes everything work as before,
> > so it appears to be a PHP nit.
>
> There are some peculiarities in this area, and people familiar with
> inheritance from other languages are likely to have expectations which
> are not satisfied by PHP. For example, there are restrictions on how you
> can use inherited interfaces in type hints, which result in fatal errors
> for code you might reasonably expect to work. It doesn't sound as if
> that's the problem here, but it may be something similar.
>
> > I'm going to try to create a little test case to reproduce this
> > outside SCA.
>
> That would help.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"phpsoa" group.
To post to this group, send email to phpsoa@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.co.uk/group/phpsoa?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to