2009年4月1日星期三

Re: [fw-webservices] Zend_Server_Reflection_Exception be more specific with your feedback...

Thanks for your response, however I had reviewed my code at LEAST ten times
before I submitted my question to the mailing list... Finally, I resorted
to copying my class to a new name and then, starting at the bottom, deleting
each method from the class. I was expecting to pinpoint which method was
causing the problem.

As it turned out, I continued deleting methods all the way to my __construct
- even then, the code still gives the same error. Lightbulb moment ensues -
my class is extending Zend_Db_Table and the error is obviously being thrown
in regards to some code in that class (or more accurately
Zend_Db_Table_Abstract).

I can see that this brings up a whole assortment of issues in regards to the
Zend_Json_Server - for example, a lot of return types from
Zend_Db_Table_Abstract are obviously not types that could be handled
natively by JavaScript.

So I guess the question has morphed into the following: how can I expose a
class through Zend_Json_Server that extends classes such as Zend_Db_Table?


Matthew Weier O'Phinney-3 wrote:
>
> -- edub <ewahlstr@gmail.com> wrote
> (on Tuesday, 31 March 2009, 12:05 PM -0700):
>>
>> I am working with creating a Zend_Json_Server and setting some classes
>> like
>> so:
>>
>> $server = new Zend_Json_Server();
>>
>> $server->setClass('MyClass', 'mynamespace');
>>
>> When I try to get the smd for this, Zend_Reflection throws the following
>> error about my class:
>>
>> Zend_Server_Reflection_Exception Object
>> "Variable number of arguments is not supported for services (except
>> optional
>> parameters). Number of function arguments must currespond to actual
>> number
>> of arguments described in a docblock."
>>
>> I understand exactly what this means and have gotten this code to work
>> using
>> some less complex classes - however, on the class I am attempting to
>> expose
>> right now, I just cannot find where I might have a discrepancy in my
>> docblock.
>>
>> It would be extremely usefull if the Zend_Server_Reflection threw an
>> exception that could help pinpoint which method it was having problems
>> with... Has anyone had a similar experience?
>
> Wow... I'm not sure how that exception message could be any more clear,
> actually.
>
> What it's saying is that there is a discrepancy with the number of
> arguments defined in the function call and those in its corresponding
> docblock. As an example:
>
> /**
> * Do something
> *
> * @param string $foo
> * @return string
> */
> public function doSomething($foo, $bar)
> {
> }
>
> In this example, your function requires 2 parameters -- but your
> docblock is only reporting one of them. This is an issue as we cannot
> infer any type information on the second parameter -- and thus an
> exception is raised.
>
> The opposite is also true:
>
> /**
> * Do something
> *
> * @param string $foo
> * @return string
> */
> public function doSomething()
> {
> }
>
> In this case, you may be using func_get_args() to process variable
> numbers of arguments in your method. Being a good developer, you've
> documented the fact that you might accept a parameter. However, because
> there is no corresponding _real_ parameter in the method definition,
> reflection is unaware of it, leading to a mismatch between the two.
> Again, an exception is raised.
>
> Both situtations are summed up nicely in the last sentence of that
> exception message:
>
> "Number of function arguments must correspond to actual number of
> arguments described in a docblock."
>
> --
> Matthew Weier O'Phinney
> Software Architect | matthew@zend.com
> Zend Framework | http://framework.zend.com/
>
>

--
View this message in context: http://www.nabble.com/Zend_Server_Reflection_Exception-be-more-specific-with-your-feedback...-tp22807177p22835017.html
Sent from the Zend Web Services mailing list archive at Nabble.com.

没有评论: