[dev] [Tickets #10880] Rdo drops objects from result when eager relation target is NULL or invalid key

Ralf Lang lang at b1-systems.de
Tue Feb 21 08:12:20 UTC 2012


>
> I'm hesitant to make this an exception, though. I see your use case, but
> for non-nested use, it means that I have to put a try/catch around
> property testing when I could otherwise just use if checks (duck typing,
> etc)...
>
> -chuck

You can check the relation key for a non-null value. But I see the issue 
too.

Another approach would be a "null" response object that only throws an 
exception if the user tries to access attributes or methods of the 
response. Both the Rdo_Base object and the "null" object would need to 
implement a simple true-false-interface which could be checked similarly 
to your former if ($object) {}. At least in my use cases, porting would 
be easy.

Countable comes to mind, though it feels a bit like abuse.

Even better would be if the null response object itself could evaluate 
to null, false, 0 or "" but I haven't read changelog on the builtin 
interfaces/magic methods in a while.



-- 
Ralf Lang
Linux Consultant / Developer
Tel.: +49-170-6381563
Mail: lang at b1-systems.de

B1 Systems GmbH
Osterfeldstraße 7 / 85088 Vohburg / http://www.b1-systems.de
GF: Ralph Dehner / Unternehmenssitz: Vohburg / AG: Ingolstadt,HRB 3537


More information about the dev mailing list