On 8 May 2010 20:20, Daniel Convissor <dani...@analysisandsolutions.com> wrote:
> Hi Folks:
>
> On Wed, May 05, 2010 at 10:31:15AM +0200, Hannes Magnusson wrote:
>>
>> None of our docs mention this (see intl and mysqli for example).
>>
>> It is clearly expected behavior and is documented in the oo chapters.
>
> Just because a function takes an object as a parameter does not mean the
> function has to modify that object.  The DateTime functions return a
> DateTime object.  In the following example:
>
>    $date = date_create();
>    $result = date_date_set($date, 2001, 2, 3);
>
> An unsuspecting user could think only $result contains the new date and
> go about needlessly writing in new variables rather than just using
> $date.  And eventually some such user will add a user comment telling
> people that $date gets modified.
>
> It seems to me the documentation should be explicit as to how things
> work.  The current parameter text says:
>
> Procedural style only: A DateTime object returned by date_create()
>
> I suggest it say something like:
>
> Procedural style only: A DateTime object returned by date_create().
> The function modifies this object.
>
> What do people think?
>
> Thanks,
>
> --Dan
>
> --
>  T H E   A N A L Y S I S   A N D   S O L U T I O N S   C O M P A N Y
>            data intensive web and database programming
>                http://www.AnalysisAndSolutions.com/
>  4015 7th Ave #4, Brooklyn NY 11232  v: 718-854-0335 f: 718-854-0409
>

As I see things (please correct me if I'm wrong ... I know you will!),
any object passed as a parameter can be modified within the
function/method as long as the object has a suitable interface for
that to happen (i.e. some public properties/methods).

This is what I read from the OOP5 pages.

If so, all object parameters are &objects.

Whereas with scalars, the function/method prototype clearly indicates
"by reference" using &, for objects they are always by reference, so
should always have &.


If there is a way to read the methodsynopsis, looking for <parameter
role="reference"> for a parameter, then could this automatically be
used to include the appropriate entity for  "The function can/may
modify this object."



-- 
-----
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

Reply via email to