Re: [PEPr] Comment on Web Services::Services_TinyURL

From: Date: Wed, 12 Sep 2007 19:32:48 +0000
Subject: Re: [PEPr] Comment on Web Services::Services_TinyURL
References: 1 2  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-48010@lists.php.net to get a copy of this message
On Sep 11, 2007, at 11:36 AM, till wrote:
On 9/11/07, Sascha Grossenbacher <saschagros@bluewin.ch> wrote:
Hi On Tue, 11 Sep 2007 09:17:56 -0700, Joe Stump <joe@joestump.net> wrote:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
No notice, no E_STRICT. Seems to be fine. Hence, Travis can extend the class for unittests without making the code any more complicated. ;-)
Since when does PHP5 allow you to call static methods non-statically without throwing a notice? This is news to me.
It seems that a static function is always called static, even with $test->staticMethod()... Simple Test: <?php class Test {
    public static function testMethod() {
        var_dump($this);
    }
} $test = new Test(); $test->testMethod(); Test::testMethod(); outputs twice(!) a notice about the undefined variable $this and null.
Interesting, and good to know. Didn't think of that. @Travis: Would this still work for you though? ;-)
One issue that doesn't resolve, small (maybe even a non-issue) as it may be is that with the current self::$api reference there's no way to inject your own api value to redirect to another site. I'm thinking along the lines of an internal proxy that tracks URLs and caches them so an outside trip to TinyURL isn't required. The other larger issue here is that even if I can sub-class the code, it becomes much harder to handle it in testing unless I sub-class it for my normal usage. I would have to depend on the object Travis instead directly on the Services_TinyURL. If I rely directly on it and can only use its methods via class-level calls, then I've effectively tied my code completely to that particular class, not an object capable of answering the calls of that class. Depending on the object loosens coupling and encourages polymorphism by saying that anything that answers to create($destination) and lookup($url) can be substituted. Now, ideally, there'd be a Services_TinyURL_Interface that Services_TinyURL implemented that'd allow me to type hint against. I'll even admit that from time to time the academic ideal might be taking things a bit far :-) -Travis

« previous php.pear.dev (#48010) next »