Am 21.02.2012 16:55, schrieb Martin Amps:
Could you not implement such functionality within your class as follows:

class Family {
        public function getMother() {
                if ($this->hasMother())
                        return $someObj;
                else
                        throw new BadMethodCallException(...);
        }
}

try {
        $granny_name = $baby->getMother()->getMother()->getName();
} catch (BadMethodCallException $ex) {

}

Martin

Hi Martin,

First of all, thank you for your rapid response but it doesn't address my question (or at least the question I intended to ask)

of course there is always a way to script around issues rather than adressing them. I just want to know if the change would be desired. I have code around which does exactly this, check on all levels of all possible combinations. Semantically, this is nonsense and it bloats the code. It's just a requirement because currently PHP handles this as non-recoverable fatal.

I see no reason why it would be not desirable to have PHP raise the exception rather than putting more or less repeating code snippets all around the place. That is why I am asking.


--
Ralf Lang
Linux Consultant / Developer
Tel.: +49-170-6381563
Mail: l...@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

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to